Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod_in_name is confusing #17

Closed
hpdeifel opened this issue Jul 24, 2019 · 4 comments
Closed

mod_in_name is confusing #17

hpdeifel opened this issue Jul 24, 2019 · 4 comments

Comments

@hpdeifel
Copy link

mod_in_name doesn't seem to have any effect, neither as parameter to #[module] nor [defun], unless I'm misunderstanding its purpose.

E.g. a rust function

#[emacs::defun(mod_in_name = false)]
fn foo(_env: &emacs::Env, n: i64) -> emacs::Result<i64> {
   Ok(n)
}

is defined in elisp as module-name-foo instead of just foo.

Notice that this is also true for the test cases of this project. See e.g. vec_size in test-module/src/test_vector.rs, which is called from elisp as t/vec-size

@ubolonton
Copy link
Owner

That option is a bit confusing. It is about Rust's submodule mod, not Emacs's dynamic module.

For example, in the case of vec_size, it is to prevent the name from being t/test-vector-vec-size.

It's documented here. If you have read it and still misunderstood, I'll have to improve the doc.

@hpdeifel
Copy link
Author

Ah, I see. I have in fact not looked at this particular section of the guide, my bad.

The reason for my confusion is probably the documentation for emacs_macros::module, which reads

mod_in_name: Whether to put module path in function names. Default to true. This can also be overridden for each individual function, by an option of the same name on [#[defun]].

There could be an indication that it is actually about the Rust "module path" instead of the Emacs module, especially since the macro itself is called module. The documentation for emacs_macros::defun is clearer, but I just skimmed over it because I thought I already understood mod_in_name from the docstring of module.

The example in your link really helps, maybe it would be a good idea to put a shorter version of that in the API reference.


Side question: So the way to have the Elisp function name derived only from the Rust function name is to set defun_prefix and separator to "" and mod_in_name to false. This feels like going against the grain (which may be intended), but maybe a shorthand could be useful?

@ubolonton
Copy link
Owner

Good point! I'll update the doc.

Side question: So the way to have the Elisp function name derived only from the Rust function name is to set defun_prefix and separator to "" and mod_in_name to false. This feels like going against the grain (which may be intended), but maybe a shorthand could be useful?

For defun_prefix and separator, yes they are intended, since Lisp functions should usually be prefixed with their package name. For mod_in_name, I'm starting to think false is a better default. I think they are not too bad though, as they are specified only once per crate. I want to wait for #9 before revamping crate-wide options.

@ubolonton ubolonton changed the title mod_in_name does not work mod_in_name is confusing Jul 25, 2019
@ubolonton
Copy link
Owner

This was fixed in the latest release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants