From 7d74b8f632b1af75b837f5b5259cd1758aab1489 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Tue, 17 May 2022 17:25:27 +0200 Subject: [PATCH] Prefer defvar-keymap in some progmodes * lisp/progmodes/asm-mode.el (asm-mode-map): * lisp/progmodes/bug-reference.el (bug-reference-map): * lisp/progmodes/erts-mode.el (erts-mode-map): * lisp/progmodes/flymake.el (flymake-mode-map) (flymake-diagnostics-buffer-mode-map): * lisp/progmodes/icon.el (icon-mode-map): * lisp/progmodes/js.el (js-mode-map): * lisp/progmodes/m4-mode.el (m4-mode-map): * lisp/progmodes/mixal-mode.el (mixal-mode-map): * lisp/progmodes/scheme.el (scheme-mode-map): Prefer defvar-keymap. --- lisp/progmodes/asm-mode.el | 12 +++++------- lisp/progmodes/bug-reference.el | 10 ++++------ lisp/progmodes/erts-mode.el | 10 ++++------ lisp/progmodes/flymake.el | 13 +++++-------- lisp/progmodes/icon.el | 21 ++++++++++----------- lisp/progmodes/js.el | 10 ++++------ lisp/progmodes/m4-mode.el | 12 +++++------- lisp/progmodes/mixal-mode.el | 17 +++++++---------- lisp/progmodes/scheme.el | 13 +++++-------- 9 files changed, 49 insertions(+), 69 deletions(-) diff --git a/lisp/progmodes/asm-mode.el b/lisp/progmodes/asm-mode.el index 370fb1b80b4..05c3fc72966 100644 --- a/lisp/progmodes/asm-mode.el +++ b/lisp/progmodes/asm-mode.el @@ -68,13 +68,11 @@ "Abbrev table used while in Asm mode.") (define-abbrev-table 'asm-mode-abbrev-table ()) -(defvar asm-mode-map - (let ((map (make-sparse-keymap))) - ;; Note that the comment character isn't set up until asm-mode is called. - (define-key map ":" 'asm-colon) - (define-key map "\C-c;" 'comment-region) - map) - "Keymap for Asm mode.") +(defvar-keymap asm-mode-map + :doc "Keymap for Asm mode." + ;; Note that the comment character isn't set up until asm-mode is called. + ":" #'asm-colon + "C-c ;" #'comment-region) (easy-menu-define asm-mode-menu asm-mode-map "Menu for Asm mode." diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el index 06242a4cba8..d3626dbaf01 100644 --- a/lisp/progmodes/bug-reference.el +++ b/lisp/progmodes/bug-reference.el @@ -40,12 +40,10 @@ ;; Somewhat arbitrary, by analogy with eg goto-address. :group 'comm) -(defvar bug-reference-map - (let ((map (make-sparse-keymap))) - (define-key map [mouse-2] 'bug-reference-push-button) - (define-key map (kbd "C-c RET") 'bug-reference-push-button) - map) - "Keymap used by bug reference buttons.") +(defvar-keymap bug-reference-map + :doc "Keymap used by bug reference buttons." + "" #'bug-reference-push-button + "C-c RET" #'bug-reference-push-button) ;; E.g., "https://gcc.gnu.org/PR%s" (defvar bug-reference-url-format nil diff --git a/lisp/progmodes/erts-mode.el b/lisp/progmodes/erts-mode.el index 1b88540ff38..13da1d478d6 100644 --- a/lisp/progmodes/erts-mode.el +++ b/lisp/progmodes/erts-mode.el @@ -64,12 +64,10 @@ "Face used for displaying specification test start markers." :group 'erts-mode) -(defvar erts-mode-map - (let ((map (make-keymap))) - (set-keymap-parent map prog-mode-map) - (define-key map "\C-c\C-r" 'erts-tag-region) - (define-key map "\C-c\C-c" 'erts-run-test) - map)) +(defvar-keymap erts-mode-map + :parent prog-mode-map + "C-c C-r" #'erts-tag-region + "C-c C-c" #'erts-run-test) (defvar erts-mode-font-lock-keywords ;; Specifications. diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 0b7958e52fb..9e3255874da 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -1080,9 +1080,8 @@ Interactively, with a prefix arg, FORCE is t." (flymake--run-backend backend backend-args))) nil)))))))) -(defvar flymake-mode-map - (let ((map (make-sparse-keymap))) map) - "Keymap for `flymake-mode'.") +(defvar-keymap flymake-mode-map + :doc "Keymap for `flymake-mode'.") ;;;###autoload (define-minor-mode flymake-mode @@ -1493,11 +1492,9 @@ TYPE is usually keyword `:error', `:warning' or `:note'." (defvar-local flymake--diagnostics-buffer-source nil) -(defvar flymake-diagnostics-buffer-mode-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "RET") 'flymake-goto-diagnostic) - (define-key map (kbd "SPC") 'flymake-show-diagnostic) - map)) +(defvar-keymap flymake-diagnostics-buffer-mode-map + "RET" #'flymake-goto-diagnostic + "SPC" #'flymake-show-diagnostic) (defun flymake-show-diagnostic (pos &optional other-window) "Show location of diagnostic at POS." diff --git a/lisp/progmodes/icon.el b/lisp/progmodes/icon.el index e1ee9efc54b..ec281f3a496 100644 --- a/lisp/progmodes/icon.el +++ b/lisp/progmodes/icon.el @@ -31,17 +31,16 @@ "Abbrev table in use in Icon-mode buffers.") (define-abbrev-table 'icon-mode-abbrev-table ()) -(defvar icon-mode-map - (let ((map (make-sparse-keymap "Icon"))) - (define-key map "{" 'electric-icon-brace) - (define-key map "}" 'electric-icon-brace) - (define-key map "\e\C-h" 'mark-icon-function) - (define-key map "\e\C-a" 'beginning-of-icon-defun) - (define-key map "\e\C-e" 'end-of-icon-defun) - (define-key map "\e\C-q" 'indent-icon-exp) - (define-key map "\177" 'backward-delete-char-untabify) - map) - "Keymap used in Icon mode.") +(defvar-keymap icon-mode-map + :doc "Keymap used in Icon mode." + :name "Icon" + "{" #'electric-icon-brace + "}" #'electric-icon-brace + "C-M-h" #'mark-icon-function + "C-M-a" #'beginning-of-icon-defun + "C-M-e" #'end-of-icon-defun + "C-M-q" #'indent-icon-exp + "DEL" #'backward-delete-char-untabify) (easy-menu-define icon-mode-menu icon-mode-map "Menu for Icon mode." diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 9c1358e466d..eb2a1e4fccc 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -660,13 +660,11 @@ This variable is like `sgml-attribute-offset'." :type 'integer :safe 'integerp) -;;; KeyMap +;;; Keymap -(defvar js-mode-map - (let ((keymap (make-sparse-keymap))) - (define-key keymap [(meta ?.)] #'js-find-symbol) - keymap) - "Keymap for `js-mode'.") +(defvar-keymap js-mode-map + :doc "Keymap for `js-mode'." + "M-." #'js-find-symbol) ;;; Syntax table and parsing diff --git a/lisp/progmodes/m4-mode.el b/lisp/progmodes/m4-mode.el index b9fcd033bbb..a18c8bcce44 100644 --- a/lisp/progmodes/m4-mode.el +++ b/lisp/progmodes/m4-mode.el @@ -121,13 +121,11 @@ If m4 is not in your PATH, set this to an absolute file name." ("#" (0 (when (m4--quoted-p (match-beginning 0)) (string-to-syntax ".")))))) -(defvar m4-mode-map - (let ((map (make-sparse-keymap))) - (define-key map "\C-c\C-b" 'm4-m4-buffer) - (define-key map "\C-c\C-r" 'm4-m4-region) - (define-key map "\C-c\C-c" 'comment-region) - map) - "Keymap for M4 Mode.") +(defvar-keymap m4-mode-map + :doc "Keymap for M4 Mode." + "C-c C-b" #'m4-m4-buffer + "C-c C-r" #'m4-m4-region + "C-c C-c" #'comment-region) (easy-menu-define m4-mode-menu m4-mode-map "Menu for M4 Mode." diff --git a/lisp/progmodes/mixal-mode.el b/lisp/progmodes/mixal-mode.el index 97a218fcfa3..9d1ceaa55a8 100644 --- a/lisp/progmodes/mixal-mode.el +++ b/lisp/progmodes/mixal-mode.el @@ -78,16 +78,13 @@ ;;; Code: (defvar compile-command) -;;; Key map -(defvar mixal-mode-map - (let ((map (make-sparse-keymap))) - (define-key map "\C-c\C-c" 'compile) - (define-key map "\C-c\C-r" 'mixal-run) - (define-key map "\C-c\C-d" 'mixal-debug) - (define-key map "\C-h\C-o" 'mixal-describe-operation-code) - map) - "Keymap for `mixal-mode'.") -;; (makunbound 'mixal-mode-map) +;;; Keymap +(defvar-keymap mixal-mode-map + :doc "Keymap for `mixal-mode'." + "C-c C-c" #'compile + "C-c C-r" #'mixal-run + "C-c C-d" #'mixal-debug + "C-h C-o" #'mixal-describe-operation-code) ;;; Syntax table (defvar mixal-mode-syntax-table diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el index cd397733d2d..cf1d3949835 100644 --- a/lisp/progmodes/scheme.el +++ b/lisp/progmodes/scheme.el @@ -1,7 +1,6 @@ ;;; scheme.el --- Scheme (and DSSSL) editing mode -*- lexical-binding: t; -*- -;; Copyright (C) 1986-1988, 1997-1998, 2001-2022 Free Software -;; Foundation, Inc. +;; Copyright (C) 1986-2022 Free Software Foundation, Inc. ;; Author: Bill Rozas ;; Adapted-by: Dave Love @@ -201,12 +200,10 @@ (defvar scheme-mode-line-process "") -(defvar scheme-mode-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map lisp-mode-shared-map) - map) - "Keymap for Scheme mode. -All commands in `lisp-mode-shared-map' are inherited by this map.") +(defvar-keymap scheme-mode-map + :doc "Keymap for Scheme mode. +All commands in `lisp-mode-shared-map' are inherited by this map." + :parent lisp-mode-shared-map) (easy-menu-define scheme-mode-menu scheme-mode-map "Menu for Scheme mode." -- 2.39.2