From: Stefan Kangas <stefankangas@gmail.com>
Date: Fri, 14 Mar 2025 23:09:45 +0000 (+0100)
Subject: Recommend using 'keymap-global-set' in Commentaries
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=be2fca4232cbd69adb6074a388e31fcc7bfe0740;p=emacs.git

Recommend using 'keymap-global-set' in Commentaries

* lisp/bs.el, lisp/calculator.el, lisp/cedet/data-debug.el:
* lisp/help-at-pt.el, lisp/hilit-chg.el, lisp/mail/mspools.el:
* lisp/mh-e/mh-e.el, lisp/mouse-copy.el, lisp/mouse-drag.el:
* lisp/net/browse-url.el, lisp/net/webjump.el, lisp/printing.el:
* lisp/progmodes/cfengine.el, lisp/progmodes/ebnf2ps.el:
* lisp/ps-print.el, lisp/repeat.el, lisp/term/wyse50.el:
* lisp/term/x-win.el, lisp/vcursor.el, lisp/woman.el:
Recommend using 'keymap-global-set' instead of 'global-set-key'.

(cherry picked from commit 679ad95a67fbecafd203c9e7f55547a312b3833b)
---

diff --git a/lisp/bs.el b/lisp/bs.el
index 75cea1bd5b6..c2022185860 100644
--- a/lisp/bs.el
+++ b/lisp/bs.el
@@ -73,8 +73,8 @@
 ;; This package offers two functions for buffer cycling.  If you want to cycle
 ;; through buffer list you can use `bs-cycle-next' or `bs-cycle-previous'.
 ;; Bind these function to a key like
-;;   (global-set-key [(f9)]   'bs-cycle-previous)
-;;   (global-set-key [(f10)]  'bs-cycle-next)
+;;   (keymap-global-set "<f9>"  #'bs-cycle-previous)
+;;   (keymap-global-set "<f10>" #'bs-cycle-next)
 ;;
 ;; Both functions use a special subset of all buffers for cycling to avoid
 ;; to go through internal buffers like *Messages*.
diff --git a/lisp/help-at-pt.el b/lisp/help-at-pt.el
index 47732c7e8fd..64f7b0de017 100644
--- a/lisp/help-at-pt.el
+++ b/lisp/help-at-pt.el
@@ -40,8 +40,8 @@
 ;;
 ;; Suggested key bindings:
 ;;
-;; (global-set-key [C-tab] 'scan-buf-next-region)
-;; (global-set-key [C-M-tab] 'scan-buf-previous-region)
+;; (keymap-global-set "C-<tab>" #'scan-buf-next-region)
+;; (keymap-global-set "C-M-<tab>" #'scan-buf-previous-region)
 
 ;;; Code:
 
diff --git a/lisp/hilit-chg.el b/lisp/hilit-chg.el
index 93ced6a5484..28a4b5a6907 100644
--- a/lisp/hilit-chg.el
+++ b/lisp/hilit-chg.el
@@ -113,8 +113,8 @@
 
 
 ;;     Possible bindings:
-;; (global-set-key '[C-right] #'highlight-changes-next-change)
-;; (global-set-key '[C-left]  #'highlight-changes-previous-change)
+;; (keymap-global-set "C-<right>" #'highlight-changes-next-change)
+;; (keymap-global-set "C-<left>"  #'highlight-changes-previous-change)
 ;;
 ;;     Other interactive functions (that could be bound if desired):
 ;; `highlight-changes-mode'
diff --git a/lisp/mail/mspools.el b/lisp/mail/mspools.el
index df956e8f58a..d9f54642029 100644
--- a/lisp/mail/mspools.el
+++ b/lisp/mail/mspools.el
@@ -62,8 +62,8 @@
 
 ;; Extras.
 ;;
-;; (global-set-key '[S-f1] 'mspools-show) ;Bind mspools-show to Shift F1.
-;; (setq mspools-update t)                ;Automatically update buffer.
+;; (keymap-global-set "S-<f1>" #'mspools-show) ;Bind mspools-show to Shift F1.
+;; (setopt mspools-update t)                ;Automatically update buffer.
 
 ;; Interface with the mail filter.
 ;; We assume that the mail filter drops new mail into the spool
diff --git a/lisp/mouse-copy.el b/lisp/mouse-copy.el
index d022d57796b..cbd3f360c3e 100644
--- a/lisp/mouse-copy.el
+++ b/lisp/mouse-copy.el
@@ -36,14 +36,15 @@
 ;; for ``one-click scrolling''.
 ;;
 ;; To use mouse-copy, place the following in your init file:
-;;	(require 'mouse-copy)
-;;     (global-set-key [M-down-mouse-1] 'mouse-drag-secondary-pasting)
-;;     (global-set-key [M-S-down-mouse-1] 'mouse-drag-secondary-moving)
-;;
-;; (These definitions override the old binding of M-mouse-1 to
-;; mouse-drag-secondary.  I find I don't use that command much so its
-;; loss is not important, and it can be made up with a M-mouse-1
-;; followed by a M-mouse-3.  I personally reserve M-mouse bindings
+;;     (autoload 'mouse-drag-secondary-pasting "mouse-copy")
+;;     (autoload 'mouse-drag-secondary-moving "mouse-copy")
+;;     (keymap-global-set "M-<down-mouse-1>" #'mouse-drag-secondary-pasting)
+;;     (keymap-global-set "M-S-<down-mouse-1>" #'mouse-drag-secondary-moving)
+;;
+;; (These definitions override the old binding of `M-<mouse-1>' to
+;; `mouse-drag-secondary'.  I find I don't use that command much so its
+;; loss is not important, and it can be made up with a `M-<mouse-1>'
+;; followed by a `M-mouse-3'.  I personally reserve M-mouse bindings
 ;; for my window manager and bind everything to C-mouse.)
 ;;
 ;;
diff --git a/lisp/mouse-drag.el b/lisp/mouse-drag.el
index e86c0f3590c..bb27994bbca 100644
--- a/lisp/mouse-drag.el
+++ b/lisp/mouse-drag.el
@@ -48,9 +48,9 @@
 ;;
 ;; To use mouse-drag, place the following in your init file:
 ;; -either-
-;;     (global-set-key [down-mouse-2] 'mouse-drag-throw)
+;;     (keymap-global-set "<down-mouse-2>" #'mouse-drag-throw)
 ;; -or-
-;;     (global-set-key [down-mouse-2] 'mouse-drag-drag)
+;;     (keymap-global-set "<down-mouse-2>" #'mouse-drag-drag)
 ;;
 ;;
 ;;
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 1a0612bba89..02d25b0ade4 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -71,7 +71,7 @@
 ;; M-x browse-url
 
 ;; To display a URL by shift-clicking on it, put this in your init file:
-;;      (global-set-key [S-mouse-2] 'browse-url-at-mouse)
+;;      (keymap-global-set "S-<mouse-2>" 'browse-url-at-mouse)
 ;; (Note that using Shift-mouse-1 is not desirable because
 ;; that event has a standard meaning in Emacs.)
 
diff --git a/lisp/net/webjump.el b/lisp/net/webjump.el
index 4afd9b292c5..9f0a8d0afbd 100644
--- a/lisp/net/webjump.el
+++ b/lisp/net/webjump.el
@@ -41,13 +41,13 @@
 
 ;; You may wish to add something like the following to your init file:
 ;;
-;;   (global-set-key "\C-cj" 'webjump)
-;;   (setq webjump-sites
-;;         (append '(
-;;                   ("My Home Page" . "www.someisp.net/users/joebobjr/")
-;;                   ("Pop's Site"   . "www.joebob-and-son.com/")
-;;                   )
-;;                 webjump-sample-sites))
+;;   (keymap-global-set "C-c j" #'webjump)
+;;   (setopt webjump-sites
+;;           (append '(
+;;                     ("My Home Page" . "www.someisp.net/users/joebobjr/")
+;;                     ("Pop's Site"   . "www.joebob-and-son.com/")
+;;                     )
+;;                   webjump-sample-sites))
 ;;
 ;; The above loads this package, binds `C-c j' to invoke WebJump, and adds your
 ;; personal favorite sites to the hotlist.
diff --git a/lisp/printing.el b/lisp/printing.el
index c84ee54eb7f..99408eef6fe 100644
--- a/lisp/printing.el
+++ b/lisp/printing.el
@@ -450,21 +450,21 @@
 ;;
 ;; Current global keyboard mapping is:
 ;;
-;;    (global-set-key [print]     'pr-ps-fast-fire)
-;;    (global-set-key [M-print]   'pr-ps-mode-using-ghostscript)
-;;    (global-set-key [S-print]   'pr-ps-mode-using-ghostscript)
-;;    (global-set-key [C-print]   'pr-txt-fast-fire)
-;;    (global-set-key [C-M-print] 'pr-txt-fast-fire)
+;;    (keymap-global-set "<print>"     'pr-ps-fast-fire)
+;;    (keymap-global-set "M-<print>"   'pr-ps-mode-using-ghostscript)
+;;    (keymap-global-set "S-<print>"   'pr-ps-mode-using-ghostscript)
+;;    (keymap-global-set "C-<print>"   'pr-txt-fast-fire)
+;;    (keymap-global-set "C-M-<print>" 'pr-txt-fast-fire)
 ;;
 ;; As a suggestion of global keyboard mapping for some `printing' commands:
 ;;
-;;    (global-set-key "\C-ci"  'pr-interface)
-;;    (global-set-key "\C-cbp" 'pr-ps-buffer-print)
-;;    (global-set-key "\C-cbx" 'pr-ps-buffer-preview)
-;;    (global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript)
-;;    (global-set-key "\C-crp" 'pr-ps-region-print)
-;;    (global-set-key "\C-crx" 'pr-ps-region-preview)
-;;    (global-set-key "\C-crr" 'pr-ps-region-using-ghostscript)
+;;    (keymap-global-set "C-c i"   'pr-interface)
+;;    (keymap-global-set "C-c b p" 'pr-ps-buffer-print)
+;;    (keymap-global-set "C-c b x" 'pr-ps-buffer-preview)
+;;    (keymap-global-set "C-c b b" 'pr-ps-buffer-using-ghostscript)
+;;    (keymap-global-set "C-c r p" 'pr-ps-region-print)
+;;    (keymap-global-set "C-c r x" 'pr-ps-region-preview)
+;;    (keymap-global-set "C-c r r" 'pr-ps-region-using-ghostscript)
 ;;
 ;;
 ;; Options
@@ -2969,13 +2969,13 @@ Calls `pr-update-menus' to adjust menus."
 (global-set-key [(control meta print)] 'pr-txt-fast-fire)
 
 ;;; You can also use something like:
-;;;(global-set-key "\C-ci"  'pr-interface)
-;;;(global-set-key "\C-cbp" 'pr-ps-buffer-print)
-;;;(global-set-key "\C-cbx" 'pr-ps-buffer-preview)
-;;;(global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript)
-;;;(global-set-key "\C-crp" 'pr-ps-region-print)
-;;;(global-set-key "\C-crx" 'pr-ps-region-preview)
-;;;(global-set-key "\C-crr" 'pr-ps-region-using-ghostscript)
+;;;(keymap-global-set "C-c i"   'pr-interface)
+;;;(keymap-global-set "C-c b p" 'pr-ps-buffer-print)
+;;;(keymap-global-set "C-c b x" 'pr-ps-buffer-preview)
+;;;(keymap-global-set "C-c b b" 'pr-ps-buffer-using-ghostscript)
+;;;(keymap-global-set "C-c r p" 'pr-ps-region-print)
+;;;(keymap-global-set "C-c r x" 'pr-ps-region-preview)
+;;;(keymap-global-set "C-c r r" 'pr-ps-region-using-ghostscript)
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el
index 9d9d1e8aa9d..acdb9a10cf7 100644
--- a/lisp/progmodes/cfengine.el
+++ b/lisp/progmodes/cfengine.el
@@ -52,7 +52,7 @@
 ;; the policy, it's a quick way to make it more legible without
 ;; manually reindenting it.  For instance:
 
-;; (global-set-key [(control f4)] 'cfengine3-reformat-json-string)
+;; (keymap-global-set "C-<f4>" 'cfengine3-reformat-json-string)
 
 ;; This is not the same as the mode written by Rolf Ebert
 ;; <ebert@waporo.muc.de>, distributed with cfengine-2.0.5.  It does
diff --git a/lisp/progmodes/ebnf2ps.el b/lisp/progmodes/ebnf2ps.el
index 0147707f80d..d5a10eab2a8 100644
--- a/lisp/progmodes/ebnf2ps.el
+++ b/lisp/progmodes/ebnf2ps.el
@@ -148,9 +148,9 @@
 ;;
 ;; Any of the `ebnf-' commands can be bound to keys.  Here are some examples:
 ;;
-;;    (global-set-key 'f22 'ebnf-print-buffer) ;f22 is prsc
-;;    (global-set-key '(shift f22) 'ebnf-print-region)
-;;    (global-set-key '(control f22) 'ebnf-despool)
+;;    (keymap-global-set "<f22>" #'ebnf-print-buffer) ;f22 is prsc
+;;    (keymap-global-set "S-<f22>" #'ebnf-print-region)
+;;    (keymap-global-set "C-<f22>" #'ebnf-despool)
 ;;
 ;;
 ;; Invoking Ebnf2ps in Batch
diff --git a/lisp/ps-print.el b/lisp/ps-print.el
index ba0d543bbcc..53302a71efb 100644
--- a/lisp/ps-print.el
+++ b/lisp/ps-print.el
@@ -145,9 +145,9 @@
 ;; `ps-spool-buffer-with-faces', `ps-spool-region-with-faces', and
 ;; `ps-despool'.  Here are the bindings I use on my Sun 4 keyboard:
 ;;
-;;   (global-set-key 'f22 'ps-spool-buffer-with-faces) ;f22 is prsc
-;;   (global-set-key '(shift f22) 'ps-spool-region-with-faces)
-;;   (global-set-key '(control f22) 'ps-despool)
+;;   (keymap-global-set "<f22>" #'ps-spool-buffer-with-faces) ;f22 is prsc
+;;   (keymap-global-set "S-<f22>" #'ps-spool-region-with-faces)
+;;   (keymap-global-set "C-<f22>" #'ps-despool)
 ;;
 ;;
 ;; The Printer Interface
diff --git a/lisp/repeat.el b/lisp/repeat.el
index b8f2c6715c1..9a4336424be 100644
--- a/lisp/repeat.el
+++ b/lisp/repeat.el
@@ -54,8 +54,8 @@
 ;; correctly if `repeat' is invoked through a rebinding to a single keystroke
 ;; and the global variable repeat-on-final-keystroke is set to a value
 ;; that doesn't include that keystroke.  For example, the lines
-;;   (global-set-key "\C-z" 'repeat)
-;;   (setq repeat-on-final-keystroke "z")
+;;   (keymap-global-set "C-z" #'repeat)
+;;   (setopt repeat-on-final-keystroke "z")
 ;; in your .emacs would allow `edit-kbd-macro' to work correctly when C-z was
 ;; used in a keyboard macro to invoke `repeat', but would still allow C-x z
 ;; to be used for `repeat' elsewhere.  The real reason for documenting this
diff --git a/lisp/term/wyse50.el b/lisp/term/wyse50.el
index e956ee120bc..875218d7269 100644
--- a/lisp/term/wyse50.el
+++ b/lisp/term/wyse50.el
@@ -145,14 +145,14 @@ M-r	M-x move-to-window-line, Funct up-arrow or down-arrow are similar"
   ;;         ;; By unsetting C-a and then binding it to a prefix, we
   ;;         ;; allow the rest of the function keys which start with C-a
   ;;         ;; to be recognized.
-  ;;         '(("\C-a"	nil)
-  ;;           ("\C-k"	nil)
-  ;;           ("\C-j"	nil)
-  ;;           ("\C-l"	nil)
-  ;;           ("\C-h"	nil)
-  ;;           ("\er"	nil)))
-  ;;   (global-set-key (car key-definition)
-  ;;                   (nth 1 key-definition)))
+  ;;         '(("C-a"	nil)
+  ;;           ("C-k"	nil)
+  ;;           ("C-j"	nil)
+  ;;           ("C-l"	nil)
+  ;;           ("C-h"	nil)
+  ;;           ("M-r"	nil)))
+  ;;   (keymap-global-set (car key-definition)
+  ;;                      (nth 1 key-definition)))
   (fset 'enable-arrow-keys nil))
 
 (provide 'term/wyse50)
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index 91b5bd5838a..1863ff92c77 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -1318,7 +1318,7 @@ This returns an error if any Emacs frames are X frames."
   ;; and turned the Emacs f10 back on.
   ;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
   ;; (if (featurep 'motif)
-  ;;     (global-set-key [f10] 'ignore))
+  ;;     (keymap-global-set "<f10>" 'ignore))
 
   ;; Enable CLIPBOARD copy/paste through menu bar commands.
   (menu-bar-enable-clipboard)
diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el
index 00362cb1e6c..aad14db6e95 100644
--- a/lisp/textmodes/table.el
+++ b/lisp/textmodes/table.el
@@ -333,7 +333,7 @@
 ;;
 ;;   (add-hook 'table-cell-map-hook
 ;;     (lambda ()
-;;       (local-set-key [<key sequence>] '<function>)))
+;;       (keymap-local-set "<key sequence>" '<function>)))
 ;;
 ;; Adding the above to your init file is a common way to customize a
 ;; mode specific keymap.  However it does not work for this package.
diff --git a/lisp/vcursor.el b/lisp/vcursor.el
index 645102c198b..ff381c01b12 100644
--- a/lisp/vcursor.el
+++ b/lisp/vcursor.el
@@ -250,7 +250,7 @@
 ;; In addition to any other bindings, vcursor-map contains key definitions
 ;; for handling the vcursor.  You should assign this to a prefix key
 ;; in the usual way, e.g.
-;;      (global-set-key [f14] vcursor-map)
+;;      (keymap-global-set "<f14>" vcursor-map)
 ;; and also as usual \C-h in this map will list the key definitions, which
 ;; are designed to be easy to remember.
 ;;
diff --git a/lisp/woman.el b/lisp/woman.el
index ac2c9225527..c182afbf313 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -121,12 +121,11 @@
 ;; The variable `woman-use-topic-at-point' can be rebound locally,
 ;; which may be useful to provide special private key bindings, e.g.
 
-;;  (global-set-key "\C-cw"
-;;  		  (lambda ()
-;;  		    (interactive)
-;;  		    (let ((woman-use-topic-at-point t))
-;;  		      (woman)))))
-
+;; (keymap-global-set "C-c w"
+;;                    (lambda ()
+;;                      (interactive)
+;;                      (let ((woman-use-topic-at-point t))
+;;                        (woman)))))
 
 ;; Customization, Hooks and Imenu
 ;; ==============================