From ffdb0a2d8e64980d63b7c1c6c71ac6e2d26b4fb2 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 26 Feb 2021 16:23:45 +0100 Subject: [PATCH] Convert some more progmode menus to easy-menu-define * lisp/progmodes/dcl-mode.el (dcl-mode-map): * lisp/progmodes/icon.el (icon-mode-map): * lisp/progmodes/scheme.el (scheme-mode-map): Move menu definitions from here... * lisp/progmodes/dcl-mode.el (dcl-mode-menu): * lisp/progmodes/icon.el (icon-mode-menu) * lisp/progmodes/scheme.el (scheme-mode-menu): ...to here, and use easy-menu-define. * lisp/progmodes/icon.el (icon-mode-map, icon-mode-syntax-table): Simplify. --- lisp/progmodes/dcl-mode.el | 61 ++++++++++----------------- lisp/progmodes/icon.el | 85 ++++++++++++++++++-------------------- lisp/progmodes/scheme.el | 33 ++++++++------- 3 files changed, 78 insertions(+), 101 deletions(-) diff --git a/lisp/progmodes/dcl-mode.el b/lisp/progmodes/dcl-mode.el index 4a8a20a2969..6ffceb444c1 100644 --- a/lisp/progmodes/dcl-mode.el +++ b/lisp/progmodes/dcl-mode.el @@ -286,49 +286,30 @@ See `imenu-generic-expression' for details." (define-key map "\C-c\C-o" 'dcl-set-option) (define-key map "\C-c\C-f" 'tempo-forward-mark) (define-key map "\C-c\C-b" 'tempo-backward-mark) - - (define-key map [menu-bar] (make-sparse-keymap)) - (define-key map [menu-bar dcl] - (cons "DCL" (make-sparse-keymap "DCL"))) - - ;; Define these in bottom-up order - (define-key map [menu-bar dcl tempo-backward-mark] - '("Previous template mark" . tempo-backward-mark)) - (define-key map [menu-bar dcl tempo-forward-mark] - '("Next template mark" . tempo-forward-mark)) - (define-key map [menu-bar dcl tempo-complete-tag] - '("Complete template tag" . tempo-complete-tag)) - (define-key map [menu-bar dcl dcl-separator-tempo] - '("--")) - (define-key map [menu-bar dcl dcl-save-all-options] - '("Save all options" . dcl-save-all-options)) - (define-key map [menu-bar dcl dcl-save-nondefault-options] - '("Save changed options" . dcl-save-nondefault-options)) - (define-key map [menu-bar dcl dcl-set-option] - '("Set option" . dcl-set-option)) - (define-key map [menu-bar dcl dcl-separator-option] - '("--")) - (define-key map [menu-bar dcl dcl-delete-indentation] - '("Delete indentation" . dcl-delete-indentation)) - (define-key map [menu-bar dcl dcl-split-line] - '("Split line" . dcl-split-line)) - (define-key map [menu-bar dcl dcl-indent-command] - '("Indent command" . dcl-indent-command)) - (define-key map [menu-bar dcl dcl-tab] - '("Indent line/insert tab" . dcl-tab)) - (define-key map [menu-bar dcl dcl-back-to-indentation] - '("Back to indentation" . dcl-back-to-indentation)) - (define-key map [menu-bar dcl dcl-forward-command] - '("End of statement" . dcl-forward-command)) - (define-key map [menu-bar dcl dcl-backward-command] - '("Beginning of statement" . dcl-backward-command)) - (define-key map [menu-bar dcl dcl-separator-movement] - '("--")) - (define-key map [menu-bar dcl imenu] - '("Buffer index menu" . imenu)) map) "Keymap used in DCL-mode buffers.") +(easy-menu-define dcl-mode-menu dcl-mode-map + "Menu for DCL-mode buffers." + '("DCL" + ["Buffer index menu" imenu] + "---" + ["Beginning of statement" dcl-backward-command] + ["End of statement" dcl-forward-command] + ["Back to indentation" dcl-back-to-indentation] + ["Indent line/insert tab" dcl-tab] + ["Indent command" dcl-indent-command] + ["Split line" dcl-split-line] + ["Delete indentation" dcl-delete-indentation] + "---" + ["Set option" dcl-set-option] + ["Save changed options" dcl-save-nondefault-options] + ["Save all options" dcl-save-all-options] + "---" + ["Complete template tag" tempo-complete-tag] + ["Next template mark" tempo-forward-mark] + ["Previous template mark" tempo-backward-mark])) + (defcustom dcl-ws-r "\\([ \t]*-[ \t]*\\(!.*\\)*\n\\)*[ \t]*" "Regular expression describing white space in a DCL command line. diff --git a/lisp/progmodes/icon.el b/lisp/progmodes/icon.el index a36f020439d..d81fe1c753b 100644 --- a/lisp/progmodes/icon.el +++ b/lisp/progmodes/icon.el @@ -31,53 +31,48 @@ "Abbrev table in use in Icon-mode buffers.") (define-abbrev-table 'icon-mode-abbrev-table ()) -(defvar icon-mode-map () - "Keymap used in Icon mode.") -(if icon-mode-map - () +(defvar icon-mode-map (let ((map (make-sparse-keymap "Icon"))) - (setq icon-mode-map (make-sparse-keymap)) - (define-key icon-mode-map "{" 'electric-icon-brace) - (define-key icon-mode-map "}" 'electric-icon-brace) - (define-key icon-mode-map "\e\C-h" 'mark-icon-function) - (define-key icon-mode-map "\e\C-a" 'beginning-of-icon-defun) - (define-key icon-mode-map "\e\C-e" 'end-of-icon-defun) - (define-key icon-mode-map "\e\C-q" 'indent-icon-exp) - (define-key icon-mode-map "\177" 'backward-delete-char-untabify) - - (define-key icon-mode-map [menu-bar] (make-sparse-keymap "Icon")) - (define-key icon-mode-map [menu-bar icon] - (cons "Icon" map)) - (define-key map [beginning-of-icon-defun] '("Beginning of function" . beginning-of-icon-defun)) - (define-key map [end-of-icon-defun] '("End of function" . end-of-icon-defun)) - (define-key map [comment-region] '("Comment Out Region" . comment-region)) - (define-key map [indent-region] '("Indent Region" . indent-region)) - (define-key map [indent-line] '("Indent Line" . icon-indent-command)) - (put 'eval-region 'menu-enable 'mark-active) - (put 'comment-region 'menu-enable 'mark-active) - (put 'indent-region 'menu-enable 'mark-active))) - -(defvar icon-mode-syntax-table nil - "Syntax table in use in Icon-mode buffers.") + (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.") -(if icon-mode-syntax-table - () - (setq icon-mode-syntax-table (make-syntax-table)) - (modify-syntax-entry ?\\ "\\" icon-mode-syntax-table) - (modify-syntax-entry ?# "<" icon-mode-syntax-table) - (modify-syntax-entry ?\n ">" icon-mode-syntax-table) - (modify-syntax-entry ?$ "." icon-mode-syntax-table) - (modify-syntax-entry ?/ "." icon-mode-syntax-table) - (modify-syntax-entry ?* "." icon-mode-syntax-table) - (modify-syntax-entry ?+ "." icon-mode-syntax-table) - (modify-syntax-entry ?- "." icon-mode-syntax-table) - (modify-syntax-entry ?= "." icon-mode-syntax-table) - (modify-syntax-entry ?% "." icon-mode-syntax-table) - (modify-syntax-entry ?< "." icon-mode-syntax-table) - (modify-syntax-entry ?> "." icon-mode-syntax-table) - (modify-syntax-entry ?& "." icon-mode-syntax-table) - (modify-syntax-entry ?| "." icon-mode-syntax-table) - (modify-syntax-entry ?\' "\"" icon-mode-syntax-table)) +(easy-menu-define icon-mode-menu icon-mode-map + "Menu for Icon mode." + '("Icon" + ["Beginning of function" beginning-of-icon-defun] + ["Comment Out Region" comment-region + :enable mark-active] + ["End of function" end-of-icon-defun] + ["Indent Line" icon-indent-command] + ["Indent Region" indent-region + :enable mark-active])) + +(defvar icon-mode-syntax-table + (let ((table (make-syntax-table))) + (modify-syntax-entry ?\\ "\\" table) + (modify-syntax-entry ?# "<" table) + (modify-syntax-entry ?\n ">" table) + (modify-syntax-entry ?$ "." table) + (modify-syntax-entry ?/ "." table) + (modify-syntax-entry ?* "." table) + (modify-syntax-entry ?+ "." table) + (modify-syntax-entry ?- "." table) + (modify-syntax-entry ?= "." table) + (modify-syntax-entry ?% "." table) + (modify-syntax-entry ?< "." table) + (modify-syntax-entry ?> "." table) + (modify-syntax-entry ?& "." table) + (modify-syntax-entry ?| "." table) + (modify-syntax-entry ?\' "\"" table) + table) + "Syntax table in use in Icon-mode buffers.") (defgroup icon nil "Mode for editing Icon code." diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el index a899de7e594..72ac2d95a21 100644 --- a/lisp/progmodes/scheme.el +++ b/lisp/progmodes/scheme.el @@ -162,25 +162,26 @@ (defvar scheme-mode-line-process "") (defvar scheme-mode-map - (let ((smap (make-sparse-keymap)) - (map (make-sparse-keymap "Scheme"))) - (set-keymap-parent smap lisp-mode-shared-map) - (define-key smap [menu-bar scheme] (cons "Scheme" map)) - (define-key map [run-scheme] '("Run Inferior Scheme" . run-scheme)) - (define-key map [uncomment-region] - '("Uncomment Out Region" . (lambda (beg end) - (interactive "r") - (comment-region beg end '(4))))) - (define-key map [comment-region] '("Comment Out Region" . comment-region)) - (define-key map [indent-region] '("Indent Region" . indent-region)) - (define-key map [indent-line] '("Indent Line" . lisp-indent-line)) - (put 'comment-region 'menu-enable 'mark-active) - (put 'uncomment-region 'menu-enable 'mark-active) - (put 'indent-region 'menu-enable 'mark-active) - smap) + (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.") +(easy-menu-define scheme-mode-menu scheme-mode-map + "Menu for Scheme mode." + '("Scheme" + ["Indent Line" lisp-indent-line] + ["Indent Region" indent-region + :enable mark-active] + ["Comment Out Region" comment-region + :enable mark-active] + ["Uncomment Out Region" (lambda (beg end) + (interactive "r") + (comment-region beg end '(4))) + :enable mark-active] + ["Run Inferior Scheme" run-scheme])) + ;; Used by cmuscheme (defun scheme-mode-commands (map) ;;(define-key map "\t" 'indent-for-tab-command) ; default -- 2.39.2