emacs-devel
[Top][All Lists]
Advanced

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

`global-set-key' vs `keymap-global-set' `key-valid-p' syntax


From: Emanuel Berg
Subject: `global-set-key' vs `keymap-global-set' `key-valid-p' syntax
Date: Tue, 07 May 2024 08:19:26 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

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 via email to

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