emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gnuplot d1a6a606dc 11/11: Merge pull request #76 from mina


From: ELPA Syncer
Subject: [nongnu] elpa/gnuplot d1a6a606dc 11/11: Merge pull request #76 from minad/lazy-loading
Date: Sun, 2 Jan 2022 11:58:19 -0500 (EST)

branch: elpa/gnuplot
commit d1a6a606dcb389a7c91a6b0d9fb995434df561be
Merge: e74ca19d8b 0654205741
Author: Maxime Tréca <16440823+mtreca@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #76 from minad/lazy-loading
    
    Lazy loading and lexical scoping
---
 README.org               |  11 +-
 gnuplot-context.el       |  90 ++++++++++++++++-
 gnuplot-debug-context.el |   6 +-
 gnuplot-gui.el           |  33 +++---
 gnuplot-test-context.el  |   4 +-
 gnuplot-tests.el         |   2 +-
 gnuplot.el               | 258 +++++++++++++++--------------------------------
 gpelcard.tex             |   3 -
 8 files changed, 195 insertions(+), 212 deletions(-)

diff --git a/README.org b/README.org
index 144cea2f88..e1c2a0b679 100644
--- a/README.org
+++ b/README.org
@@ -103,7 +103,6 @@ When =gnuplot-mode= is on, the following keybindings are 
available:
 | M-tab or M-ret | complete keyword before point                        |
 | ret            | newline and indent                                   |
 | tab            | indent current line                                  |
-| C-c M-i        | toggle inline plot display in comint buffer          |
 
 
 With the exception of the commands for sending commands to Gnuplot,
@@ -140,16 +139,16 @@ terminal= commands.
 If you install the file =gnuplot-eldoc.el= from a recent Gnuplot
 distribution, gnuplot-mode can show syntax hints in the modeline when
 ~eldoc-mode~ is turned on and context sensitivity is enabled.
-    
+
 ** Inline Images
 
 You can optionally have plots displayed inline in the Gnuplot comint
 process buffer. This is handy for trying things out without having to
 switch between Emacs and the Gnuplot display. Call
-=gnuplot-inline-imge-mode= or type ~C-c M-i~ in a gnuplot-mode buffer
-to try it out. This feature is implemented using temporary =png=
-files, and is also somewhat experimental. It requires Gnuplot to have
-=png= support and a GNU Emacs with image support. Please report bugs.
+=gnuplot-inline-display-mode= in a gnuplot-mode buffer to try it out. This
+feature is implemented using temporary =png= files, and is also somewhat
+experimental. It requires Gnuplot to have =png= support and a GNU Emacs
+with image support. Please report bugs.
 
 
 
diff --git a/gnuplot-context.el b/gnuplot-context.el
index 00230ea1d0..67f15b0ab0 100644
--- a/gnuplot-context.el
+++ b/gnuplot-context.el
@@ -1,4 +1,4 @@
-;;; gnuplot-context.el -- context-sensitive help and completion for gnuplot
+;;; gnuplot-context.el -- context-sensitive help and completion for gnuplot 
-*- lexical-binding: t -*-
 
 ;; Copyright (C) 2012-2013 Jon Oddie <jonxfield@gmail.com>
 
@@ -1721,9 +1721,9 @@ name; otherwise continues tokenizing up to the token at 
point.  FIXME."
 ;; them. For normal use, they compile to no-ops.
 (eval-when-compile
   (when (not (featurep 'gnuplot-debug-context))
-    (defmacro with-gnuplot-trace-buffer (&rest args) "No-op." '(progn nil))
-    (defmacro gnuplot-trace (&rest args) "No-op." '(progn nil))
-    (defmacro gnuplot-debug (&rest args) "No-op." '(progn nil))))
+    (defmacro with-gnuplot-trace-buffer (&rest _) "No-op." '(progn nil))
+    (defmacro gnuplot-trace (&rest _) "No-op." '(progn nil))
+    (defmacro gnuplot-debug (&rest _) "No-op." '(progn nil))))
 
 
 
@@ -1755,6 +1755,12 @@ name specified in the (capture NAME PATTERN) form in the
 list beginning the capture group, and END is the tail of the
 token list just after the end of the capture group.")
 
+(defvar gnuplot-eldoc-hash nil
+  "ElDoc strings for gnuplot-mode.
+
+These have to be compiled from the Gnuplot source tree using
+`doc2texi.el'.")
+
 
 ;;;; The pattern matching machine
 (defun gnuplot-match-pattern (instructions tokens completing-p
@@ -1984,7 +1990,7 @@ there."
 (defun gnuplot-scan-stack (stack tokens)
   "Scan STACK for the most recently pushed eldoc and info strings."
   (gnuplot-trace "\t* scanning stack *\n")
-  (gnuplot-debug (gnuplot-backtrace))
+  (gnuplot-debug (gnuplot-backtrace stack))
   (gnuplot-debug (gnuplot-dump-captures))
 
   (catch 'no-scan
@@ -2180,6 +2186,80 @@ command."
       nil)))
 
 
+;;;###autoload
+(define-minor-mode gnuplot-context-sensitive-mode
+  "Use context-sensitive completion and help in gnuplot-mode.
+
+When context-sensitive mode is enabled, gnuplot-mode tries to
+provide more useful completions and help suggestions for built-in
+keywords and functions by parsing each command as you type.  It
+attempts to take into account Gnuplot's many abbreviated
+keywords.  For example, with point at the end of a line reading
+\"plot 'datafile' w \", typing \\[completion-at-point] will pop
+up a list of plotting styles.
+
+Key bindings:
+
+\\[completion-at-point] will complete the keyword at point based
+on its context in the command. To make keyword completion work on
+pressing TAB, set `tab-always-indent' to `complete', or customize
+`gnuplot-tab-completion' to make this automatic in gnuplot-mode
+buffers.
+
+\\[gnuplot-info-at-point] will try to find the most relevant
+Gnuplot info node for the construction at point, prompting for a
+node name if nothing is found.
+
+\\[gnuplot-help-function] will pop up a brief summary of the
+syntax at point in the minibuffer. To have one-line syntax
+summaries appear in the echo area as you type, toggle
+`eldoc-mode' or customize `gnuplot-eldoc-mode'.
+
+To choose whether to use this mode by default in Gnuplot buffers,
+customize the variable
+`gnuplot-use-context-sensitive-completion'.
+
+Note: help strings for eldoc-mode and \\[gnuplot-help-function]
+need to be provided in an Emacs-readable form by the Gnuplot
+distribution. See gnuplot-context.el for details."
+  :keymap
+  `((,(kbd "C-c C-/") . gnuplot-help-function)
+    (,(kbd "C-c C-d") . gnuplot-info-at-point))
+  (unless (derived-mode-p 'gnuplot-mode 'gnuplot-comint-mode)
+    (message "Gnuplot context-sensitive mode works only in Gnuplot-mode 
buffers")
+    (setq gnuplot-context-sensitive-mode nil))
+  (if gnuplot-context-sensitive-mode
+      ;; Turn on
+      (progn
+        (setq gnuplot-completion-at-point-function 
#'gnuplot-context-completion-at-point)
+
+        ;; Setup Eldoc
+        (setq-local eldoc-documentation-function #'gnuplot-eldoc-function)
+        (eldoc-add-command 'completion-at-point)     ; Check for eldoc after 
completion
+
+        ;; Try to load Eldoc strings
+        (when gnuplot-eldoc-mode
+          (unless gnuplot-eldoc-hash
+            (condition-case nil
+                (load-library "gnuplot-eldoc")
+              (error
+               (message "gnuplot-eldoc.el not found. Install it from the 
Gnuplot distribution.")
+               (setq gnuplot-eldoc-hash nil
+                     gnuplot-eldoc-mode nil))))
+
+          (if gnuplot-eldoc-hash
+              (eldoc-mode 1)
+            (eldoc-mode 0)))
+
+        ;; Set up tab-to-complete
+        (when gnuplot-tab-completion
+          (setq-local tab-always-indent 'complete)))
+
+    ;; Turn off
+    (setq gnuplot-completion-at-point-function 
#'gnuplot-completion-at-point-info-look)
+    (setq eldoc-documentation-function nil)
+    (eldoc-mode 0)))
+
 
 ;;; All done!
 (provide 'gnuplot-context)
diff --git a/gnuplot-debug-context.el b/gnuplot-debug-context.el
index 8ac2dbdfd7..daf2298d33 100644
--- a/gnuplot-debug-context.el
+++ b/gnuplot-debug-context.el
@@ -1,6 +1,4 @@
-;;
-;; debugging utilities for the gnuplot-mode context matcher
-;;
+;; debugging utilities for the gnuplot-mode context matcher -*- 
lexical-binding: t -*-
 
 (require 'gnuplot-test-context) ; for gnuplot-simplify-tokens
 
@@ -56,7 +54,7 @@
 (defmacro gnuplot-trace (&rest args)
   `(with-gnuplot-trace-buffer (insert (format ,@args))))
 
-(defun gnuplot-backtrace ()
+(defun gnuplot-backtrace (stack)
   (if stack
       (with-gnuplot-trace-buffer
        (insert "\n-- * backtrace: * --\n")
diff --git a/gnuplot-gui.el b/gnuplot-gui.el
index 042b9b1404..061284e9ff 100644
--- a/gnuplot-gui.el
+++ b/gnuplot-gui.el
@@ -1,4 +1,4 @@
-;;;; gnuplot-gui.el -- GUI interface to setting options in gnuplot-mode
+;;;; gnuplot-gui.el -- GUI interface to setting options in gnuplot-mode -*- 
lexical-binding: t -*-
 
 ;; Copyright (C) 1998-2000 Bruce Ravel
 
@@ -805,6 +805,7 @@ This alist is formed at load time by appending together
                                     gnuplot-gui-test-type))
 
 
+;;;###autoload
 (defun gnuplot-gui-swap-simple-complete ()
   (interactive)
   (setq gnuplot-gui-plot-splot-fit-style
@@ -826,6 +827,7 @@ 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]
@@ -842,6 +844,7 @@ currently supported."
 (defun gnuplot-gui-set-frame-param (param value)
   (setcdr (assoc param gnuplot-gui-frame-parameters) value))
 
+;;;###autoload
 (defun gnuplot-gui-set-options-and-insert ()
   "Insert arguments using a GUI interface.
 Determine contents of current line and set up the appropriate GUI
@@ -923,6 +926,7 @@ Note that \"cntrparam\" is not currently supported."
                (message
                 "%S is not a gnuplot command which takes options" w)))) )))
 
+;;;###autoload
 (defun gnuplot-gui-toggle-popup ()
   (interactive)
   (setq gnuplot-gui-popup-flag (not gnuplot-gui-popup-flag))
@@ -931,7 +935,6 @@ Note that \"cntrparam\" is not currently supported."
              "Argument popup will no longer appear after insertions.")))
 
 
-(defun gnuplot-gui-y-n (foo))
 (defalias 'gnuplot-gui-y-n 'y-or-n-p)
 
 (defun gnuplot-gui-correct-command (word set term begin)
@@ -1312,7 +1315,7 @@ SAVE-FRAME is non-nil when the widgets are being reset."
                  :button-face 'gnuplot-gui-button-face
                  :help-echo "Push this button to set options"
                  :notify
-                 (lambda (widget &rest ignore)
+                 (lambda (widget &rest _ignore)
                    (kill-buffer (get-buffer-create "*Gnuplot GUI*"))
                    (delete-frame)
                    (select-frame gnuplot-current-frame)
@@ -1352,7 +1355,7 @@ SAVE-FRAME is non-nil when the widgets are being reset."
                  :button-face 'gnuplot-gui-button-face
                  :doc item
                  :notify
-                 (lambda (widget &rest ignore)
+                 (lambda (widget &rest _ignore)
                    (let ((word (widget-get widget :doc)))
                      (gnuplot-gui-set-alist word gnuplot-gui-current-string)
                      (gnuplot-gui-prompt-for-frame word t))))
@@ -1362,7 +1365,7 @@ SAVE-FRAME is non-nil when the widgets are being reset."
                  :button-face 'gnuplot-gui-button-face
                  :doc item
                  :notify
-                 (lambda (widget &rest ignore)
+                 (lambda (widget &rest _ignore)
                    (let* ((word (widget-get widget :doc))
                           (alist (cdr (assoc word gnuplot-gui-all-types))))
                      (while alist
@@ -1375,7 +1378,7 @@ SAVE-FRAME is non-nil when the widgets are being reset."
   (widget-create 'push-button :value "Cancel"
                  :help-echo "Quit setting options and dismiss frame"
                  :button-face 'gnuplot-gui-button-face
-                 :notify (lambda (widget &rest ignore)
+                 :notify (lambda (_widget &rest _ignore)
                            (kill-buffer (get-buffer-create "*Gnuplot GUI*"))
                            (setq gnuplot-gui-alist nil
                                  gnuplot-gui-current-string nil)
@@ -1425,7 +1428,7 @@ menu.  STARRED is true if this a 'list* widget."
                 :button-prefix "[" :button-suffix "]"
                 :help-echo (format "Mouse-2 to view the %S menu" (downcase 
item))
                 :notify
-                (lambda (widget &rest ignore)
+                (lambda (widget &rest _ignore)
                   (let ((lab (if (widget-get widget :doc)
                                  (concat (downcase (widget-get widget :tag)) " 
")
                                "" )))
@@ -1450,7 +1453,7 @@ the numerical argument."
     (widget-create 'editable-field
                    :size 2 :tag item :value default :doc prefix
                    :help-echo (format "Insert new value of %S here" help-label)
-                   :notify (lambda (widget &rest ignore)
+                   :notify (lambda (widget &rest _ignore)
                              (let ((val (widget-value widget))
                                    (pre (concat (widget-get widget :doc) " ")))
                                (setcdr (assoc (widget-get widget :tag)
@@ -1486,7 +1489,7 @@ prefix for the string.  STARRED is t if quotes are not to 
be used."
      'editable-field
      :size width :tag item :doc prefix :value default
      :help-echo (format "Insert new value of %S here" help-label)
-     :notify (lambda (widget &rest ignore)
+     :notify (lambda (widget &rest _ignore)
                (let ((val (widget-value widget))
                      (q gnuplot-quote-character)
                      (p (widget-get widget :doc)) )
@@ -1520,7 +1523,7 @@ prefix for the string."
   (widget-create 'editable-field
                  :size (/ (frame-width) 3) :tag item :value default
                  :help-echo (format "Insert new format string here")
-                 :notify (lambda (widget &rest ignore)
+                 :notify (lambda (widget &rest _ignore)
                            (let ((val (widget-value widget)))
                              (setcdr (assoc (widget-get widget :tag)
                                             gnuplot-gui-alist)
@@ -1574,7 +1577,7 @@ the default value for the argument.  TAG is non-nil if 
ITEM rather than
                :doc item :help-echo "Insert a filename here"
                :complete 'gnuplot-gui-file-completion
                :notify
-               (lambda (widget &rest ignore)
+               (lambda (widget &rest _ignore)
                  (setcdr (assoc (widget-get widget :doc) gnuplot-gui-alist)
                          (format "%s%s%s" gnuplot-quote-character
                                  (widget-value widget)
@@ -1584,7 +1587,7 @@ the default value for the argument.  TAG is non-nil if 
ITEM rather than
      'push-button :value "Browse"
      :doc item :help-echo "Browse directories for a filename."
      :parent widg
-     :notify (lambda (widget &rest ignore)
+     :notify (lambda (widget &rest _ignore)
                (let ((fname (file-relative-name (read-file-name "File: ")
                                                 default-directory))
                      (q gnuplot-quote-character))
@@ -1610,7 +1613,7 @@ the default value for the argument."
    :format "%{%t%}:\n%v\t  %i\n"
    :entry-format "\t  %i %d %v\n"
    :button-face 'gnuplot-gui-labels-face
-   :notify (lambda (widget &rest ignore)
+   :notify (lambda (widget &rest _ignore)
              (setcdr (assoc (upcase (widget-get widget :tag))
                             gnuplot-gui-alist)
                      (widget-value widget)))))
@@ -1627,7 +1630,7 @@ is non-nil if this is a 'range widget."
                  :size 4 :tag item :value (car default)
                  :help-echo (format "Insert the first value of the %S here"
                                     (downcase item))
-                 :notify (lambda (widget &rest ignore)
+                 :notify (lambda (widget &rest _ignore)
                            (setcar (cdr (assoc (widget-get widget :tag)
                                                gnuplot-gui-alist))
                                    (format "%s" (widget-value widget)))))
@@ -1636,7 +1639,7 @@ is non-nil if this is a 'range widget."
                  :size 4 :tag item :value (cdr default)
                  :help-echo (format "Insert the second value of the %S here"
                                     (downcase item))
-                 :notify (lambda (widget &rest ignore)
+                 :notify (lambda (widget &rest _ignore)
                            (setcdr (cdr (assoc (widget-get widget :tag)
                                                gnuplot-gui-alist))
                                    (format "%s" (widget-value widget)))))
diff --git a/gnuplot-test-context.el b/gnuplot-test-context.el
index eb08223bdb..48dd73104d 100644
--- a/gnuplot-test-context.el
+++ b/gnuplot-test-context.el
@@ -1,6 +1,4 @@
-;;
-;; automated tests for gnuplot-mode context matching
-;;
+;; automated tests for gnuplot-mode context matching  -*- lexical-binding: t 
-*-
 
 (require 'gnuplot-context)
 
diff --git a/gnuplot-tests.el b/gnuplot-tests.el
index 5f73703f89..84bd65f53b 100644
--- a/gnuplot-tests.el
+++ b/gnuplot-tests.el
@@ -1,4 +1,4 @@
-;;; Tests for gnuplot-mode.
+;;; Tests for gnuplot-mode. -*- lexical-binding: t -*-
 
 ;;; Currently these attempt to cover the correct identification of
 ;;; string and comment syntax.
diff --git a/gnuplot.el b/gnuplot.el
index 61aeb79b76..a7d486520e 100644
--- a/gnuplot.el
+++ b/gnuplot.el
@@ -1,4 +1,4 @@
-;;; gnuplot.el --- Major-mode and interactive frontend for gnuplot
+;;; gnuplot.el --- Major-mode and interactive frontend for gnuplot -*- 
lexical-binding: t -*-
 
 ;; Copyright (C) 1998, 2011 Phil Type and Bruce Ravel, 1999-2012 Bruce Ravel
 
@@ -114,12 +114,13 @@
   :group 'gnuplot-hooks
   :type 'hook)
 
-(defcustom gnuplot-load-hook nil
-  "Hook run when gnuplot.el is first loaded."
-  :group 'gnuplot-hooks
-  :type 'hook)
+(defvar gnuplot-load-hook nil)
+(make-obsolete-variable
+ 'gnuplot-load-hook
+ "The package loading hook has been removed, use `with-eval-after-load' 
instead."
+ "8.0")
 
-(defcustom gnuplot-after-plot-hook nil
+(defcustom gnuplot-after-plot-hook (list #'gnuplot-trim-gnuplot-buffer)
   "Hook run after gnuplot plots something.
 This is the last thing done by the functions for plotting a line, a
 region, a buffer, or a file."
@@ -184,11 +185,10 @@ for backward compatibility."
   :group 'gnuplot-hooks
   :type 'hook)
 
-(defvar gnuplot-recently-sent nil
+(defvar-local gnuplot-recently-sent nil
   "This is a record of the most recent kind of text sent to gnuplot.
 It takes as its value nil, 'line, 'region, 'buffer, or 'file.  It is
 useful for functions included in `gnuplot-after-plot-hook'.")
-(make-variable-buffer-local 'gnuplot-recently-sent)
 
 (defcustom gnuplot-program "gnuplot"
   "The name of the gnuplot executable."
@@ -304,9 +304,6 @@ beginning the continued command."
   :type 'integer)
 
 (defvar gnuplot-info-frame nil)
-(defvar gnuplot-info-nodes '())
-
-(defvar gnuplot-first-call t)
 
 ;; with info-look, there is no need to carry this list around -- it
 ;; can be generated on the fly appropriate to the currently installed
@@ -334,13 +331,20 @@ command line to provide smarter completion and 
documentation
 suggestions."
   :group 'gnuplot
   :type 'boolean
-  :initialize 'custom-set-default
   :set (lambda (sym value)
+         (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))
+          (t
+           (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 (derived-mode-p 'gnuplot-mode 'gnuplot-comint-mode)
-               (gnuplot-context-sensitive-mode
-                (if value 1 0))))))
+             (when (and (derived-mode-p 'gnuplot-mode 'gnuplot-comint-mode)
+                        (fboundp 'gnuplot-context-sensitive-mode))
+               (gnuplot-context-sensitive-mode (if value 1 0))))))
   :link '(emacs-commentary-link "gnuplot-context"))
 
 (defcustom gnuplot-eldoc-mode nil
@@ -358,7 +362,7 @@ symbol `complete' in gnuplot-mode buffers."
   :group 'gnuplot
   :type 'boolean)
 
-(defun gnuplot-set-display-mode (variable value &rest args)
+(defun gnuplot-set-display-mode (variable value &rest _args)
   "Customize :set function for `gnuplot-inline-image-mode'.
 Set VARIABLE to VALUE.  ARGS is optional args."
   (if (and (eq variable 'gnuplot-inline-image-mode)
@@ -389,8 +393,8 @@ and `gnuplot-dedicated-display-mode'."
           (const :tag "No" nil)
           (const :tag "In Comint buffer" inline)
           (const :tag "In dedicated buffer" dedicated))
-  :initialize 'custom-initialize-default
-  :set 'gnuplot-set-display-mode)
+  :initialize #'custom-initialize-default
+  :set #'gnuplot-set-display-mode)
 
 (defcustom gnuplot-image-format "png"
   "Image format to use for displaying images within Emacs.
@@ -403,8 +407,8 @@ This only has an effect when `gnuplot-inline-image-mode' is
 non-nil."
   :group 'gnuplot
   :type 'string
-  :initialize 'custom-initialize-default
-  :set 'gnuplot-set-display-mode)
+  :initialize #'custom-initialize-default
+  :set #'gnuplot-set-display-mode)
 
 (defgroup gnuplot-faces nil
   "Text faces used by gnuplot-mode."
@@ -423,27 +427,26 @@ non-nil."
 
 (defvar gnuplot-mode-map
   (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-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-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)
-    (define-key map "\C-c\C-i"    'gnuplot-insert-filename)
-    (define-key map "\C-c\C-j"    'gnuplot-forward-script-line)
-    (define-key map "\C-c\C-k"    'gnuplot-kill-gnuplot-buffer)
-    (define-key map "\C-c\C-l"    'gnuplot-send-line-to-gnuplot)
-    (define-key map "\C-c\C-n"    'gnuplot-negate-option)
-    (define-key map "\C-c\C-r"    'gnuplot-send-region-to-gnuplot)
-    (define-key map (kbd "C-M-x") 'gnuplot-send-line-to-gnuplot)
-    (define-key map "\C-c\C-v"    'gnuplot-send-line-and-forward)
-    (define-key map "\C-c\C-z"    'gnuplot-customize)
-    (define-key map "\C-i"        'indent-for-tab-command)
-    (define-key map "\C-m"        'newline-and-indent)
-    (define-key map "\C-c\M-i"    'gnuplot-inline-image-mode)
-    (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 "\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)
+    (define-key map "\C-c\C-i"    #'gnuplot-insert-filename)
+    (define-key map "\C-c\C-j"    #'gnuplot-forward-script-line)
+    (define-key map "\C-c\C-k"    #'gnuplot-kill-gnuplot-buffer)
+    (define-key map "\C-c\C-l"    #'gnuplot-send-line-to-gnuplot)
+    (define-key map "\C-c\C-n"    #'gnuplot-negate-option)
+    (define-key map "\C-c\C-r"    #'gnuplot-send-region-to-gnuplot)
+    (define-key map (kbd "C-M-x") #'gnuplot-send-line-to-gnuplot)
+    (define-key map "\C-c\C-v"    #'gnuplot-send-line-and-forward)
+    (define-key map "\C-c\C-z"    #'gnuplot-customize)
+    (define-key map "\C-i"        #'indent-for-tab-command)
+    (define-key map "\C-m"        #'newline-and-indent)
+    (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)
 
     map))
@@ -512,7 +515,6 @@ non-nil."
 
 ;;; --- insertions variables and menus
 
-;;(load-library "gnuplot-insertions")
 (defvar gnuplot-mode-insertions-menu nil)
 (defvar gnuplot-insertions-menu nil
   "Menu for insertions in `gnuplot-mode'.
@@ -544,18 +546,16 @@ The easiest way to customize the submenus is to use the 
custom
 package.  Just type \\[gnuplot-customize] and follow your nose.
 
 You can also add new items to any of these sub-menus by adding to the
-`gnuplot-load-hook' in your .emacs file.  Here is an example of adding
-the \"regis\" terminal type to the terminal sub-menu:
+`with-eval-after-load' blocks in your .emacs file. Here is an example of
+adding the \"regis\" terminal type to the terminal sub-menu:
 
- (add-hook
-  'gnuplot-load-hook
-  '(lambda ()
+ (with-eval-after-load 'gnuplot
       (setq gnuplot-insertions-terminal
             (append gnuplot-insertions-terminal
                     (list
                      [\"regis\"
                       (gnuplot-insert \"set terminal regis\")
-                       t])))))")
+                       t]))))")
 
 (defvar gnuplot-insertions-top ()
   "Top part of insertions menu.
@@ -837,18 +837,16 @@ create a `gnuplot-mode' buffer."
                                (boolean  :tag "Enabled" t)))))
 
 
-(defvar gnuplot-gui-popup-flag)
-(defvar gnuplot-insertions-bottom ()
+(defvar gnuplot-insertions-bottom
+  '("---"
+    ["Display of info with insertion" gnuplot-toggle-info-display
+     :style toggle :selected gnuplot-insertions-show-help-flag]
+    ["Display GUI popup with insertion" gnuplot-gui-toggle-popup
+     :active t
+     :style toggle :selected gnuplot-gui-popup-flag])
   "Bottom part of the insertions menu.
 This part contains the toggle buttons for displaying info or
 opening an argument-setting popup.")
-(setq gnuplot-insertions-bottom
-      '("---"
-        ["Display of info with insertion" gnuplot-toggle-info-display
-         :style toggle :selected gnuplot-insertions-show-help-flag]
-        ["Display GUI popup with insertion" gnuplot-gui-toggle-popup
-         :active t
-         :style toggle :selected gnuplot-gui-popup-flag]))
 
 (defun gnuplot-setup-menubar ()
   "Initial setup of gnuplot and insertions menus."
@@ -1348,13 +1346,11 @@ this function is attached to `gnuplot-after-plot-hook'"
   (if (> gnuplot-buffer-max-size 0)
       (with-current-buffer gnuplot-buffer
         (let ((gnuplot-lines (count-lines (point-min) (point-max))))
-          (dotimes (tmp (- gnuplot-lines gnuplot-buffer-max-size))
+          (dotimes (_n (- gnuplot-lines gnuplot-buffer-max-size))
             (goto-char (point-min))
             (delete-region (line-beginning-position) (1+ (line-end-position))))
           (goto-char (point-max))))))
 
-(add-hook 'gnuplot-after-plot-hook 'gnuplot-trim-gnuplot-buffer nil nil)
-
 
 ;;; --- functions controlling the gnuplot process
 
@@ -1404,13 +1400,13 @@ buffer."
   (setq-local parse-sexp-lookup-properties t)
   (setq-local syntax-propertize-function #'gnuplot-syntax-propertize)
 
-  (add-hook 'kill-buffer-hook 'gnuplot-close-down nil t)
+  (add-hook 'kill-buffer-hook #'gnuplot-close-down nil t)
 
   (add-hook 'comint-output-filter-functions
-            'comint-postoutput-scroll-to-bottom
+            #'comint-postoutput-scroll-to-bottom
             nil t)
   (add-hook 'comint-output-filter-functions
-            'gnuplot-protect-prompt-fn
+            #'gnuplot-protect-prompt-fn
             nil t)
 
   ;; Set up completion, using completion-at-point
@@ -1424,17 +1420,16 @@ buffer."
   (easy-menu-add gnuplot-comint-mode-menu gnuplot-comint-mode-map))
 
 ;; Key bindings for gnuplot-comint-mode
-(define-key gnuplot-comint-mode-map "\M-\C-p"   'gnuplot-plot-from-comint)
-(define-key gnuplot-comint-mode-map "\M-\C-f"   
'gnuplot-save-and-plot-from-comint)
-(define-key gnuplot-comint-mode-map "\C-d"      'gnuplot-delchar-or-maybe-eof)
-(define-key gnuplot-comint-mode-map "\M-\r"     'completion-at-point)
-(define-key gnuplot-comint-mode-map "\M-\t"     'completion-at-point)
-(define-key gnuplot-comint-mode-map "\C-c\C-d"  'gnuplot-info-lookup-symbol)
-(define-key gnuplot-comint-mode-map "\C-c\C-i"  'gnuplot-insert-filename)
-(define-key gnuplot-comint-mode-map "\C-c\C-n"  'gnuplot-negate-option)
-(define-key gnuplot-comint-mode-map "\C-c\C-z"  'gnuplot-customize)
-(define-key gnuplot-comint-mode-map "\C-c\C-e"  'gnuplot-pop-to-recent-buffer)
-(define-key gnuplot-comint-mode-map "\C-c\M-i"  'gnuplot-inline-image-mode)
+(define-key gnuplot-comint-mode-map "\M-\C-p"   #'gnuplot-plot-from-comint)
+(define-key gnuplot-comint-mode-map "\M-\C-f"   
#'gnuplot-save-and-plot-from-comint)
+(define-key gnuplot-comint-mode-map "\C-d"      #'gnuplot-delchar-or-maybe-eof)
+(define-key gnuplot-comint-mode-map "\M-\r"     #'completion-at-point)
+(define-key gnuplot-comint-mode-map "\M-\t"     #'completion-at-point)
+(define-key gnuplot-comint-mode-map "\C-c\C-d"  #'gnuplot-info-lookup-symbol)
+(define-key gnuplot-comint-mode-map "\C-c\C-i"  #'gnuplot-insert-filename)
+(define-key gnuplot-comint-mode-map "\C-c\C-n"  #'gnuplot-negate-option)
+(define-key gnuplot-comint-mode-map "\C-c\C-z"  #'gnuplot-customize)
+(define-key gnuplot-comint-mode-map "\C-c\C-e"  #'gnuplot-pop-to-recent-buffer)
 
 ;; Menu for gnuplot-comint-mode
 (defvar gnuplot-comint-mode-menu nil
@@ -1446,7 +1441,7 @@ buffer."
   (unless (and gnuplot-process (eq (process-status gnuplot-process) 'run)
                gnuplot-buffer (buffer-live-p gnuplot-buffer))
     (message "Starting gnuplot plotting program...")
-    (let ((gnuplot-cmd (list 'make-comint gnuplot-process-name 
gnuplot-program)))
+    (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)
@@ -1463,7 +1458,7 @@ buffer."
   (regexp-opt '("gnuplot> " "multiplot> "))
   "Regexp for recognizing the GNUPLOT prompt.")
 
-(defun gnuplot-protect-prompt-fn (string)
+(defun gnuplot-protect-prompt-fn (_string)
   "Prevent the Gnuplot prompt from being deleted or overwritten.
 STRING is the text as originally inserted in the comint buffer."
   (save-excursion
@@ -1573,10 +1568,10 @@ gnuplot process buffer will be displayed in a window."
              (format "set terminal %s\n" gnuplot-image-format))
             (gnuplot-inline-image-set-output)
             (add-hook 'comint-output-filter-functions
-                      'gnuplot-insert-inline-image-output nil t))
+                      #'gnuplot-insert-inline-image-output nil t))
         (gnuplot-send-hiding-output "set terminal pop\n")
         (remove-hook 'comint-output-filter-functions
-                     'gnuplot-insert-inline-image-output t)))))
+                     #'gnuplot-insert-inline-image-output t)))))
 
 (defun gnuplot-inline-image-set-output ()
   "Set Gnuplot's output file to `gnuplot-inline-image-filename'."
@@ -1584,9 +1579,9 @@ gnuplot process buffer will be displayed in a window."
     (setq gnuplot-inline-image-filename tmp)
     (gnuplot-send-hiding-output (format "set output '%s'\n" tmp))))
 
-(defvar gnuplot-inhibit-filter nil)
+(defvar gnuplot--inhibit-filter nil)
 
-(defun gnuplot-insert-inline-image-output (string)
+(defun gnuplot-insert-inline-image-output (_string)
   "Insert Gnuplot graphical output STRING in the gnuplot-comint buffer.
 
 Called via `comint-preoutput-filter-functions' hook when
@@ -1595,8 +1590,8 @@ file `gnuplot-inline-image-filename'; if it exists and has
 nonzero size, inserts it as an inline image, stores a new
 temporary filename in `gnuplot-inline-image-filename', and
 updates Gnuplot with the appropriate 'set output' command."
-  (unless gnuplot-inhibit-filter        ; Prevent recursively entering this 
filter
-    (let ((gnuplot-inhibit-filter t))   ; (causing an infinite loop)
+  (unless gnuplot--inhibit-filter        ; Prevent recursively entering this 
filter
+    (let ((gnuplot--inhibit-filter t))   ; (causing an infinite loop)
       (save-excursion
         (goto-char (point-max))
         (beginning-of-line)
@@ -1632,7 +1627,7 @@ updates Gnuplot with the appropriate 'set output' 
command."
   "Send STRING to the running Gnuplot process invisibly."
   (with-current-buffer gnuplot-buffer
     (add-hook 'comint-preoutput-filter-functions
-              'gnuplot-discard-output nil t))
+              #'gnuplot-discard-output nil t))
   (with-current-buffer (get-buffer-create gnuplot-hidden-output-buffer)
     (erase-buffer))
   (comint-send-string (get-buffer-process gnuplot-buffer) string))
@@ -1784,7 +1779,7 @@ ARG is optional arg."
   (if (not arg) (setq arg 1))
   (if (> arg 0)
       (catch 'bob               ; go to beginning of ARGth prev. defun
-        (dotimes (n arg)
+        (dotimes (_n arg)
           (when (= (point)
                    (gnuplot-point-at-beginning-of-continuation))
             (forward-line -1)
@@ -1796,7 +1791,7 @@ ARG is optional arg."
         t)
 
     (catch 'eob                   ; find beginning of (-ARG)th following defun
-      (dotimes (n (- arg))
+      (dotimes (_n (- arg))
         (gnuplot-end-of-continuation)
         (forward-line)
         (if (eobp) (throw 'eob t))
@@ -1960,88 +1955,6 @@ Return a list of keywords."
   "Perform completion in Gnuplot buffers."
   (funcall gnuplot-completion-at-point-function))
 
-(defvar gnuplot-eldoc-hash nil
-  "ElDoc strings for gnuplot-mode.
-
-These have to be compiled from the Gnuplot source tree using
-`doc2texi.el'.")
-
-;; Enable and disable context-sensitive completion
-(define-minor-mode gnuplot-context-sensitive-mode
-  "Use context-sensitive completion and help in gnuplot-mode.
-
-When context-sensitive mode is enabled, gnuplot-mode tries to
-provide more useful completions and help suggestions for built-in
-keywords and functions by parsing each command as you type.  It
-attempts to take into account Gnuplot's many abbreviated
-keywords.  For example, with point at the end of a line reading
-\"plot 'datafile' w \", typing \\[completion-at-point] will pop
-up a list of plotting styles.
-
-Key bindings:
-
-\\[completion-at-point] will complete the keyword at point based
-on its context in the command. To make keyword completion work on
-pressing TAB, set `tab-always-indent' to `complete', or customize
-`gnuplot-tab-completion' to make this automatic in gnuplot-mode
-buffers.
-
-\\[gnuplot-info-at-point] will try to find the most relevant
-Gnuplot info node for the construction at point, prompting for a
-node name if nothing is found.
-
-\\[gnuplot-help-function] will pop up a brief summary of the
-syntax at point in the minibuffer. To have one-line syntax
-summaries appear in the echo area as you type, toggle
-`eldoc-mode' or customize `gnuplot-eldoc-mode'.
-
-To choose whether to use this mode by default in Gnuplot buffers,
-customize the variable
-`gnuplot-use-context-sensitive-completion'.
-
-Note: help strings for eldoc-mode and \\[gnuplot-help-function]
-need to be provided in an Emacs-readable form by the Gnuplot
-distribution. See gnuplot-context.el for details."
-  :keymap
-  `((,(kbd "C-c C-/") . gnuplot-help-function)
-    (,(kbd "C-c C-d") . gnuplot-info-at-point))
-  (unless (derived-mode-p 'gnuplot-mode 'gnuplot-comint-mode)
-    (message "Gnuplot context-sensitive mode works only in Gnuplot-mode 
buffers")
-    (setq gnuplot-context-sensitive-mode nil))
-  (if gnuplot-context-sensitive-mode
-      ;; Turn on
-      (progn
-        (load-library "gnuplot-context")
-        (load-library "eldoc")
-        (setq gnuplot-completion-at-point-function 
#'gnuplot-context-completion-at-point)
-
-        ;; Setup Eldoc
-        (setq-local eldoc-documentation-function #'gnuplot-eldoc-function)
-        (eldoc-add-command 'completion-at-point)     ; Check for eldoc after 
completion
-
-        ;; Try to load Eldoc strings
-        (when gnuplot-eldoc-mode
-          (unless gnuplot-eldoc-hash
-            (condition-case nil
-                (load-library "gnuplot-eldoc")
-              (error
-               (message "gnuplot-eldoc.el not found. Install it from the 
Gnuplot distribution.")
-               (setq gnuplot-eldoc-hash nil
-                     gnuplot-eldoc-mode nil))))
-
-          (if gnuplot-eldoc-hash
-              (eldoc-mode 1)
-            (eldoc-mode 0)))
-
-        ;; Set up tab-to-complete
-        (when gnuplot-tab-completion
-          (setq-local tab-always-indent 'complete)))
-
-    ;; Turn off
-    (setq gnuplot-completion-at-point-function 
#'gnuplot-completion-at-point-info-look)
-    (setq eldoc-documentation-function nil)
-    (eldoc-mode 0)))
-
 ;; Older completion method using info-look
 (defun gnuplot-completion-at-point-info-look ()
   "Return completions of keyword preceding point.
@@ -2130,7 +2043,8 @@ shown."
           (setq topic (downcase (match-string 2 string))
                 term            (match-string 4 string))
           (if (string= topic "terminal") (setq topic (downcase term)))))
-    (cond (gnuplot-gui-popup-flag
+    (cond ((and (bound-and-true-p gnuplot-gui-popup-flag)
+                (fboundp 'gnuplot-gui-set-options-and-insert))
            (gnuplot-gui-set-options-and-insert))
           (gnuplot-insertions-show-help-flag
            (if gnuplot-keywords-pending          ; <HW>
@@ -2215,7 +2129,7 @@ a list:
   (setq-local beginning-of-defun-function #'gnuplot-beginning-of-defun)
   (setq-local end-of-defun-function #'gnuplot-end-of-continuation)
 
-  (add-hook 'completion-at-point-functions 'gnuplot-completion-at-point nil t)
+  (add-hook 'completion-at-point-functions #'gnuplot-completion-at-point nil t)
 
   (set-syntax-table gnuplot-mode-syntax-table)
 
@@ -2232,9 +2146,7 @@ a list:
   (setq-local font-lock-multiline t)
   (setq-local parse-sexp-lookup-properties t)
 
-  (require 'gnuplot-gui)
-  (setq gnuplot-first-call nil          ; a few more details ...
-        gnuplot-comint-recent-buffer (current-buffer))
+  (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))
@@ -2265,11 +2177,7 @@ following in your .emacs file:
 
 ;;; That's it! ----------------------------------------------------------------
 
-
-;;; --- final chores: provide 'gnuplot and run load-hook
-;; provide before run-hooks suggested by <DB>
 (provide 'gnuplot)
-(run-hooks 'gnuplot-load-hook)
 
 ;; Local Variables:
 ;; indent-tabs-mode: nil
diff --git a/gpelcard.tex b/gpelcard.tex
index 03f88f2ba6..9c8a779108 100644
--- a/gpelcard.tex
+++ b/gpelcard.tex
@@ -322,9 +322,6 @@ the gnuplot buffer.  Excess lines are trimmed.  0 means to 
never trim.}
 \variable{gnuplot-mode-hook}{nil}{Functions run when gnuplot minor
   mode is entered.}
 %
-\variable{gnuplot-load-hook}{nil}{Functions run when gnuplot.el is
-  first loaded.}
-%
 \variable{gnuplot-after-plot-hook}{nil}{Functions run after gnuplot
   plots an entire buffer.  See the doc string for
   \texttt{gnuplot-recently-sent}.}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]