all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* `global-set-key' vs `keymap-global-set' `key-valid-p' syntax
@ 2024-05-07  6:19 Emanuel Berg
  2024-05-07 11:15 ` Emanuel Berg
  0 siblings, 1 reply; 8+ messages in thread
From: Emanuel Berg @ 2024-05-07  6:19 UTC (permalink / raw)
  To: emacs-devel

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




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

end of thread, other threads:[~2024-05-09 15:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-07  6:19 `global-set-key' vs `keymap-global-set' `key-valid-p' syntax Emanuel Berg
2024-05-07 11:15 ` 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

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.