@@ -625,6 +625,8 @@ These are set by `gnuplot--set-keywords-list' from the values in
625625; ;; --- key bindings and menus
626626
627627(defvar-keymap gnuplot-mode-map
628+ :doc " Keymap used by `gnuplot-mode' ."
629+ :parent prog-mode-map
628630 " C-c C-b" #'gnuplot-send-buffer-to-gnuplot
629631 " C-c C-o" #'gnuplot-gui-set-options-and-insert
630632 " C-c C-e" #'gnuplot-show-comint-buffer
@@ -643,8 +645,6 @@ These are set by `gnuplot--set-keywords-list' from the values in
643645 " M-TAB" #'completion-at-point
644646 " S-<mouse-2>" #'gnuplot-gui-set-options-and-insert )
645647
646- (defvar gnuplot-mode-menu nil )
647-
648648(defvar gnuplot--display-options-menu
649649 (cl-flet ((make-image-setter (type)
650650 `[,(concat (upcase type) " images" )
@@ -666,7 +666,8 @@ These are set by `gnuplot--set-keywords-list' from the values in
666666 ,@(mapcar #'make-image-setter (list " png" " jpeg" " svg" ))
667667 [" Other image type..." gnuplot-set-image-format])))
668668
669- (defvar gnuplot--menu
669+ (easy-menu-define gnuplot-mode-menu gnuplot-mode-map
670+ " Menu used in `gnuplot-mode' ."
670671 `(" Gnuplot"
671672 [" Send line to gnuplot" gnuplot-send-line-to-gnuplot t]
672673 [" Send line & move forward" gnuplot-send-line-and-forward (not (eobp ))]
@@ -698,8 +699,7 @@ These are set by `gnuplot--set-keywords-list' from the values in
698699 " ---"
699700 [" Customize gnuplot" gnuplot-customize t]
700701 " ---"
701- [" Kill gnuplot" gnuplot-kill-comint-buffer t])
702- " Menu for `gnuplot-mode' ." )
702+ [" Kill gnuplot" gnuplot-kill-comint-buffer t]))
703703
704704
705705; ;; --- syntax colorization, syntax table
@@ -1156,8 +1156,22 @@ this function is attached to `gnuplot-after-plot-hook'"
11561156
11571157; ;; --- functions controlling the gnuplot process
11581158
1159- ; ; Menu for the comint-mode buffer
1160- (defvar gnuplot--comint-menu
1159+ (defvar-keymap gnuplot-comint-mode-map
1160+ :doc " Keymap used by `gnuplot-comint-mode' ."
1161+ :parent comint-mode-map
1162+ " C-M-p" #'gnuplot-plot-from-comint
1163+ " C-M-f" #'gnuplot-save-and-plot-from-comint
1164+ " C-d" #'gnuplot-delchar-or-maybe-eof
1165+ " M-TAB" #'completion-at-point
1166+ " C-c C-d" #'gnuplot-info-lookup-symbol
1167+ " C-c C-i" #'gnuplot-insert-filename
1168+ " C-c C-n" #'gnuplot-negate-option
1169+ " C-c C-z" #'gnuplot-customize
1170+ " C-c C-e" #'gnuplot-pop-to-recent-buffer )
1171+
1172+ (easy-menu-define
1173+ gnuplot-comint-mode-menu gnuplot-comint-mode-map
1174+ " Menu used in `gnuplot-comint-mode' ."
11611175 `(" Gnuplot"
11621176 [" Plot most recent gnuplot buffer" gnuplot-plot-from-comint
11631177 (buffer-live-p gnuplot--comint-recent-buffer)]
@@ -1209,27 +1223,7 @@ buffer."
12091223 (add-hook 'comint-output-filter-functions
12101224 #'gnuplot--protect-prompt-fn
12111225 nil t )
1212- (add-hook 'completion-at-point-functions #'gnuplot-completion-at-point-info-look nil t )
1213-
1214- ; ; Set up menu (see below)
1215- (easy-menu-define
1216- gnuplot-comint-mode-menu gnuplot-comint-mode-map " Menu used in gnuplot-comint-mode"
1217- gnuplot--comint-menu))
1218-
1219- ; ; Key bindings for gnuplot-comint-mode
1220- (define-key gnuplot-comint-mode-map " \M -\C -p" #'gnuplot-plot-from-comint )
1221- (define-key gnuplot-comint-mode-map " \M -\C -f" #'gnuplot-save-and-plot-from-comint )
1222- (define-key gnuplot-comint-mode-map " \C -d" #'gnuplot-delchar-or-maybe-eof )
1223- (define-key gnuplot-comint-mode-map " \M -\t " #'completion-at-point )
1224- (define-key gnuplot-comint-mode-map " \C -c\C -d" #'gnuplot-info-lookup-symbol )
1225- (define-key gnuplot-comint-mode-map " \C -c\C -i" #'gnuplot-insert-filename )
1226- (define-key gnuplot-comint-mode-map " \C -c\C -n" #'gnuplot-negate-option )
1227- (define-key gnuplot-comint-mode-map " \C -c\C -z" #'gnuplot-customize )
1228- (define-key gnuplot-comint-mode-map " \C -c\C -e" #'gnuplot-pop-to-recent-buffer )
1229-
1230- ; ; Menu for gnuplot-comint-mode
1231- (defvar gnuplot-comint-mode-menu nil
1232- " Menu for `gnuplot-comint-mode' ." )
1226+ (add-hook 'completion-at-point-functions #'gnuplot-completion-at-point-info-look nil t ))
12331227
12341228(defun gnuplot--make-comint-buffer ()
12351229 " Switch to the gnuplot program buffer or create one if none exists."
@@ -1779,29 +1773,25 @@ shown."
17791773 " Help will be displayed after insertions."
17801774 " Help no longer displayed after insertions." )))
17811775
1782- (defun gnuplot--setup-menubar ()
1783- " Initial setup of gnuplot and insertions menus."
1784- (unless gnuplot-mode-menu
1785- (when gnuplot-insertions-menu-flag
1786- (easy-menu-define gnuplot--insertions-menu gnuplot-mode-map
1787- " Insertions menu used in Gnuplot-mode"
1788- `(" Insertions"
1789- ,@gnuplot-insertions-top
1790- , gnuplot-insertions-adornments
1791- , gnuplot-insertions-plot-options
1792- , gnuplot-insertions-terminal
1793- , gnuplot-insertions-x-axis
1794- , gnuplot-insertions-y-axis
1795- , gnuplot-insertions-z-axis
1796- , gnuplot-insertions-x2-axis
1797- , gnuplot-insertions-y2-axis
1798- , gnuplot-insertions-parametric-plots
1799- , gnuplot-insertions-polar-plots
1800- , gnuplot-insertions-surface-plots
1801- ,@gnuplot-insertions-bottom )))
1802- (easy-menu-define ; set up gnuplot menu
1803- gnuplot-mode-menu gnuplot-mode-map " Menu used in gnuplot-mode"
1804- gnuplot--menu)))
1776+ (defun gnuplot--setup-insertions-menu ()
1777+ " Initial setup of insertions menu."
1778+ (when (and gnuplot-insertions-menu-flag (not gnuplot--insertions-menu))
1779+ (easy-menu-define gnuplot--insertions-menu gnuplot-mode-map
1780+ " Insertions menu used in Gnuplot-mode"
1781+ `(" Insertions"
1782+ ,@gnuplot-insertions-top
1783+ , gnuplot-insertions-adornments
1784+ , gnuplot-insertions-plot-options
1785+ , gnuplot-insertions-terminal
1786+ , gnuplot-insertions-x-axis
1787+ , gnuplot-insertions-y-axis
1788+ , gnuplot-insertions-z-axis
1789+ , gnuplot-insertions-x2-axis
1790+ , gnuplot-insertions-y2-axis
1791+ , gnuplot-insertions-parametric-plots
1792+ , gnuplot-insertions-polar-plots
1793+ , gnuplot-insertions-surface-plots
1794+ ,@gnuplot-insertions-bottom ))))
18051795
18061796(defun gnuplot--mark-active ()
18071797 " Return non-nil if the mark is active and it is not equal to point."
@@ -1866,7 +1856,7 @@ a list:
18661856 (add-hook 'syntax-propertize-extend-region-functions
18671857 #'gnuplot--syntax-propertize-extend-region nil t )
18681858 (setq gnuplot--comint-recent-buffer (current-buffer ))
1869- (gnuplot--setup-menubar ))
1859+ (gnuplot--setup-insertions-menu ))
18701860
18711861;;;### autoload
18721862(defun gnuplot-make-buffer ()
0 commit comments