emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Clarifying the C-c letter guideline


From: Philip Kaludercic
Subject: Clarifying the C-c letter guideline
Date: Sun, 14 Feb 2021 13:12:52 +0100

Hi,

a few days ago, there was a discussion on help-gnu-emacs[0],
specifically on this one paragraph from (elisp) Key Binding Conventions:

> • Don’t define ‘C-c LETTER’ as a key in Lisp programs.  Sequences
>   consisting of ‘C-c’ and a letter (either upper or lower case) are
>   reserved for users; they are the *only* sequences reserved for
>   users, so do not block them.

There seems to be some uncertainty in how this should be
interpreted. Does this mean that...

- No package/library/third-party code may ever bind a command or map to
  C-c LETTER, under any circumstances (in the letter of the law).

- A package/library/third-party code may bind a command or a map to C-c
  LETTER, if the user is explicitly asked and he or she gives
  permission (in the spirit of the law).

I lean towards the second interpretation, which would allow something
like

    (defcustom foobar-bind-to nil
      "Bind command `foobar' to C-c LETTER."
      :set (lambda (sym val)
             (cond (val (global-set-key (format "%c" val) #'foobar))
                   ((where-is-internal #'foobar)
                    (global-set-key (car (where-is-internal #'foobar)) nil)))
             (set-default sym val))
      :type '(choice (const :tag "Don't bind" nil)
                     (character :tag "Bind to")))

(even though I don't think code like this is necessary in the first
place, but this is just an example).

The background of this discussion is to settle the question, whether/how
packages might suggest binding a global command, if their interface is
not a major or minor mode, but a specific command
(e.g. magit-status). Using defcustom is probably not the best idea, but
something I think that something along these lines might be interesting
to have.

So I'd be interested in what the mailing list has to say on this
question. Should this section be rephrased to clarify the guideline?

[0] https://lists.gnu.org/archive/html/help-gnu-emacs/2021-02/msg00426.html

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]