]> git.eshelyaron.com Git - emacs.git/commitdiff
Convert some more progmode menus to easy-menu-define
authorStefan Kangas <stefan@marxist.se>
Fri, 26 Feb 2021 15:23:45 +0000 (16:23 +0100)
committerStefan Kangas <stefan@marxist.se>
Fri, 26 Feb 2021 15:51:19 +0000 (16:51 +0100)
* 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
lisp/progmodes/icon.el
lisp/progmodes/scheme.el

index 4a8a20a29693f2713c972db49ebc2d43ed2e588c..6ffceb444c1209eb115c35d9b229d37e2cc35fce 100644 (file)
@@ -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.
index a36f020439d5aebc42fae6e93d1c5375ded1a168..d81fe1c753bb0e053ee0020bd68ccf18a5eeb9d2 100644 (file)
   "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."
index a899de7e594bfff8b9e40bb94fbe2b458b4bf4e6..72ac2d95a2188388812972b36384cffa82852969 100644 (file)
 (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