From 25d80e4f8115bc297ebe99bc698e8257bb0d29b3 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sat, 2 Jul 2022 12:25:03 +0200 Subject: [PATCH] Prefer defvar-keymap in nxml/*.el * lisp/nxml/nxml-mode.el (nxml-mode-map): * lisp/nxml/nxml-outln.el (nxml-outline-prefix-map) (nxml-outline-show-map, nxml-outline-hiding-tag-map) (nxml-outline-showing-tag-map): Prefer defvar-keymap. --- lisp/nxml/nxml-mode.el | 48 ++++++++++++++++++------------------ lisp/nxml/nxml-outln.el | 54 ++++++++++++++++++----------------------- 2 files changed, 46 insertions(+), 56 deletions(-) diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el index 171b7088c10..dfe5c369e2c 100644 --- a/lisp/nxml/nxml-mode.el +++ b/lisp/nxml/nxml-mode.el @@ -369,31 +369,29 @@ and, if `nxml-char-ref-display-glyph-flag' is non-nil, a glyph corresponding to the referenced character following the character reference.") -(defvar nxml-mode-map - (let ((map (make-sparse-keymap))) - (define-key map "\M-\C-u" 'nxml-backward-up-element) - (define-key map "\M-\C-d" 'nxml-down-element) - (define-key map "\M-\C-n" 'nxml-forward-element) - (define-key map "\M-\C-p" 'nxml-backward-element) - (define-key map "\M-{" 'nxml-backward-paragraph) - (define-key map "\M-}" 'nxml-forward-paragraph) - (define-key map "\M-h" 'nxml-mark-paragraph) - (define-key map "\C-c\C-f" 'nxml-finish-element) - (define-key map "\C-c]" 'nxml-finish-element) - (define-key map "\C-c/" 'nxml-finish-element) - (define-key map "\C-c\C-m" 'nxml-split-element) - (define-key map "\C-c\C-b" 'nxml-balanced-close-start-tag-block) - (define-key map "\C-c\C-i" 'nxml-balanced-close-start-tag-inline) - (define-key map "\C-c\C-x" 'nxml-insert-xml-declaration) - (define-key map "\C-c\C-d" 'nxml-dynamic-markup-word) - ;; u is for Unicode - (define-key map "\C-c\C-u" 'nxml-insert-named-char) - (define-key map "\C-c\C-o" nxml-outline-prefix-map) - (define-key map [S-mouse-2] 'nxml-mouse-hide-direct-text-content) - (define-key map "/" 'nxml-electric-slash) - (define-key map "\M-\t" 'completion-at-point) - map) - "Keymap for `nxml-mode'.") +(defvar-keymap nxml-mode-map + :doc "Keymap for `nxml-mode'." + "C-M-u" #'nxml-backward-up-element + "C-M-d" #'nxml-down-element + "C-M-n" #'nxml-forward-element + "C-M-p" #'nxml-backward-element + "M-{" #'nxml-backward-paragraph + "M-}" #'nxml-forward-paragraph + "M-h" #'nxml-mark-paragraph + "C-c C-f" #'nxml-finish-element + "C-c ]" #'nxml-finish-element + "C-c /" #'nxml-finish-element + "C-c C-m" #'nxml-split-element + "C-c C-b" #'nxml-balanced-close-start-tag-block + "C-c C-i" #'nxml-balanced-close-start-tag-inline + "C-c C-x" #'nxml-insert-xml-declaration + "C-c C-d" #'nxml-dynamic-markup-word + ;; u is for Unicode + "C-c C-u" #'nxml-insert-named-char + "C-c C-o" nxml-outline-prefix-map + "/" #'nxml-electric-slash + "M-TAB" #'completion-at-point + "S-" #'nxml-mouse-hide-direct-text-content) (defvar nxml-font-lock-keywords '(nxml-fontify-matcher) diff --git a/lisp/nxml/nxml-outln.el b/lisp/nxml/nxml-outln.el index 928338a6af9..1518122a79d 100644 --- a/lisp/nxml/nxml-outln.el +++ b/lisp/nxml/nxml-outln.el @@ -129,20 +129,18 @@ See the variable `nxml-section-element-name-regexp' for more details." (defvar nxml-heading-scan-distance 1000 "Maximum distance from section to scan for heading.") -(defvar nxml-outline-prefix-map - (let ((map (make-sparse-keymap))) - (define-key map "\C-a" 'nxml-show-all) - (define-key map "\C-t" 'nxml-hide-all-text-content) - (define-key map "\C-r" 'nxml-refresh-outline) - (define-key map "\C-c" 'nxml-hide-direct-text-content) - (define-key map "\C-e" 'nxml-show-direct-text-content) - (define-key map "\C-d" 'nxml-hide-subheadings) - (define-key map "\C-s" 'nxml-show) - (define-key map "\C-k" 'nxml-show-subheadings) - (define-key map "\C-l" 'nxml-hide-text-content) - (define-key map "\C-i" 'nxml-show-direct-subheadings) - (define-key map "\C-o" 'nxml-hide-other) - map)) +(defvar-keymap nxml-outline-prefix-map + "C-a" #'nxml-show-all + "C-t" #'nxml-hide-all-text-content + "C-r" #'nxml-refresh-outline + "C-c" #'nxml-hide-direct-text-content + "C-e" #'nxml-show-direct-text-content + "C-d" #'nxml-hide-subheadings + "C-s" #'nxml-show + "C-k" #'nxml-show-subheadings + "C-l" #'nxml-hide-text-content + "C-i" #'nxml-show-direct-subheadings + "C-o" #'nxml-hide-other) ;;; Commands for changing visibility @@ -693,11 +691,9 @@ non-transparent child section." (nxml-highlighted-qname (xmltok-end-tag-qname)) nxml-highlighted-greater-than)))) -(defvar nxml-outline-show-map - (let ((map (make-sparse-keymap))) - (define-key map "\C-m" 'nxml-show-direct-text-content) - (define-key map [mouse-2] 'nxml-mouse-show-direct-text-content) - map)) +(defvar-keymap nxml-outline-show-map + "RET" #'nxml-show-direct-text-content + "" #'nxml-mouse-show-direct-text-content) (defvar nxml-outline-show-help "mouse-2: show") @@ -724,12 +720,10 @@ non-transparent child section." (put 'nxml-outline-display-heading 'evaporate t) (put 'nxml-outline-display-heading 'face 'nxml-heading) -(defvar nxml-outline-hiding-tag-map - (let ((map (make-sparse-keymap))) - (define-key map [mouse-1] 'nxml-mouse-show-direct-subheadings) - (define-key map [mouse-2] 'nxml-mouse-show-direct-text-content) - (define-key map "\C-m" 'nxml-show-direct-text-content) - map)) +(defvar-keymap nxml-outline-hiding-tag-map + "" #'nxml-mouse-show-direct-subheadings + "" #'nxml-mouse-show-direct-text-content + "RET" #'nxml-show-direct-text-content) (defvar nxml-outline-hiding-tag-help "mouse-1: show subheadings, mouse-2: show text content") @@ -739,12 +733,10 @@ non-transparent child section." (put 'nxml-outline-display-hiding-tag 'keymap nxml-outline-hiding-tag-map) (put 'nxml-outline-display-hiding-tag 'help-echo nxml-outline-hiding-tag-help) -(defvar nxml-outline-showing-tag-map - (let ((map (make-sparse-keymap))) - (define-key map [mouse-1] 'nxml-mouse-hide-subheadings) - (define-key map [mouse-2] 'nxml-mouse-show-direct-text-content) - (define-key map "\C-m" 'nxml-show-direct-text-content) - map)) +(defvar-keymap nxml-outline-showing-tag-map + "" #'nxml-mouse-hide-subheadings + "" #'nxml-mouse-show-direct-text-content + "RET" #'nxml-show-direct-text-content) (defvar nxml-outline-showing-tag-help "mouse-1: hide subheadings, mouse-2: show text content") -- 2.39.2