I learn the mark-end-of-sentence is handy to select to end of the sentence as handy as C-M-Space which select a word. from Select to the sentence of line in a shortcut

The function is not bound by default, so I tried kinds of keys permutations.

  • one option is C-M-s (s for sentence) and C-M corresponding to C-M-Space to select a word, then faild.

    (global-set-key (kbd "C-M-s") #'mark-end-of-sentence)

global-set-key (kbd “C-M-s”) 'mark-end-of-sentence

  • It remind me that M-e move-forward to end of a sentence, then set 'C-M-ewhich cover the original(sp-end-of-sexp &optional ARG)`, still failed.

    (global-set-key (kbd "C-M-s") #'mark-end-of-sentence)

  • Final solution, I set a key sequence randomly.

Take it seriously, what's the rules to bind keys? Two items I could get:

  1. Not conflict with the current important and frequent keys
  2. as semantic as possible to assistance memory.

I am determined passing my emacs.config to the grandsons, how could I play a intelligent role from now?

  • 1
    Not rules, rather some conventions are defined here.
    – Pouya
    Jan 9, 2020 at 12:42
  • 1
    The question is rambling, and not very clear. Could you please clarify/simplify it?
    – Drew
    Jan 9, 2020 at 17:01
  • In particular, specify what you mean by "failed", and show the code you tried, which "failed".
    – Drew
    Jan 9, 2020 at 17:45
  • question revised @Drew
    – Wizard
    Jan 10, 2020 at 0:46

1 Answer 1


Per the conventions referenced in a comment on the question,

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.

So as a user, you redefine arbitrary keys outside of that range at your own risk, though of course people do it all the time.

Recently as I work on my config I've been trying to go back to original conventions as much as possible. For example, one of the first things in my first .emacs in 1995 was to bind query-replace-regexp to M-s (instead of M-%), but I've just turned it back to M-%. It's still customized because I want regexp by default instead of regular, but it follows the convention so is more portable, easier to talk to others about, less likely to conflict with functionality added in the future, etc.

For what bindings I do add, I have been trying to use custom prefix maps as a way to get unconstrained namespaces. Relevant to your example about commands to mark things, I have a "mark-map" to support different functions to mark text objects. Of course you still need to bind the map to some prefix key, and maybe C-M-SPC would be a good choice, so mark-word would become C-M-SPC w. Or if you wanted to be more standards compliant you could use C-c m. Or I think meta-capital-letter combinations are overlooked; how about M-M (shift-meta-m)?

(defvar mark-text-object-map (make-sparse-keymap)
  "Keymap for selecting text objects")
(global-set-key (kbd "C-M-SPC") mark-text-object-map)
(global-set-key (kbd "C-M-@") mark-text-object-map) ;; How C-M-SPC shows up in some terminals
(define-key mark-text-object-map (kbd "b") #'mark-whole-buffer)
(define-key mark-text-object-map (kbd "w") #'mark-word)
(define-key mark-text-object-map (kbd "s") #'mark-end-of-sentence)
;; get a listing of the available commands
(define-key mark-text-object-map (kbd "?")
    #'(lambda ()
        (with-help-window (help-buffer)
          (with-current-buffer (help-buffer)
            (insert (substitute-command-keys "\\{mark-text-object-map}"))))))

All that said, binding new keys isn't everything. Decomposition can be a good strategy. Sometimes it's easier to do C-SPC M-f, or C-SPC M-e, than it is to bind and use a dedicated command :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.