all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: emacs-devel@gnu.org
Subject: `global-set-key' vs `keymap-global-set' `key-valid-p' syntax
Date: Tue, 07 May 2024 08:19:26 +0200	[thread overview]
Message-ID: <874jba9ma9.fsf@dataswamp.org> (raw)

In the docstring to `global-set-key' they say it is a legacy
function and one should use `keymap-global-set' instead.

This note is hardcoded in the docstring so the byte-compiler
don't tell you about it.

What is the difference between obsolete, legacy, and
deprecated source code? We learn from gpt4 that

  - obsolete code is outdated and no longer used;
  
  - legacy code is still in use but outdated; and
  
  - deprecated code is discouraged from being used but still functional.

Since `global-set-key' and `keymap-global-set' superficially
have identical interfaces, it would seem it would be easy to
do a search and replace. However, this is not so because one
syntax to denote keys, if I just take one example from my own
Elisp - which, BTW, has 78 instances of global-set-key - isn't
allowed with keymap-global-set.

;; disable keys
(global-set-key "\C-h\C-p" #'ignore) ; view-emacs-problems
(global-set-key "\C-hr"    #'ignore) ; info-emacs-manual
(global-set-key "\C-ht"    #'ignore) ; help-with-tutorial
(global-set-key "\C-x\C-c" #'ignore) ; save-buffers-kill-terminal
(global-set-key "\C-x\C-n" #'ignore) ; set-goal-column

The reason is they are not valid by `key-valid-p'.

I don't know what the reasoning behind this was? One gets the
feeling that Emacs is obsolete but still in use, and left in
the repos only to avoid conflicts with legacy programmers.

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




             reply	other threads:[~2024-05-07  6:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-07  6:19 Emanuel Berg [this message]
2024-05-07 11:15 ` `global-set-key' vs `keymap-global-set' `key-valid-p' syntax Emanuel Berg
2024-05-07 13:43   ` Emanuel Berg
2024-05-07 13:47   ` Emanuel Berg
2024-05-07 14:42     ` Andreas Schwab
2024-05-09 10:06       ` Emanuel Berg
2024-05-09 10:33       ` Emanuel Berg
2024-05-09 15:24         ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874jba9ma9.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.