bbatsov / emacs-lisp-style-guide

A community-driven Emacs Lisp style guide
1.08k stars 53 forks source link

Add sharp quote advice (fixes #7). #12

Closed skeeto closed 9 years ago

skeeto commented 10 years ago

Adds advice according to #7.

shosti commented 10 years ago

Question: should this apply to hooks as well? If so, there should probably be an example since most examples floating around the web don't use sharp-quotes.

skeeto commented 10 years ago

@shosti That's a good point. It looks like key bindings and hooks are cases where the manual uses plain quoting. It's also another situation where it's a (usually) top-level expression that's intentionally referring to a global function.

The way I'm sort of seeing it is that regular users writing their .emacs configs can just stick to plain quotes all the time. It's very ad hoc and user configurations are rarely byte compiled anyway. However, package authors, the kind of people using this style guide, should be more rigorous in their discipline.

bbatsov commented 10 years ago

I think you should also mention in the rule the rationale behind it.

Malabarba commented 10 years ago

Although the lexical aspect is mostly moot in keybinds and hooks, the sharp quote still gives the compiler useful information. Might it be best to say something along lines of "for keybind and hooks, it is optional but recommended"? Or would we rather not say that since the manual doesn't use it?

bbatsov commented 10 years ago

@skeeto Ping :-)

bbatsov commented 9 years ago

@skeeto Ping :-)

dgutov commented 9 years ago

I don't think we should list key bindings or hooks as exceptions.

AFAICS, sharp quotes have a consistent benefit (byte compiler warnings), and no real drawbacks in any usages. There are actually a lot of places of them being used in key binding forms inside Emacs core (roughly ~100 matches). The ones in lisp/net/quickurl.el, for example, were added originally in 1999 by RMS himself.

bbatsov commented 9 years ago

I totally agree.

On Sunday, January 25, 2015, Dmitry Gutov notifications@github.com wrote:

I don't think we should list key bindings or hooks as exceptions.

AFAICS, sharp quotes have a consistent benefit (byte compiler warnings), and no real drawbacks in any usages. There are actually a lot of places of them being used in key binding forms inside Emacs core (roughly ~100 matches). The ones in lisp/net/quickurl.el, for example, were added originally in 1999 by RMS himself.

— Reply to this email directly or view it on GitHub https://github.com/bbatsov/emacs-lisp-style-guide/pull/12#issuecomment-71371627 .

Best Regards, Bozhidar Batsov

http://www.batsov.com

swsnr commented 9 years ago

So do I. A function is a function, whether in a key binding or not.

Malabarba commented 9 years ago

Me too. Despite my previous on-the-fence comment, I've since started using and recommending it unconditionally.

bbatsov commented 9 years ago

Guess @skeeto forgot about this PR, so one of us should probably commit the updated rule/examples.

dgutov commented 9 years ago

Done, kinda.

I'm not sure what to write about macros: the cl-labels example returns (:local :local) in the current Emacs master. Maybe it was just a long-standing bug, but either way it's there in 24.4 and earlier.