all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* About the key binding convention: C-x is reserved by emacs itself whereas the C-c prefix is used for user defined keybindings.
@ 2021-09-21  5:20 Hongyi Zhao
  2021-09-21 16:08 ` [External] : " Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Hongyi Zhao @ 2021-09-21  5:20 UTC (permalink / raw)
  To: help-gnu-emacs

I noticed some interesting statements on key binding conventions of Emacs:

https://emacs.stackexchange.com/questions/42164/convention-about-using-c-x-or-c-c-as-prefix-keys,
told the following:

There is the convention that the C-x is reserved by emacs itself
whereas the C-c prefix is used for user defined keybindings.

https://github.com/Malabarba/emacs-google-this/issues/1#issue-12700382,
told the following:

As far as I know, C-x is generally reserved for Emacs itself, and thus
off limits to 3rd party libraries.

Furthermore, I also noticed the official manual of Emacs on this topic:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html

But I can't find the convention regarding C-x. Any hints will be helpful.

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [External] : About the key binding convention: C-x is reserved by emacs itself whereas the C-c prefix is used for user defined keybindings.
  2021-09-21  5:20 About the key binding convention: C-x is reserved by emacs itself whereas the C-c prefix is used for user defined keybindings Hongyi Zhao
@ 2021-09-21 16:08 ` Drew Adams
  2021-09-21 17:54   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2021-09-21 16:08 UTC (permalink / raw)
  To: Hongyi Zhao, help-gnu-emacs

> There is the convention that the C-x is reserved by emacs itself
> whereas the C-c prefix is used for user defined keybindings.

No, there is NO such convention regarding C-x.
No key bindings are "reserved by emacs [for] itself".

The only "reserved" bindings are those reserved for
users.  (And users can bind any keys they want;
they're not _limited_ to the keys reserved for them.)

This post of mine states the situation clearly (IMO):

https://emacs.stackexchange.com/a/42166/105

(It's the accepted answer to the question you cited.)

Wrt C-x, it says this:

  You'll note that there is no convention regarding
  C-x.  An unstated convention, or just good
  advice/practice is this one, however: If you
  replace some existing, standard Emacs binding
  (i.e., one that you get from Emacs as distributed,
  without loading any 3rd-party libraries) then that
  might confuse or annoy some users of your code.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [External] : About the key binding convention: C-x is reserved by emacs itself whereas the C-c prefix is used for user defined keybindings.
  2021-09-21 16:08 ` [External] : " Drew Adams
@ 2021-09-21 17:54   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 3+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-09-21 17:54 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

> You'll note that there is no convention regarding C-x.
> An unstated convention, or just good advice/practice is this
> one, however: If you replace some existing, standard Emacs
> binding (i.e., one that you get from Emacs as distributed,
> without loading any 3rd-party libraries) then that might
> confuse or annoy some users of your code.

I know but if the user installs it is with the intention of
changing the current state of Emacs ... and

If the user installs it he/she is unlikely to want to setup
the keys manually, especially in the early phase where he/she
just wants to get a grip on (not literally ha) what the
software is, if indeed it'd be left to him/her that would be
a poor choise of person doing it all the more ... and

If the software relies of interactive stuff that must be fast
(i.e. mere practically, invocation wise) to make sense to have
a poor shortcut for key functionality would be to have
a modern quality fully suspended 1x12 MTB, only the saddle is
way to high which makes it disgrace anyway for the presumed
rider ... and

If the user installs a second package which is of the same
nature, what will happen?

I have no solution, maybe one could have yet another package
that would interactively ask the user, what are the fastest,
closest, and most intuitive and ergonomic keystrokes? [user
hits] and the next one? [etc] then when done one would have
a stack for this and then every installed package would
annotate functionality with respect to these characteristics
and it would be mapped to the shortcuts one by one ...
(Theoretical example, not suggesting anyone do it.)

Or rely on the user.

Or do something else?

Actually I just posted, it is a great example of this exact
situation which I describe (from my incompleteness-POW), which is

- it was one of the first things I ever wrote BTW and I use it
ever time I use the computer, or more times than that often -
the "Created" refers to the package restyle - it ~twice that
old, I'd approximate. (Unbelievably such basic stuff has to be
written by Elisp novices all the same.)

Yes, those keys are arbitrarily assigned in terms of anyone
else using it who might use other stuff - just what I like -
not that I'm THAT different from everybody else - I'm mean
AARGH

But I have no idea what creative things other people might do
their `message-mode'. See what I mean? ("Moggle" is a FF7
reference BTW. And pun och "toggle". Cute!)

;;; moggle.el --- iterate headers and body in message-mode -*- lexical-binding: t
;;;
;;; Commentary:
;;;
;;; Author: Emanuel Berg (incal) <moasenwood@zoho.eu>
;;; Created: 2014-07-04
;;; Keywords: news, mail
;;; License: GPL3+
;;; URL: https://dataswamp.org/~incal/emacs-init/moggle.el
;;; Version: 2.0.0
;;;
;;; In the current message, hit one (1) key to go to the next
;;; field to type. The first fields in a message are the
;;; headers -- "To", "Subject", and so on -- and the last one
;;; is the body.
;;;
;;; And, there is another key to do the exact same thing, only
;;; in the opposite direction!
;;;
;;; By default, `next-header' is bound to TAB ("\t"), and
;;; `previous-header' to BACKTAB (<backtab>; i.e., right-shift
;;; and TAB).
;;;
;;; This also plays seamlessly with the abbrevs of the
;;; ~/.mailrc file. Try it: setup an alias, type it in the
;;; "To" header, and hit TAB.
;;;
;;; For example, for mail addresses, ~/.mailrc can look like
;;; this:
;;;
;;;   alias john    "John DiFool <difool@incal.com>"
;;;   alias kate    "Katherine Moss <mossy@km.com>"
;;;   alias friends john kate
;;;
;;; (For Usenet/Gmane groups, ordinary abbrevs are setup: geh
;;; -> gnu.emacs.help (gmane.emacs.help) and so on.)
;;;
;;; All in all, this makes for rapid, mouse-free editing of
;;; mails and Usenet/Gmane posts.
;;;
;;; Code:

(require 'message)

(defun get-header-separator-pos ()
  "Get the position of `mail-header-separator'."
  (save-excursion
    (rfc822-goto-eoh)
    (point) ))

(defun at-end-of-line-p ()
  "True iff point is at the end of the current line."
  (looking-at "$"))

(defun next-line-header-or-body ()
  "Go to the next header field.
If already at the last header field go to the message body."
  (if (re-search-forward ": " (get-header-separator-pos) t)
      (end-of-line)
    (message-goto-body) ))

(defun end-of-line-or-next-line ()
  "If not at the end of a line go there.
Else got to the next header field if it exists."
  (if (at-end-of-line-p)
      (next-line-header-or-body)
    (end-of-line) ))

(defun next-header ()
  "Go to the next header field.
If already at the last one go to the message body."
  (interactive)
  (if (< (point) (get-header-separator-pos))
      (progn
        (expand-abbrev)
        (end-of-line-or-next-line) )
    (goto-char (point-min))
    (end-of-line-or-next-line) ))

(defun prev-header ()
  "Go to the previous header field.
If already at the first one got to the message body."
  (interactive)
  (if (< (point) (get-header-separator-pos))
      (progn
        (expand-abbrev)
        (if (= 1 (line-number-at-pos))
            (message-goto-body)
          (forward-line -1) )
        (end-of-line) )
    (goto-char (get-header-separator-pos))
    (backward-char 1) ))

(define-key message-mode-map "\t"      #'next-header)
(define-key message-mode-map [backtab] #'prev-header)

(provide 'moggle)
;;; moggle.el ends here

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-21 17:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-21  5:20 About the key binding convention: C-x is reserved by emacs itself whereas the C-c prefix is used for user defined keybindings Hongyi Zhao
2021-09-21 16:08 ` [External] : " Drew Adams
2021-09-21 17:54   ` Emanuel Berg via Users list for the GNU Emacs text editor

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.