branch: elpa/gnuplot
commit 517f051d819e9123af549acf555c5bfd9989c88a
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Daniel Mendler <m...@daniel-mendler.de>

    Various major mode improvements
    
    Patch by Stefan Monnier
---
 .gitignore     |  13 ++---
 gnuplot-gui.el | 160 ++++++++++++++++++++++++++++-----------------------------
 gnuplot.el     |  17 +++---
 3 files changed, 93 insertions(+), 97 deletions(-)

diff --git a/.gitignore b/.gitignore
index f137194cf3..4875bb47c8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,14 +1,15 @@
-/.cask
+*.aux
+*.dvi
 *.elc
 *.log
-*.aux
 *.pdf
-*.dvi
+*/#*#
 *~
+.#*
 /#*#
-*/#*#
+/*-autoloads.el
+/*-pkg.el
+/gpelcard.ps
 /hacks.el
-.#*
 /info-look.el
-/gpelcard.ps
 gnuplot-mode-*.tar.gz
diff --git a/gnuplot-gui.el b/gnuplot-gui.el
index ebcb754d6e..100df67194 100644
--- a/gnuplot-gui.el
+++ b/gnuplot-gui.el
@@ -828,15 +828,8 @@ This alist is formed at load time by appending together
 ;;; user interface to the widget-y stuff
 
 ;;;###autoload
-(defun gnuplot-gui-mouse-set (event)
-  "Use the mouse to begin setting options using a GUI interface.
-EVENT is a mouse event.  Bound to \\[gnuplot-gui-mouse-set]
-Note that \"plot\", \"splot\", \"fit\", and \"cntrparam\" are not
-currently supported."
-  (interactive "@e")
-  (save-excursion
-    (mouse-set-point event)
-    (gnuplot-gui-set-options-and-insert)))
+(define-obsolete-function-alias 'gnuplot-gui-mouse-set
+  #'gnuplot-gui-set-options-and-insert "2025")
 
 (defun gnuplot-gui-get-frame-param (param)
   (cdr (assoc param gnuplot-gui-frame-parameters)))
@@ -845,86 +838,89 @@ currently supported."
   (setcdr (assoc param gnuplot-gui-frame-parameters) value))
 
 ;;;###autoload
-(defun gnuplot-gui-set-options-and-insert ()
+(defun gnuplot-gui-set-options-and-insert (&optional event)
   "Insert arguments using a GUI interface.
 Determine contents of current line and set up the appropriate GUI
 frame.  Bound to \\[gnuplot-gui-set-options-and-insert]
 Note that \"cntrparam\" is not currently supported."
   (interactive)
-  (let ((begin  (gnuplot-point-at-beginning-of-command))
-        (end    (save-excursion (end-of-line)       (point-marker)))
-        (termin (concat "\\(,\\s-*" (regexp-quote "\\") "\\|;\\)"))
-        (set nil) (term nil))
-    (save-excursion
-      ;; there can be more then one command per line
-      (if (re-search-forward termin end "to_limit")
-          (progn (backward-char (length (match-string 1)))
-                 (setq end (point-marker))))
-      (goto-char begin)
-      (skip-syntax-forward "-" end)
-      ;; various constructions are recognized here. at the end of this
-      ;; cond, point should be just after the word whose arguments are
-      ;; to be set
-      (cond ((looking-at "set\\s-+")
-             (setq set t)
-             (goto-char (match-end 0))
-             (if (looking-at "\\sw+") (goto-char (match-end 0)))
-             (when (string-match "^ter" (gnuplot-this-word)) ; terminal?
-               (setq term t)
+  (interactive (list last-nonmenu-event))
+  (save-excursion
+    (if event (mouse-set-point event))
+    (let ((begin  (gnuplot-point-at-beginning-of-command))
+          (end    (save-excursion (end-of-line)       (point-marker)))
+          (termin (concat "\\(,\\s-*" (regexp-quote "\\") "\\|;\\)"))
+          (set nil) (term nil))
+      (save-excursion
+        ;; there can be more then one command per line
+        (if (re-search-forward termin end "to_limit")
+            (progn (backward-char (length (match-string 1)))
+                   (setq end (point-marker))))
+        (goto-char begin)
+        (skip-syntax-forward "-" end)
+        ;; various constructions are recognized here. at the end of this
+        ;; cond, point should be just after the word whose arguments are
+        ;; to be set
+        (cond ((looking-at "set\\s-+")
+               (setq set t)
+               (goto-char (match-end 0))
+               (if (looking-at "\\sw+") (goto-char (match-end 0)))
+               (when (string-match "^ter" (gnuplot-this-word)) ; terminal?
+                 (setq term t)
+                 (forward-word 1))
+               (when (string-match "^\\(da\\|fu\\)" (gnuplot-this-word))
+                 (unless (looking-at "\\s-+st")
+                   (insert " style") (forward-word 1))
+                 (forward-word 1)))
+              ((looking-at (concat "\\(cd\\|ca\\|lo\\|pa\\|pr\\|sa\\|u\\)"
+                                   "\\w*"
+                                   "[\\s-\\']"))
                (forward-word 1))
-             (when (string-match "^\\(da\\|fu\\)" (gnuplot-this-word))
-               (unless (looking-at "\\s-+st")
-                 (insert " style") (forward-word 1))
-               (forward-word 1)))
-            ((looking-at (concat "\\(cd\\|ca\\|lo\\|pa\\|pr\\|sa\\|u\\)"
-                                 "\\w*"
-                                 "[\\s-\\']"))
-             (forward-word 1))
-            ;;(goto-char (match-end 0)))
-            (t
-             (forward-word 1)))
-      (if (> (point) end) (goto-char end))
-      (let* ((w (gnuplot-this-word))
-             (wd (try-completion w gnuplot-gui-all-types))
-             (word "") wrd list)
-        (cond ((equal wd t)                     (setq word w))
-              ((equal wd nil)                   (setq word w))
-              ((assoc wd gnuplot-gui-all-types) (setq word wd))
-              (t                                (setq wd nil)))
-        (cond ((equal (string-match "^\\s-*$" w) 0)
-               (message "Blank line"))
-              ((and wd (stringp word))
-               (gnuplot-gui-correct-command word set term begin)
-               (setq gnuplot-gui-alist nil
-                     gnuplot-gui-current-string
-                     (buffer-substring-no-properties (point) end))
-               (gnuplot-gui-set-alist word gnuplot-gui-current-string)
-               (let* ((old-height (gnuplot-gui-get-frame-param 'height))
-                      (old-top    (gnuplot-gui-get-frame-param 'top)))
-                 (when (or
-                        (and (equal gnuplot-gui-plot-splot-fit-style 'complete)
-                             (cl-member word '("plot" "splot" "fit")
-                                        :test 'string=))
-                        (equal word "test"))
-                   (gnuplot-gui-set-frame-param 'height 32)
-                   (gnuplot-gui-set-frame-param 'top    50))
-                 (gnuplot-gui-prompt-for-frame word)
-                 (when (or
-                        (and (equal gnuplot-gui-plot-splot-fit-style 'complete)
-                             (cl-member word '("plot" "splot" "fit")
-                                        :test 'string=))
-                        (equal word "test"))
-                   (gnuplot-gui-set-frame-param 'height old-height)
-                   (gnuplot-gui-set-frame-param 'top    old-top)) ))
-              ((setq wrd (car (all-completions w '(("cntrparam")))))
-               (message
-                "Setting arguments for %S is currently unsuported in 
gnuplot-mode"
-                wrd))
-              ((setq list (all-completions w gnuplot-gui-all-types))
-               (message "%S could be one of %S" w list))
+              ;;(goto-char (match-end 0)))
               (t
-               (message
-                "%S is not a gnuplot command which takes options" w)))) )))
+               (forward-word 1)))
+        (if (> (point) end) (goto-char end))
+        (let* ((w (gnuplot-this-word))
+               (wd (try-completion w gnuplot-gui-all-types))
+               (word "") wrd list)
+          (cond ((equal wd t)                     (setq word w))
+                ((equal wd nil)                   (setq word w))
+                ((assoc wd gnuplot-gui-all-types) (setq word wd))
+                (t                                (setq wd nil)))
+          (cond ((equal (string-match "^\\s-*$" w) 0)
+                 (message "Blank line"))
+                ((and wd (stringp word))
+                 (gnuplot-gui-correct-command word set term begin)
+                 (setq gnuplot-gui-alist nil
+                       gnuplot-gui-current-string
+                       (buffer-substring-no-properties (point) end))
+                 (gnuplot-gui-set-alist word gnuplot-gui-current-string)
+                 (let* ((old-height (gnuplot-gui-get-frame-param 'height))
+                        (old-top    (gnuplot-gui-get-frame-param 'top)))
+                   (when (or
+                          (and (equal gnuplot-gui-plot-splot-fit-style 
'complete)
+                               (cl-member word '("plot" "splot" "fit")
+                                          :test 'string=))
+                          (equal word "test"))
+                     (gnuplot-gui-set-frame-param 'height 32)
+                     (gnuplot-gui-set-frame-param 'top    50))
+                   (gnuplot-gui-prompt-for-frame word)
+                   (when (or
+                          (and (equal gnuplot-gui-plot-splot-fit-style 
'complete)
+                               (cl-member word '("plot" "splot" "fit")
+                                          :test 'string=))
+                          (equal word "test"))
+                     (gnuplot-gui-set-frame-param 'height old-height)
+                     (gnuplot-gui-set-frame-param 'top    old-top)) ))
+                ((setq wrd (car (all-completions w '(("cntrparam")))))
+                 (message
+                  "Setting arguments for %S is currently unsuported in 
gnuplot-mode"
+                  wrd))
+                ((setq list (all-completions w gnuplot-gui-all-types))
+                 (message "%S could be one of %S" w list))
+                (t
+                 (message
+                  "%S is not a gnuplot command which takes options" w)))) ))))
 
 ;;;###autoload
 (defun gnuplot-gui-toggle-popup ()
diff --git a/gnuplot.el b/gnuplot.el
index 86f8b24eac..00ef227bb0 100644
--- a/gnuplot.el
+++ b/gnuplot.el
@@ -282,11 +282,11 @@ suggestions."
          (set sym value)
          (cond
           (value
-           (add-hook 'gnuplot-mode-hook 'gnuplot-context-sensitive-mode nil 
nil)
-           (add-hook 'gnuplot-comint-mode-hook 'gnuplot-context-sensitive-mode 
nil nil))
+           (add-hook 'gnuplot-mode-hook #'gnuplot-context-sensitive-mode nil 
nil)
+           (add-hook 'gnuplot-comint-mode-hook 
#'gnuplot-context-sensitive-mode nil nil))
           (t
-           (remove-hook 'gnuplot-mode-hook 'gnuplot-context-sensitive-mode)
-           (remove-hook 'gnuplot-comint-mode-hook 
'gnuplot-context-sensitive-mode)))
+           (remove-hook 'gnuplot-mode-hook #'gnuplot-context-sensitive-mode)
+           (remove-hook 'gnuplot-comint-mode-hook 
#'gnuplot-context-sensitive-mode)))
          (dolist (buffer (buffer-list))
            (with-current-buffer buffer
              (when (and (derived-mode-p 'gnuplot-mode 'gnuplot-comint-mode)
@@ -376,7 +376,7 @@ non-nil."
   (let ((map (make-sparse-keymap)))
     (define-key map "\C-c\C-b"    #'gnuplot-send-buffer-to-gnuplot)
     (define-key map "\C-c\C-c"    #'comment-region) ; <RF>
-    (define-key map "\C-c\C-o"    'gnuplot-gui-set-options-and-insert)
+    (define-key map "\C-c\C-o"    #'gnuplot-gui-set-options-and-insert)
     (define-key map "\C-c\C-e"    #'gnuplot-show-gnuplot-buffer)
     (define-key map "\C-c\C-f"    #'gnuplot-send-file-to-gnuplot)
     (define-key map "\C-c\C-d"    #'gnuplot-info-lookup-symbol)
@@ -394,7 +394,7 @@ non-nil."
     (define-key map (kbd "}")     #'gnuplot-electric-insert)
     (define-key map "\M-\r"       #'completion-at-point)
     (define-key map "\M-\t"       #'completion-at-point)
-    (define-key map [S-mouse-2]   'gnuplot-gui-mouse-set)
+    (define-key map [S-mouse-2]   #'gnuplot-gui-set-options-and-insert)
 
     map))
 
@@ -1384,7 +1384,7 @@ buffer."
     (let ((gnuplot-cmd (list #'make-comint gnuplot-process-name 
gnuplot-program)))
       (when gnuplot-program-args
         (setq gnuplot-cmd (append gnuplot-cmd '(nil) (split-string 
gnuplot-program-args))))
-      (setq gnuplot-buffer  (eval gnuplot-cmd)
+      (setq gnuplot-buffer  (eval gnuplot-cmd t)
             gnuplot-process (get-buffer-process gnuplot-buffer)))
     (set-process-query-on-exit-flag gnuplot-process nil)
     (with-current-buffer gnuplot-buffer
@@ -1582,7 +1582,7 @@ then removes itself from 
`comint-preoutput-filter-functions'."
     (when (looking-back gnuplot-prompt-regexp (point-min))
       (with-current-buffer gnuplot-buffer
         (remove-hook 'comint-preoutput-filter-functions
-                     'gnuplot-discard-output t))))
+                     #'gnuplot-discard-output t))))
   "")
 
 
@@ -2049,7 +2049,6 @@ a list:
 
   (setq gnuplot-comint-recent-buffer (current-buffer))
   (setq-local comint-process-echoes gnuplot-echo-command-line-flag)
-  (run-hooks 'gnuplot-mode-hook)
   (gnuplot-setup-menubar))
 
 ;;;###autoload

Reply via email to