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

[craftedv2beta] Standardized way for naming functions #347

Closed
jvdydev opened this issue Sep 10, 2023 · 5 comments
Closed

[craftedv2beta] Standardized way for naming functions #347

jvdydev opened this issue Sep 10, 2023 · 5 comments
Labels
discussion Discuss things, make decisions documentation Improvements or additions to documentation enhancement New feature or request

Comments

@jvdydev
Copy link
Contributor

jvdydev commented Sep 10, 2023

I don't know if we have a standardized way for naming functions, if we do, we probably should document it.

;;; Version with '/'
;; Signature
(crafted-[module]/[function-name] ...)

;; Example
(defun crafted-defaults/some-special-function (...)
  ...)

;;; Version with '-'
;; Signature
(crafted-[module]-[function-name] ...)

;; Example
(defun crafted-defaults-some-special-function (...)
  ...)

I think putting in the module name is important as it automatically documents where it comes from.
As for the separation character, I'm open for both (/ or -).

The / makes it look a little more special (compared to e.g. built-in functions), but my understanding is that the / is usually used for personal functions, not libraries (or by extension something like Crafted Emacs).
Also the - may be nicer to look at with interactive, but that's just my point of view.

We could split it between interactive/configuration functions and e.g. hook functions, but I feel that may add additional mental overhead without much benefit.

@jvdydev jvdydev added enhancement New feature or request discussion Discuss things, make decisions documentation Improvements or additions to documentation labels Sep 10, 2023
@sthesing
Copy link
Contributor

I was always working on the assumption that crafted-[module]-[function-name] is the established way.

If it's up for discussion, I prefer that over the / alternative. I haven't read tons of Emacs Lisp code, but from what I've seen I also gathered that - like @jvdydev mentioned - / is to designate personal namespaces while libraries, packages etc. use -.

@jvdydev
Copy link
Contributor Author

jvdydev commented Sep 10, 2023

ye, I had a similar assumption, however I noticed we don't have a clear guideline.
Since we want to move towards more automated testing and linting in the future, I think having the guidelines introduced beforehand is good so it's not as drastic of a change.
It also helps new people find their grip in the project easier.

Same naming would apply for variables/defcustoms (although those should get rare, but having a good guideline on naming them won't hurt).

Just wanted a small discussion place instead of just changing the guidelines docs 😄

@jvdydev
Copy link
Contributor Author

jvdydev commented Sep 10, 2023

I also totally forgot we link to the Emacs Lisp Style Guide in the README.
Probably should mid-to-long-term introduce a contributing section in the info file for contributing code (the "CONTRIBUTING.org" file is only on docs currently, probably merge code stuff in there too).

Might be useful for people who are comfortable in Emacs, but may not be comfortable with git/GitHub and how to contribute things.

Just some thoughts, once I have some more concrete ideas on how that would look, I'll PR them.

More thoughts, opinions and suggestions welcome 😄

@jeffbowman
Copy link
Contributor

I'm not as big a fan of the / separator between the "namespace" and the function name. It's just harder for me to type quickly, which is usually mitigated by a completion UI, but still...

Generally, I agree we should follow a consistent naming structure, for me that would be module-function or module-variable, thus crafted-defaults-do-a-thing for a function or crafted-defaults-thing for a variable. I believe that is inline with the style guide we link to anyway, so sticking with that makes sense to me at least.

We might consider adding a CONTRIBUTING.org to the modules section to describe how to contribute code as a deliverable for RC1... thoughts?

@jvdydev
Copy link
Contributor Author

jvdydev commented Sep 22, 2023

I'm closing this as the functions have somewhat standardized naming now.
Any further discussion on style guide should be in #69 or related.

@jvdydev jvdydev closed this as completed Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discuss things, make decisions documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants