From 4f453c28c4b007693ab8c477fb4c4459d3f63148 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Fri, 24 Apr 2026 18:46:59 +0200 Subject: [PATCH] update gnuplot --- .../gnuplot-autoloads.el | 169 - elpa/gnuplot-20250724.1531/dir | 18 + .../gnuplot-autoloads.el | 90 + .../gnuplot-context.el | 478 +- elpa/gnuplot-20250724.1531/gnuplot-eldoc.el | 631 + .../gnuplot-gui.el | 310 +- .../gnuplot-pkg.el | 9 +- .../gnuplot.el | 1329 +- elpa/gnuplot-20250724.1531/gnuplot.info | 26562 ++++++++++++++++ 9 files changed, 28205 insertions(+), 1391 deletions(-) delete mode 100644 elpa/gnuplot-20240914.1522/gnuplot-autoloads.el create mode 100644 elpa/gnuplot-20250724.1531/dir create mode 100644 elpa/gnuplot-20250724.1531/gnuplot-autoloads.el rename elpa/{gnuplot-20240914.1522 => gnuplot-20250724.1531}/gnuplot-context.el (84%) create mode 100644 elpa/gnuplot-20250724.1531/gnuplot-eldoc.el rename elpa/{gnuplot-20240914.1522 => gnuplot-20250724.1531}/gnuplot-gui.el (90%) rename elpa/{gnuplot-20240914.1522 => gnuplot-20250724.1531}/gnuplot-pkg.el (66%) rename elpa/{gnuplot-20240914.1522 => gnuplot-20250724.1531}/gnuplot.el (67%) create mode 100644 elpa/gnuplot-20250724.1531/gnuplot.info diff --git a/elpa/gnuplot-20240914.1522/gnuplot-autoloads.el b/elpa/gnuplot-20240914.1522/gnuplot-autoloads.el deleted file mode 100644 index 87425afa..00000000 --- a/elpa/gnuplot-20240914.1522/gnuplot-autoloads.el +++ /dev/null @@ -1,169 +0,0 @@ -;;; gnuplot-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- -;; Generated by the `loaddefs-generate' function. - -;; This file is part of GNU Emacs. - -;;; Code: - -(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) - - - -;;; Generated autoloads from gnuplot.el - -(autoload 'gnuplot-mode "gnuplot" "\ -Major mode for editing and executing GNUPLOT scripts. -This was written with version 4.6 of gnuplot in mind, but should -work with newer and older versions. - -Report bugs at https://github.com/emacs-gnuplot/gnuplot/issues - - ------O------ - -Gnuplot-mode includes two different systems for keyword -completion and documentation lookup: a newer one, -`gnuplot-context-sensitive-mode' (enabled by default), and a -older one which extracts keywords from gnuplot's Info file. Both -systems allow looking up documentation in the Info file. The -older system also depends having the info file properly installed -to make a list of keywords. - -The info file should be installed by default with the Gnuplot -distribution, or is available at the `gnuplot-mode' web page: -https://github.com/emacs-gnuplot/gnuplot/ - -With the new context-sensitive mode active, `gnuplot-mode' can also -provide function/`eldoc-mode' syntax hints as you type. This requires a -separate file of strings, `gnuplot-eldoc.el', which is also -provided by recent Gnuplot distributions. - - ------O------ - -There are several known shortcomings of `gnuplot-mode', version 0.5g -and up. Many of the shortcomings involve the graphical interface -(refered to as the GUI) to setting arguments to plot options. Here is -a list: - - 1. Currently there is no way for `gnuplot-mode' to know if information - sent to gnuplot was correctly plotted. - 2. \"plot\", \"splot\", and \"fit\" are handled in the GUI, but are - a bit flaky. Their arguments may not be read correctly from - existing text, and continuation lines (common for plot and splot) - are not supported. - 3. The GUI does not know how to read from continuation lines. - 4. Comma separated position arguments to plot options are - unsupported in the GUI. Colon separated datafile modifiers (used - for plot, splot, and fit) are not supported either. Arguments - not yet supported by the GUI generate messages printed in grey - text. - 5. The GUI handling of \"hidden3d\" is flaky and \"cntrparam\" is - unsupported. - - ------O------ - - Key bindings: - \\{gnuplot-mode-map}" t) -(autoload 'gnuplot-make-buffer "gnuplot" "\ -Open a new buffer in `gnuplot-mode'. -When invoked, it switches to a new, empty buffer visiting no file -and then starts `gnuplot-mode'. - -It is convenient to bind this function to a global key sequence. For -example, to make the F10 key open a gnuplot script buffer, put the -following in your .emacs file: - (autoload \\='gnuplot-make-buffer \"gnuplot\" - \"open a buffer in gnuplot mode\" t) - (global-set-key [(f10)] \\='gnuplot-make-buffer)" t) -(autoload 'run-gnuplot "gnuplot" "\ -Run an inferior Gnuplot process." t) -(register-definition-prefixes "gnuplot" '("gnuplot-")) - - -;;; Generated autoloads from gnuplot-context.el - -(autoload 'gnuplot-context-sensitive-mode "gnuplot-context" "\ -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. - -This is a minor mode. If called interactively, toggle the -`Gnuplot-Context-Sensitive mode' mode. If the prefix argument is -positive, enable the mode, and if it is zero or negative, disable the -mode. - -If called from Lisp, toggle the mode if ARG is `toggle'. Enable the -mode if ARG is nil, omitted, or is a positive number. Disable the mode -if ARG is a negative number. - -To check whether the minor mode is enabled in the current buffer, -evaluate the variable `gnuplot-context-sensitive-mode'. - -The mode's hook is called both when the mode is enabled and when it is -disabled. - -(fn &optional ARG)" t) -(register-definition-prefixes "gnuplot-context" '("gnuplot-")) - - -;;; Generated autoloads from gnuplot-gui.el - -(autoload 'gnuplot-gui-swap-simple-complete "gnuplot-gui" nil t) -(autoload 'gnuplot-gui-mouse-set "gnuplot-gui" "\ -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. - -(fn EVENT)" t) -(autoload 'gnuplot-gui-set-options-and-insert "gnuplot-gui" "\ -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." t) -(autoload 'gnuplot-gui-toggle-popup "gnuplot-gui" nil t) -(register-definition-prefixes "gnuplot-gui" '("gnuplot-")) - -;;; End of scraped data - -(provide 'gnuplot-autoloads) - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; no-native-compile: t -;; coding: utf-8-emacs-unix -;; End: - -;;; gnuplot-autoloads.el ends here diff --git a/elpa/gnuplot-20250724.1531/dir b/elpa/gnuplot-20250724.1531/dir new file mode 100644 index 00000000..37ad9fe4 --- /dev/null +++ b/elpa/gnuplot-20250724.1531/dir @@ -0,0 +1,18 @@ +This is the file .../info/dir, which contains the +topmost node of the Info hierarchy, called (dir)Top. +The first time you invoke Info you start off looking at this node. + +File: dir, Node: Top This is the top of the INFO tree + + This (the Directory node) gives a menu of major topics. + Typing "q" exits, "H" lists all Info commands, "d" returns here, + "h" gives a primer for first-timers, + "mEmacs" visits the Emacs manual, etc. + + In Emacs, you can click mouse button 2 on a menu item or cross reference + to select it. + +* Menu: + +Math +* GNUPLOT: (gnuplot). An Interactive Plotting Program diff --git a/elpa/gnuplot-20250724.1531/gnuplot-autoloads.el b/elpa/gnuplot-20250724.1531/gnuplot-autoloads.el new file mode 100644 index 00000000..88ce31e8 --- /dev/null +++ b/elpa/gnuplot-20250724.1531/gnuplot-autoloads.el @@ -0,0 +1,90 @@ +;;; gnuplot-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + +;;; Code: + +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + + + +;;; Generated autoloads from gnuplot.el + +(autoload 'gnuplot-mode "gnuplot" "\ +Major mode for editing and executing GNUPLOT scripts. +This was written with version 4.6 of gnuplot in mind, but should +work with newer and older versions. + +Report bugs at https://github.com/emacs-gnuplot/gnuplot/issues + + ------O------ + +Gnuplot-mode includes two different systems for keyword completion and +documentation lookup: a newer one, `gnuplot-context-sensitive-mode' , +which is enabled by default, and a older one which extracts keywords +from gnuplot's Info file. Both systems allow looking up documentation +in the Info file. With the context-sensitive mode active, +`gnuplot-mode' can also provide Eldoc syntax hints as you type. + + ------O------ + +There are several known shortcomings of `gnuplot-mode', version 0.5g +and up. Many of the shortcomings involve the graphical interface +(refered to as the GUI) to setting arguments to plot options. Here is +a list: + + 1. Currently there is no way for `gnuplot-mode' to know if information + sent to gnuplot was correctly plotted. + 2. \"plot\", \"splot\", and \"fit\" are handled in the GUI, but are + a bit flaky. Their arguments may not be read correctly from + existing text, and continuation lines (common for plot and splot) + are not supported. + 3. The GUI does not know how to read from continuation lines. + 4. Comma separated position arguments to plot options are + unsupported in the GUI. Colon separated datafile modifiers (used + for plot, splot, and fit) are not supported either. Arguments + not yet supported by the GUI generate messages printed in grey + text. + 5. The GUI handling of \"hidden3d\" is flaky and \"cntrparam\" is + unsupported. + +(fn)" t) +(autoload 'gnuplot-make-buffer "gnuplot" "\ +Open a new buffer in `gnuplot-mode'. +When invoked, it switches to a new, empty buffer visiting no file +and then starts `gnuplot-mode'. + +It is convenient to bind this function to a global key sequence. For +example, to make the F10 key open a gnuplot script buffer, put the +following in your .emacs file: + (global-set-key [(f10)] \\='gnuplot-make-buffer)" t) +(autoload 'run-gnuplot "gnuplot" "\ +Run an inferior Gnuplot process." t) +(add-to-list 'auto-mode-alist '("\\.gp\\'" . gnuplot-mode)) +(add-to-list 'interpreter-mode-alist '("gnuplot" . gnuplot-mode)) +(register-definition-prefixes "gnuplot" '("gnuplot-")) + + +;;; Generated autoloads from gnuplot-context.el + +(register-definition-prefixes "gnuplot-context" '("gnuplot-context-")) + + +;;; Generated autoloads from gnuplot-gui.el + +(register-definition-prefixes "gnuplot-gui" '("gnuplot-gui-")) + +;;; End of scraped data + +(provide 'gnuplot-autoloads) + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; no-native-compile: t +;; coding: utf-8-emacs-unix +;; End: + +;;; gnuplot-autoloads.el ends here diff --git a/elpa/gnuplot-20240914.1522/gnuplot-context.el b/elpa/gnuplot-20250724.1531/gnuplot-context.el similarity index 84% rename from elpa/gnuplot-20240914.1522/gnuplot-context.el rename to elpa/gnuplot-20250724.1531/gnuplot-context.el index 6b49ea78..25831a61 100644 --- a/elpa/gnuplot-20240914.1522/gnuplot-context.el +++ b/elpa/gnuplot-20250724.1531/gnuplot-context.el @@ -2,8 +2,7 @@ ;; Copyright (C) 2012-2013 Jon Oddie -;; Author: Jon Oddie -;; URL: https://github.com/emacs-gnuplot/gnuplot +;; Author: Jon Oddie ;; This file is not part of GNU Emacs. @@ -18,7 +17,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . +;; along with this program. If not, see . ;;; Commentary: @@ -41,30 +40,18 @@ ;; ;; Gnuplot's context sensitive mode is best controlled using Customize ;; (M-x customize-group gnuplot): simply enable the -;; `gnuplot-context-sensitive-mode' setting. You may also want to turn -;; on `gnuplot-tab-completion' so that the TAB key does auto-completion -;; on lines which are already indented. (This just sets the Emacs -;; variable `tab-always-indent' to `complete' in Gnuplot buffers). +;; `gnuplot-context-sensitive-mode' setting. You may also want to set +;; the Emacs variable `tab-always-indent' to `complete' so that the +;; TAB key does auto-completion on lines which are already indented. ;; ;; If you need to turn context sensitivity on or off from Lisp code ;; for some reason, call the function ;; `gnuplot-context-sensitive-mode', which behaves like a minor mode. ;; -;; With `eldoc-mode' support, gnuplot-mode will show one-line syntax -;; hints automatically in the echo area. Whether eldoc-mode is active -;; or not, you can always pop up a longer description of syntax using -;; `gnuplot-help-function' (C-c C-/ or C-c M-h). ElDoc support also -;; requires an additional file of help strings, `gnuplot-eldoc.el', -;; which should be included in recent Gnuplot releases. If it didn't -;; come with your Gnuplot installation, you'll need to grab a recent -;; source distribution of Gnuplot from http://gnuplot.info, and use -;; the `doc2texi.el' program in the docs/ directory to create it. So -;; long as the file is on your Emacs load path somewhere it will be -;; loaded automatically when needed. -;; -;; You can customize gnuplot-mode to turn on eldoc mode automatically -;; using variable `gnuplot-eldoc-mode'. Simply calling `eldoc-mode' -;; will also work. +;; With `eldoc-mode' support, `gnuplot-mode' will show one-line syntax +;; hints automatically in the echo area. Whether `eldoc-mode' is +;; active or not, you can always pop up a longer description of syntax +;; using `gnuplot-context-help-at-point' (C-c C-/ or C-c M-h). ;; ;; Internal details ;; ================ @@ -74,20 +61,22 @@ ;; features was to do a complete parse of the command line. So that's ;; what this package does. Instead of building a parse tree, it ;; matches up until the token at point, and then either makes a list -;; of possible completions, or sets the variables `gnuplot-eldoc' and -;; `gnuplot-info-at-point' based on where it is in the grammar at that -;; point. +;; of possible completions, or sets the variables +;; `gnuplot-context--eldoc' and `gnuplot-context--info-at-point' based +;; on where it is in the grammar at that point. ;; ;; The parsing/matching process happens in two phases: tokenizing -;; (`gnuplot-tokenize') and matching (`gnuplot-match-pattern'). In -;; order to be able to construct a full list of possible completions -;; via backtracking, the matching algorithm simulates a simple stack -;; machine with continuations. At byte-compile time, the PEG-like -;; grammar in S-expression notation (`gnuplot-grammar') is compiled -;; down into a vector of "machine code" for the parsing machine (see -;; `gnuplot-compile-pattern', `gnuplot-compile-grammar' and -;; `gnuplot-compiled-grammar'). This is complicated, but it seems to -;; work well enough, and it saves on the Emacs call stack. +;; (`gnuplot-context--tokenize') and matching +;; (`gnuplot-context--match-pattern'). In order to be able to +;; construct a full list of possible completions via backtracking, the +;; matching algorithm simulates a simple stack machine with +;; continuations. At byte-compile time, the PEG-like grammar in +;; S-expression notation (`gnuplot-grammar') is compiled down into a +;; vector of "machine code" for the parsing machine (see +;; `gnuplot-context--compile-pattern', +;; `gnuplot-context--compile-grammar' and +;; `gnuplot-context--compiled-grammar'). This is complicated, but it +;; seems to work well enough, and it saves on the Emacs call stack. ;; ;; Compiling the grammar does require increasing `max-lisp-eval-depth' ;; modestly. This shouldn't cause any problems on modern machines, and @@ -95,14 +84,14 @@ ;; ;; The parsing machine and compiler are partially based on the ;; description in Medeiros and Ierusalimschy 2008, "A Parsing Machine -;; for PEGs" (http://dl.acm.org/citation.cfm?doid=1408681.1408683). +;; for PEGs" (https://dl.acm.org/citation.cfm?doid=1408681.1408683). ;; ;; The pattern-matching language ;; ============================= ;; -;; The gnuplot-mode grammar (see `gnuplot-compiled-grammar') is a list -;; of rules (RULE PATTERN), with each pattern written in S-expression -;; notation as follows: +;; The gnuplot-mode grammar (see `gnuplot-context--compiled-grammar') +;; is a list of rules (RULE PATTERN), with each pattern written in +;; S-expression notation as follows: ;; ;; any ;; Match any token @@ -166,8 +155,8 @@ ;; ;; (capture NAME PATTERN) ;; Match PATTERN, capturing the tokens in a capture group named -;; NAME. Capture groups are stored in `gnuplot-captures' -;; and can be retrieved using `gnuplot-capture-group'. This is +;; NAME. Capture groups are stored in `gnuplot-context--captures' +;; and can be retrieved using `gnuplot-context--capture-group'. This is ;; used to store the plotting style, which we need in order to ;; give the correct ElDoc string for "using" clauses, and for ;; info keywords (see below) @@ -192,7 +181,7 @@ ;; Evaluate LISP-FORM and fail if it returns NIL. We need this in ;; the patterns for "plot" and "splot" to check whether the ;; command at point should be parsed in parametric mode or -;; not. See `gnuplot-guess-parametric-p'. +;; not. See `gnuplot-context--guess-parametric-p'. ;; ;; ;; Bugs, TODOs, etc. @@ -229,22 +218,21 @@ ;;; Code: -(require 'cl-lib) (require 'gnuplot) -(require 'eldoc) -(require 'info) -(require 'info-look) +(require 'gnuplot-eldoc) ;;;; The tokenizer. -(cl-defstruct gnuplot-token +(cl-defstruct (gnuplot-context--token + (:constructor gnuplot-context--token-make) + (:copier nil)) start ; Buffer start position end ; Buffer end position id ; Text type) ; a symbol: name, number, string, operator, separator -(defvar gnuplot-operator-regexp +(defvar gnuplot-context--operator-regexp (eval-when-compile (regexp-opt '("(" ")" "(" ")" "{" "," "}" "[" ":" "]" "!" "**" "-" "+" "~" "!" "*" "/" @@ -253,7 +241,7 @@ "Regexp to match Gnuplot operators for tokenizing.") (eval-when-compile - (defmacro gnuplot-tokenize-by-regexps (&rest rules) + (defmacro gnuplot-context--tokenize-by-regexps (&rest rules) `(cond ,@(mapcar (lambda (rule) (let ((regexp (car rule)) @@ -261,27 +249,27 @@ `((looking-at ,regexp) (let ((str (match-string-no-properties 0))) (forward-char (length str)) - (make-gnuplot-token :id str - :type ',token-type - :start (match-beginning 0) - :end (match-end 0)))))) + (gnuplot-context--token-make :id str + :type ',token-type + :start (match-beginning 0) + :end (match-end 0)))))) rules)))) -(defun gnuplot-tokenize (&optional completing-p) +(defun gnuplot-context--tokenize (&optional completing-p) "Tokenize the Gnuplot command at point. -Return a list of `gnuplot-token' objects. +Return a list of `gnuplot-context--token' objects. If COMPLETING-P is non-nil, omits the token at point if it is a name; otherwise continues tokenizing up to the token at point. FIXME." (let ((tokens '()) (stop-point (min (point) - (gnuplot-point-at-end-of-command)))) + (gnuplot--point-at-end-of-command)))) (save-excursion (if (save-excursion ; HACK FIXME - (gnuplot-beginning-of-continuation) + (gnuplot--beginning-of-continuation) (looking-at "\\s-*if\\s-*(")) - (gnuplot-beginning-of-continuation) - (gnuplot-beginning-of-command)) + (gnuplot--beginning-of-continuation) + (gnuplot--beginning-of-command)) (while ;; Skip whitespace and continuation lines (progn @@ -295,23 +283,23 @@ name; otherwise continues tokenizing up to the token at point. FIXME." (let* ((from (point)) (token (cond - ((gnuplot-tokenize-by-regexps + ((gnuplot-context--tokenize-by-regexps ("[[:alpha:]_][[:alpha:]0-9_]*" name) ("[0-9]+\\(\\.[0-9]*\\)?\\([eE][+-]?[0-9]+\\)?\\|\\.[0-9]+\\([eE][+-]?[0-9]+\\)?" number) - (gnuplot-operator-regexp operator) + (gnuplot-context--operator-regexp operator) (";" separator))) ((looking-at "['\"]") (let* ((bounds (bounds-of-thing-at-point 'sexp)) (to (or (cdr bounds) stop-point))) (goto-char to) - (make-gnuplot-token + (gnuplot-context--token-make :id (buffer-substring-no-properties from to) :type 'string :start from :end to))) (t (error - "Gnuplot-tokenize: bad token beginning %s" + "gnuplot-context--tokenize: bad token beginning %s" (buffer-substring-no-properties (point) stop-point)))))) (push token tokens)))) @@ -323,19 +311,18 @@ name; otherwise continues tokenizing up to the token at point. FIXME." ;; in that position for completion. (if (and completing-p tokens - (eq (gnuplot-token-type (car tokens)) 'name) - (<= (point) (gnuplot-token-end (car tokens)))) + (eq (gnuplot-context--token-type (car tokens)) 'name) + (<= (point) (gnuplot-context--token-end (car tokens)))) (pop tokens)) (nreverse tokens))) - ;;;; The pattern and grammar compiler ;; ;; These functions compile the source S-expression grammar into a ;; vector of instructions for the parsing machine, -;; `gnuplot-match-pattern'. Its state consists of a program counter +;; `gnuplot-context--match-pattern'. Its state consists of a program counter ;; (PC), a position in the list of tokens, a call stack, and a second ;; stack of backtracking entries (continuations). Its "machine ;; instructions" are the following: @@ -344,15 +331,15 @@ name; otherwise continues tokenizing up to the token at point. FIXME." ;; Match any token (fails only at end of command). ;; ;; (literal LITERAL NO-COMPLETE) -;; Match token with `gnuplot-token-id' LITERAL or fail. If we +;; Match token with `gnuplot-context--token-id' LITERAL or fail. If we ;; have reached the token before point, include LITERAL in the ;; completion list unless NO-COMPLETE is non-`nil'. ;; ;; (token-type TYPE) -;; Match a token with `gnuplot-token-type' TYPE, or fail. +;; Match a token with `gnuplot-context--token-type' TYPE, or fail. ;; ;; (keyword REGEXP NAME) -;; Match any token whose `gnuplot-token-id' matches REGEXP. Use +;; Match any token whose `gnuplot-context--token-id' matches REGEXP. Use ;; NAME for the completion list. ;; ;; (jump OFFSET FIXED) @@ -404,12 +391,12 @@ name; otherwise continues tokenizing up to the token at point. FIXME." ;; ;; (save-start NAME) ;; Open a capture group named NAME. Pushes an entry onto -;; `gnuplot-captures' with current position in token list as the +;; `gnuplot-context--captures' with current position in token list as the ;; start of the group. ;; ;; (save-end NAME) ;; Close the capture group named NAME. Finds the topmost entry in -;; `gnuplot-captures' with this name and sets its endpoint to the +;; `gnuplot-context--captures' with this name and sets its endpoint to the ;; current position in token list. Error if no group with that ;; name is found. ;; @@ -419,13 +406,12 @@ name; otherwise continues tokenizing up to the token at point. FIXME." ;; for debugging purposes. ;; - (eval-and-compile ;; Compile a single pattern into a list of instructions. Leaves ;; calls to other rules as symbolic instructions (call SYMBOL) and ;; jumps, commits etc. as relative offsets; these are resolved into - ;; absolute locations by `gnuplot-compile-grammar', below. - (defun gnuplot-compile-pattern (pat) + ;; absolute locations by `gnuplot-context--compile-grammar', below. + (defun gnuplot-context--compile-pattern (pat) (cond ;; Strings match a single token literally ((stringp pat) @@ -442,7 +428,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME." ;; Syntactic sugar: write sequences (sequence ...) as vectors [...] ((vectorp pat) - (gnuplot-compile-pattern + (gnuplot-context--compile-pattern (append '(sequence) pat '()))) ;; Other forms combine simpler patterns @@ -454,11 +440,11 @@ name; otherwise continues tokenizing up to the token at point. FIXME." ((sequence) (cl-destructuring-bind (subpats eldoc info) - (gnuplot-filter-arg-list (cdr pat)) + (gnuplot-context--filter-arg-list (cdr pat)) (let ((eldoc-push '()) (eldoc-pop '()) (info-push '()) (info-pop '()) (compiled - (mapcar 'gnuplot-compile-pattern subpats))) + (mapcar 'gnuplot-context--compile-pattern subpats))) (if eldoc (setq eldoc-push `((push eldoc ,eldoc)) eldoc-pop `((pop eldoc)))) @@ -479,16 +465,16 @@ name; otherwise continues tokenizing up to the token at point. FIXME." ((either) (cond ((= (length pat) 2) ; trivial case - (gnuplot-compile-pattern (cadr pat))) + (gnuplot-context--compile-pattern (cadr pat))) ((> (length pat) 3) ; could be more efficient... - (gnuplot-compile-pattern (gnuplot-either-helper pat))) + (gnuplot-context--compile-pattern (gnuplot-context--either-helper pat))) (t ; two patterns (let* ((pat1 (cadr pat)) (pat2 (cl-caddr pat)) - (pat1-c (gnuplot-compile-pattern pat1)) - (pat2-c (gnuplot-compile-pattern pat2)) + (pat1-c (gnuplot-context--compile-pattern pat1)) + (pat2-c (gnuplot-context--compile-pattern pat2)) (pat1-l (length pat1-c)) (pat2-l (length pat2-c))) `((choice ,(+ pat1-l 2)) @@ -499,7 +485,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME." ;; Repetition (*) ((many) (let* ((pat1 (cons 'sequence (cdr pat))) - (pat1-c (gnuplot-compile-pattern pat1)) + (pat1-c (gnuplot-context--compile-pattern pat1)) (pat1-l (length pat1-c))) `((choice ,(+ pat1-l 3)) (check-progress) ; bail out of infinite loops @@ -509,14 +495,13 @@ name; otherwise continues tokenizing up to the token at point. FIXME." ;; Repetition (+) ((many1) (let* ((pat1 (cdr pat))) - (gnuplot-compile-pattern + (gnuplot-context--compile-pattern `(sequence ,@pat1 (many ,@pat1))))) - ;; Optional (?) ((maybe) (let* ((pat1 (cons 'sequence (cdr pat))) - (pat1-c (gnuplot-compile-pattern pat1)) + (pat1-c (gnuplot-context--compile-pattern pat1)) (pat1-l (length pat1-c))) `((choice ,(+ pat1-l 1)) ,@pat1-c))) @@ -525,20 +510,20 @@ name; otherwise continues tokenizing up to the token at point. FIXME." ((delimited-list) (let* ((item (cadr pat)) (sep (cl-caddr pat))) - (gnuplot-compile-pattern + (gnuplot-context--compile-pattern `(sequence ,item (many (sequence ,sep ,item)))))) ;; keywords ((kw) (cl-destructuring-bind (regex name) - (gnuplot-keyword-helper (cdr pat)) + (gnuplot-context--keyword-helper (cdr pat)) `((keyword ,regex ,name)))) ;; Capturing groups ((capture) (let* ((name (cadr pat)) (pat1 (cons 'sequence (cddr pat))) - (pat1-c (gnuplot-compile-pattern pat1))) + (pat1-c (gnuplot-context--compile-pattern pat1))) `((save-start ,name) ,@pat1-c (save-end ,name)))) @@ -546,7 +531,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME." ;; Use the first token as an info keyword ((info-keyword) (let* ((pat1 (cons 'sequence (cdr pat))) - (pat1-c (gnuplot-compile-pattern pat1))) + (pat1-c (gnuplot-context--compile-pattern pat1))) `((push info first-token) ,@pat1-c (pop info)))) @@ -557,12 +542,12 @@ name; otherwise continues tokenizing up to the token at point. FIXME." `((assert ,form)))) (t - (error "Gnuplot-compile-pattern: bad pattern form %s" pat))))))) + (error "gnuplot-context--compile-pattern: bad pattern form %s" pat))))))) ;; Helper function for destructuring (sequence ...) forms in patterns ;; Takes the cdr of the sequence form, returns a list (PATTERNS ELDOC ;; INFO). - (defun gnuplot-filter-arg-list (args) + (defun gnuplot-context--filter-arg-list (args) (let ((accum '()) (eldoc nil) (info nil)) (dolist (item args) @@ -576,7 +561,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME." ;; Helper function for compiling (kw...) patterns ;; Takes the cdr of the kw form, returns a list (REGEXP KEYWORD) - (defun gnuplot-keyword-helper (args) + (defun gnuplot-context--keyword-helper (args) (let ((keyword (car args)) (aliases (cdr args))) (when (consp keyword) (let ((pre (car keyword)) (suf (cdr keyword))) @@ -594,18 +579,18 @@ name; otherwise continues tokenizing up to the token at point. FIXME." ;; Helper function for compiling (either ...) patterns. Rewrites ;; alternates (either A B C) into (either A (either B (either C D))) - (defun gnuplot-either-helper (pat) + (defun gnuplot-context--either-helper (pat) (if (= (length pat) 3) pat `(either ,(cadr pat) - ,(gnuplot-either-helper + ,(gnuplot-context--either-helper (cons 'either (cddr pat)))))) ;; Compile the grammar (a list of rule-pattern pairs (RULE PATTERN)) ;; into a single vector of matching-machine instructions. Compiles ;; each pattern individually, then "links" them into one vector, ;; converting symbolic (call ...) instructions into numeric offsets - (defun gnuplot-compile-grammar (grammar start-symbol) + (defun gnuplot-context--compile-grammar (grammar start-symbol) (let ((compiled-pats '()) ; Alist of (name . instructions) ;; Reserve space for a jump to the start symbol (code-length 1)) @@ -614,7 +599,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME." (dolist (item grammar) (let* ((name (car item)) (pat (cadr item)) - (code (gnuplot-compile-pattern pat))) + (code (gnuplot-context--compile-pattern pat))) (push (cons name code) compiled-pats) ;; Reserve space for a label at the beginning and (return) at ;; the end @@ -653,7 +638,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME." (location (gethash name name->offset))) (if (not location) (error - (concat "gnuplot-compile-grammar: " + (concat "gnuplot-context--compile-grammar: " "No rule found for symbol `%s' in pattern `%s'") name pattern-name)) (setcdr inst `(,location ,name)))) @@ -664,14 +649,14 @@ name; otherwise continues tokenizing up to the token at point. FIXME." (setcdr inst `(,location)))) (t - (error "Gnuplot-compile-grammar: bad instruction %s" inst)))))))) + (error "gnuplot-context--compile-grammar: bad instruction %s" inst)))))))) object-code)))) ;;; The grammar. -(defvar gnuplot-compiled-grammar +(defvar gnuplot-context--compiled-grammar (eval-when-compile (let ((max-lisp-eval-depth 600)) - (gnuplot-compile-grammar + (gnuplot-context--compile-grammar '((expression [infix-expression (maybe "?" expression ":" expression)]) @@ -781,7 +766,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME." (either ;; Parametric ranges - [(assert (gnuplot-guess-parametric-p)) + [(assert (gnuplot-context--guess-parametric-p)) (maybe t-axis-range) (maybe x-axis-range) (maybe y-axis-range)] ;; Non-parametric ranges @@ -790,13 +775,13 @@ name; otherwise continues tokenizing up to the token at point. FIXME." plot-body]) (splot-command - [ ;; This capturing group lets `gnuplot-find-using-eldoc' know + [ ;; This capturing group lets `gnuplot-context--find-using-eldoc' know ;; that this is an splot command (capture :splot-command (kw ("spl" . "ot"))) (either ;; Parametric ranges - [(assert (gnuplot-guess-parametric-p)) + [(assert (gnuplot-context--guess-parametric-p)) (maybe u-axis-range) (maybe v-axis-range) (maybe x-axis-range) (maybe y-axis-range) (maybe z-axis-range)] @@ -1007,7 +992,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME." [(kw "thru") expression]) (using-modifier - [(:eldoc gnuplot-find-using-eldoc) + [(:eldoc gnuplot-context--find-using-eldoc) (kw ("u" . "sing")) (either string @@ -1660,7 +1645,6 @@ name; otherwise continues tokenizing up to the token at point. FIXME." "zzeroaxis") (maybe linestyle-spec)]) - ;;; Other commands (cd-command ["cd" string]) @@ -1720,58 +1704,52 @@ 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 _) "No-op." '(progn nil)) - (defmacro gnuplot-trace (&rest _) "No-op." '(progn nil)) - (defmacro gnuplot-debug (&rest _) "No-op." '(progn nil)))) - + (defmacro gnuplot-context--with-trace-buffer (&rest _) "No-op." '(progn nil)) + (defmacro gnuplot-context--trace (&rest _) "No-op." '(progn nil)) + (defmacro gnuplot-context--debug (&rest _) "No-op." '(progn nil)))) ;;;; Variables to be set via pattern matching -(defvar gnuplot-completions nil +(defvar gnuplot-context--completions nil "List of possible `gnuplot-mode' completions at point. -This is filled in by `gnuplot-match-pattern' when it reaches the +This is filled in by `gnuplot-context--match-pattern' when it reaches the token before point.") -(defvar gnuplot-info-at-point nil +(defvar gnuplot-context--info-at-point nil "Relevant page of the Gnuplot info manual for the construction at point. -Set by `gnuplot-match-pattern' using information from -`gnuplot-compiled-grammar'. `gnuplot-match-pattern' pushes ElDoc -and info strings onto the stack as it runs, and scans the stack -for the topmost entry when it reaches the token at point.") - -(defvar gnuplot-eldoc nil - "ElDoc documentation string for the Gnuplot construction at point. - -Set by `gnuplot-match-pattern'. See also `gnuplot-info-at-point'.") +Set by `gnuplot-context--match-pattern' using information from +`gnuplot-context--compiled-grammar'. `gnuplot-context--match-pattern' +pushes ElDoc and info strings onto the stack as it runs, and scans the +stack for the topmost entry when it reaches the token at point.") -(defvar gnuplot-captures nil +(defvar gnuplot-context--captures nil "Alist of named capture groups for `gnuplot-mode' completion code. Each entry is of the form (NAME BEGIN END), where NAME is the name specified in the (capture NAME PATTERN) form in the -`gnuplot-compiled-grammar' source, BEGIN is the tail of the token +`gnuplot-context--compiled-grammar' source, BEGIN is the tail of the token 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'. +(defvar gnuplot-context--eldoc nil + "ElDoc documentation string for the Gnuplot construction at point. -These have to be compiled from the Gnuplot source tree using -`doc2texi.el'.") +Set by `gnuplot-context--match-pattern'. See also +`gnuplot-context-info-at-point'.") ;;;; The pattern matching machine -(defun gnuplot-match-pattern (instructions tokens completing-p - &optional start-symbol) +(defun gnuplot-context--match-pattern (instructions tokens completing-p + &optional start-symbol) "Parse TOKENS, setting completions, info and ElDoc information. This function parses TOKENS by simulating a stack machine with unlimited backtracking. If COMPLETING-P is non-nil, it stops before the token at point and collects a list of the next tokens -that it would accept in `gnuplot-completions'. If COMPLETING-P is -nil, it parses up to the token at point and sets `gnuplot-eldoc' -and `gnuplot-info-at-point' based on the contents of the stack +that it would accept in `gnuplot-context--completions'. If COMPLETING-P is +nil, it parses up to the token at point and sets `gnuplot-context--eldoc' +and `gnuplot-context--info-at-point' based on the contents of the stack there." (catch 'return (let ((pc 0) ; Program counter @@ -1789,7 +1767,7 @@ there." ;; of conses (pc . tokens) (progress '())) - (with-gnuplot-trace-buffer (erase-buffer)) + (gnuplot-context--with-trace-buffer (erase-buffer)) (when start-symbol ; HACK FIXME (let ((look-for `(label ,start-symbol))) @@ -1797,17 +1775,17 @@ there." (cl-incf pc)) (cl-incf pc))) - (setq gnuplot-completions nil - gnuplot-eldoc nil - gnuplot-info-at-point nil - gnuplot-captures nil) + (setq gnuplot-context--completions nil + gnuplot-context--eldoc nil + gnuplot-context--info-at-point nil + gnuplot-context--captures nil) (cl-flet ((advance - () - (pop tokens) - (if (and (null tokens) (not completing-p)) - (gnuplot-scan-stack stack tokens))) - (fail () (setq fail t))) + () + (pop tokens) + (if (and (null tokens) (not completing-p)) + (gnuplot-context--scan-stack stack tokens))) + (fail () (setq fail t))) ;; Main loop (while t @@ -1815,7 +1793,7 @@ there." (opcode (car inst)) (token (car tokens)) (end-of-tokens (null tokens))) - (gnuplot-trace "%s\t%s\t%s\n" pc inst (and token (gnuplot-token-id token))) + (gnuplot-context--trace "%s\t%s\t%s\n" pc inst (and token (gnuplot-context--token-id token))) (cl-case opcode ;; (literal LITERAL NO-COMPLETE) @@ -1824,11 +1802,11 @@ there." (no-complete (cl-caddr inst))) (cond (end-of-tokens (unless no-complete - (gnuplot-trace "\tpushing \"%s\" to completions\n" expect) - (push expect gnuplot-completions)) + (gnuplot-context--trace "\tpushing \"%s\" to completions\n" expect) + (push expect gnuplot-context--completions)) (fail)) - ((not (equal (gnuplot-token-id token) expect)) + ((not (equal (gnuplot-context--token-id token) expect)) (fail)) ;; otherwise succeed @@ -1838,7 +1816,7 @@ there." ((token-type) (let ((expect (cadr inst))) (if (or end-of-tokens - (not (eq (gnuplot-token-type token) expect))) + (not (eq (gnuplot-context--token-type token) expect))) (fail) (advance)))) @@ -1848,16 +1826,16 @@ there." (let ((regexp (cadr inst)) (name (cl-caddr inst))) (cond (end-of-tokens - (gnuplot-trace "\tpushing \"%s\" to completions\n" name) - (push name gnuplot-completions) + (gnuplot-context--trace "\tpushing \"%s\" to completions\n" name) + (push name gnuplot-context--completions) (fail)) - ((not (string-match-p regexp (gnuplot-token-id token))) + ((not (string-match-p regexp (gnuplot-context--token-id token))) (fail)) ;; otherwise succeed (t - (setf (gnuplot-token-id token) name) + (setf (gnuplot-context--token-id token) name) (advance))))) ;; (any): match any token @@ -1896,7 +1874,7 @@ there." ;; backtracking points and continue at next instruction ((choice) (let ((location (cadr inst))) - (push `(,stack ,tokens ,location ,gnuplot-captures + (push `(,stack ,tokens ,location ,gnuplot-context--captures ,progress) backtrack))) @@ -1938,17 +1916,17 @@ there." ;; beginning of capture group NAME ((save-start) (let ((name (cadr inst))) - (push `(,name ,tokens nil) gnuplot-captures))) + (push `(,name ,tokens nil) gnuplot-context--captures))) ;; (save-end NAME): save current token pointer as end of ;; capture group NAME ((save-end) (let* ((name (cadr inst)) - (record (assoc name gnuplot-captures))) + (record (assoc name gnuplot-context--captures))) (if (not record) (error "Gnuplot-match-tokens: no open capture group named %s" name) (setf (cl-caddr record) tokens) - (gnuplot-debug (gnuplot-dump-captures))))) + (gnuplot-context--debug (gnuplot-dump-captures))))) ;; (check-progress): make sure not stuck in an infinite loop ((check-progress) @@ -1968,12 +1946,12 @@ there." (when fail (if (not backtrack) ; Out of backtracking stack: failed match (throw 'return nil) - (gnuplot-trace "\t*fail*\t%s\n" (length backtrack)) - (gnuplot-debug (gnuplot-dump-backtrack backtrack)) + (gnuplot-context--trace "\t*fail*\t%s\n" (length backtrack)) + (gnuplot-context--debug (gnuplot-dump-backtrack backtrack)) ;; If we got as far as token-at-point before failing, ;; scan the stack for eldoc and info strings (when (and end-of-tokens (not completing-p)) - (gnuplot-scan-stack stack tokens)) + (gnuplot-context--scan-stack stack tokens)) (cl-destructuring-bind (bt-stack bt-tokens bt-pc bt-captures bt-progress) @@ -1981,20 +1959,20 @@ there." (setq stack bt-stack tokens bt-tokens pc bt-pc - gnuplot-captures bt-captures + gnuplot-context--captures bt-captures progress bt-progress fail nil) - (gnuplot-debug (gnuplot-dump-progress progress))))))))))) + (gnuplot-context--debug (gnuplot-dump-progress progress))))))))))) -(defun gnuplot-scan-stack (stack tokens) +(defun gnuplot-context--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 stack)) - (gnuplot-debug (gnuplot-dump-captures)) + (gnuplot-context--trace "\t* scanning stack *\n") + (gnuplot-context--debug (gnuplot-backtrace stack)) + (gnuplot-context--debug (gnuplot-dump-captures)) (catch 'no-scan (while (and stack - (not (and gnuplot-info-at-point gnuplot-eldoc))) + (not (and gnuplot-context--info-at-point gnuplot-context--eldoc))) (let* ((item (car stack)) (type (car item)) (position (cl-caddr item))) ; must progress by at least one token @@ -2005,34 +1983,34 @@ there." (throw 'no-scan nil)) ((info) - (when (not gnuplot-info-at-point) + (when (not gnuplot-context--info-at-point) (let ((info (cadr item))) - (setq gnuplot-info-at-point + (setq gnuplot-context--info-at-point (cond ((eq info 'first-token) - (gnuplot-token-id (car position))) + (gnuplot-context--token-id (car position))) ((functionp info) (funcall info)) (t info))) - (when gnuplot-info-at-point - (gnuplot-trace "\tset info to \"%s\"\n" gnuplot-info-at-point) - (when (and (not gnuplot-eldoc) gnuplot-eldoc-hash) + (when gnuplot-context--info-at-point + (gnuplot-context--trace "\tset info to \"%s\"\n" gnuplot-context--info-at-point) + (unless gnuplot-context--eldoc (let ((eldoc - (car (gethash gnuplot-info-at-point gnuplot-eldoc-hash)))) + (car (gethash gnuplot-context--info-at-point gnuplot-eldoc-hash)))) (when eldoc - (setq gnuplot-eldoc eldoc) - (gnuplot-trace "\tand set eldoc to \"%s\"\n" eldoc)))))))) + (setq gnuplot-context--eldoc eldoc) + (gnuplot-context--trace "\tand set eldoc to \"%s\"\n" eldoc)))))))) ((eldoc) - (when (not gnuplot-eldoc) + (when (not gnuplot-context--eldoc) (let ((eldoc (cadr item))) - (setq gnuplot-eldoc + (setq gnuplot-context--eldoc (if (functionp eldoc) (funcall eldoc) eldoc)) - (gnuplot-trace "\tset eldoc to \"%s\"\n" gnuplot-eldoc))))))) + (gnuplot-context--trace "\tset eldoc to \"%s\"\n" gnuplot-context--eldoc))))))) (pop stack)))) -(defun gnuplot-capture-group (name) +(defun gnuplot-context--capture-group (name) "Return capture group NAME from the most recent parse, as a list of tokens." - (let ((record (assoc name gnuplot-captures))) + (let ((record (assoc name gnuplot-context--captures))) (if (not record) nil (let ((begin (cadr record)) (end (cl-caddr record)) @@ -2041,60 +2019,55 @@ there." (push (pop begin) accum)) (nreverse accum))))) -(defun gnuplot-capture-group->string (name) - (let ((tokens (gnuplot-capture-group name))) - (and tokens - (mapconcat 'gnuplot-token-id tokens " ")))) - ;;; Interface to the matching machine -(defun gnuplot-parse-at-point (completing-p) - (let ((tokens (gnuplot-tokenize completing-p))) - (gnuplot-match-pattern gnuplot-compiled-grammar tokens completing-p))) +(defun gnuplot-context--parse-at-point (completing-p) + (let ((tokens (gnuplot-context--tokenize completing-p))) + (gnuplot-context--match-pattern gnuplot-context--compiled-grammar tokens completing-p))) ;; Completions -(defun gnuplot-completions () - (gnuplot-parse-at-point t) - gnuplot-completions) +(defun gnuplot-context--completions () + (gnuplot-context--parse-at-point t) + gnuplot-context--completions) (defun gnuplot-context-completion-at-point () "Return completions of keyword preceding point, using context." (list (save-excursion - (skip-syntax-backward "w_" (gnuplot-point-at-beginning-of-command)) + (skip-syntax-backward "w_" (gnuplot--point-at-beginning-of-command)) (point)) (point) - (gnuplot-completions))) + (gnuplot-context--completions))) ;; Eldoc help -(defun gnuplot-eldoc-function () +(defun gnuplot-context-eldoc-function (&rest _) "Return the ElDoc string for the Gnuplot construction at point." - (gnuplot-parse-at-point nil) - gnuplot-eldoc) + (gnuplot-context--parse-at-point nil) + gnuplot-context--eldoc) -(defun gnuplot-help-function () +(defun gnuplot-context-help-at-point () "Pop up the extended documentation for the construction at point." - (interactive) - (gnuplot-parse-at-point nil) - (if (and gnuplot-info-at-point gnuplot-eldoc-hash) + (interactive nil gnuplot-mode gnuplot-comint-mode) + (gnuplot-context--parse-at-point nil) + (if gnuplot-context--info-at-point (let ((eldoc - (cadr (gethash gnuplot-info-at-point gnuplot-eldoc-hash)))) + (cadr (gethash gnuplot-context--info-at-point gnuplot-eldoc-hash)))) (if eldoc (message eldoc))))) ;; Info lookup -(defun gnuplot-info-at-point (&optional query) +(defun gnuplot-context-info-at-point (&optional query) "Open the relevant gnuplot info page for the construction at point." - (interactive "P") - (setq gnuplot-info-at-point nil) + (interactive "P" gnuplot-mode gnuplot-comint-mode) + (setq gnuplot-context--info-at-point nil) (unless query - (gnuplot-parse-at-point nil)) - (if (or query (not gnuplot-info-at-point)) + (gnuplot-context--parse-at-point nil)) + (if (or query (not gnuplot-context--info-at-point)) (let ((info (info-lookup-interactive-arguments 'symbol))) - (setq gnuplot-info-at-point (car info)))) - (when gnuplot-info-at-point - (gnuplot--find-info-node gnuplot-info-at-point))) + (setq gnuplot-context--info-at-point (car info)))) + (when gnuplot-context--info-at-point + (gnuplot-context--find-info-node gnuplot-context--info-at-point))) -(defun gnuplot--find-info-node (node) +(defun gnuplot-context--find-info-node (node) (save-window-excursion (info (format "(gnuplot)%s" node))) (gnuplot--adjust-info-display)) @@ -2105,7 +2078,7 @@ there." ;; ElDoc strings for "using" specs, which depend on other information ;; from the parsed command -(defvar gnuplot-using-eldoc +(defvar gnuplot-context--using-eldoc '(("boxerrorbars" . "x:y:ydelta{:xdelta} | x:y:ylow:yhigh{:xdelta}") ("boxes" . "x:y{:x_width}") ("boxxyerrorbars" . "x:y:xdelta:ydelta | x:y:xlow:xhigh:ylow:yhigh") @@ -2133,7 +2106,7 @@ there." ("xyerrorlines" . "x:y:xdelta:ydelta | x:y:xlow:xhigh:ylow:yhigh")) "Alist of ElDoc strings for Gnuplot \"using\" clauses in \"plot\" commands.") -(defvar gnuplot-using-3d-eldoc +(defvar gnuplot-context--using-3d-eldoc (append '(("fsteps" . "z | x:y:z") ("histeps" . "z | x:y:z") @@ -2145,28 +2118,28 @@ there." ("lines" . "z | x:y:z") ("steps" . "z | x:y:z") ("vectors" . "x:y:z:xdelta:ydelta:zdelta")) - gnuplot-using-eldoc) + gnuplot-context--using-eldoc) "Alist of ElDoc strings for Gnuplot \"using\" clauses in \"splot\" commands.") -(defun gnuplot-find-using-eldoc () +(defun gnuplot-context--find-using-eldoc () "Return ElDoc string for a Gnuplot \"using\" clause, based on plotting style. This will fail if the \"using\" clause comes before the \"with\" clause." - (let ((with-style (gnuplot-capture-group :with-style)) - (3d-p (gnuplot-capture-group :splot-command)) + (let ((with-style (gnuplot-context--capture-group :with-style)) + (3d-p (gnuplot-context--capture-group :splot-command)) (column-description nil)) (if with-style - (let ((with-style-string (gnuplot-token-id (car with-style)))) + (let ((with-style-string (gnuplot-context--token-id (car with-style)))) (setq column-description (or (and 3d-p - (cdr (assoc with-style-string gnuplot-using-3d-eldoc))) - (cdr (assoc with-style-string gnuplot-using-eldoc)) + (cdr (assoc with-style-string gnuplot-context--using-3d-eldoc))) + (cdr (assoc with-style-string gnuplot-context--using-eldoc)) "")))) (format "using %s {'format'}" column-description))) ;;; Needed for correctly parsing plot commands -(defun gnuplot-guess-parametric-p (&optional start) +(defun gnuplot-context--guess-parametric-p (&optional start) "Guess whether the command beginning at START is in parametric mode. Searches backward in current buffer for an \"(un)set parametric\" @@ -2176,13 +2149,11 @@ command." (catch 'result (while (search-backward-regexp "reset\\|set\\s-+parametric" (point-min) t) - (gnuplot-beginning-of-command) + (gnuplot--beginning-of-command) (cond ((looking-at "reset\\|unset\\s-+parametric") (throw 'result nil)) ((looking-at "set\\s-+parametric") (throw 'result t)))) nil))) - -;;;###autoload (define-minor-mode gnuplot-context-sensitive-mode "Use context-sensitive completion and help in `gnuplot-mode'. @@ -2198,70 +2169,35 @@ 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. +pressing TAB, set `tab-always-indent' to `complete'. -\\[gnuplot-info-at-point] will try to find the most relevant +\\[gnuplot-context-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 +\\[gnuplot-context-help-at-point] 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'. +`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." +`gnuplot-use-context-sensitive-completion'." + :interactive (gnuplot-mode gnuplot-comint-mode) :keymap - `((,(kbd "C-c C-/") . gnuplot-help-function) - (,(kbd "C-c C-d") . gnuplot-info-at-point)) + `((,(kbd "C-c C-/") . gnuplot-context-help-at-point) + (,(kbd "C-c C-d") . gnuplot-context-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))) + (remove-hook 'completion-at-point-functions #'gnuplot-completion-at-point-info-look t) + (add-hook 'completion-at-point-functions #'gnuplot-context-completion-at-point nil t) + (add-hook 'eldoc-documentation-functions #'gnuplot-context-eldoc-function nil 'local)) + (add-hook 'completion-at-point-functions #'gnuplot-completion-at-point-info-look nil t) + (remove-hook 'completion-at-point-functions #'gnuplot-context-completion-at-point t) + (remove-hook 'eldoc-documentation-functions #'gnuplot-context-eldoc-function t))) - -;;; All done! (provide 'gnuplot-context) - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: - ;;; gnuplot-context.el ends here diff --git a/elpa/gnuplot-20250724.1531/gnuplot-eldoc.el b/elpa/gnuplot-20250724.1531/gnuplot-eldoc.el new file mode 100644 index 00000000..0425ffe9 --- /dev/null +++ b/elpa/gnuplot-20250724.1531/gnuplot-eldoc.el @@ -0,0 +1,631 @@ +;;; gnuplot-eldoc.el -- Eldoc documentation strings for gnuplot-mode -*- lexical-binding: t -*- +;;; Automatically generated by doc2texi.el on Sun, 01 June 2025 + +;;;; This file is generated automatically from the Gnuplot +;;;; documentation by `doc2texi.el', part of the Gnuplot distribution. +;;;; It is not intended to be edited manually. See docs/gnuplot.doc +;;;; in the gnuplot source tree (available from +;;;; gnuplot.sourcefourge.net) for the original. + +;; This file is covered by the Gnuplot licensing terms: + +;; Copyright 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley +;; +;; Permission to use, copy, and distribute this software and its +;; documentation for any purpose with or without fee is hereby granted, +;; provided that the above copyright notice appear in all copies and +;; that both that copyright notice and this permission notice appear +;; in supporting documentation. +;; +;; Permission to modify the software is granted, but not the right to +;; distribute the complete modified source code. Modifications are to +;; be distributed as patches to the released version. Permission to +;; distribute binaries produced by compiling modified sources is granted, +;; provided you +;; 1. distribute the corresponding source modifications from the +;; released version in the form of a patch file along with the binaries, +;; 2. add special version identification to distinguish your version +;; in addition to the base release version number, +;; 3. provide your name and address as the primary contact for the +;; support of your modified version, and +;; 4. retain our contact information in regard to use of the base +;; software. +;; Permission to distribute the released version of the source code along +;; with corresponding source modifications in the form of a patch file is +;; granted with same provisions 2 through 4 for binary distributions. +;; +;; This software is provided "as is" without express or implied warranty +;; to the extent permitted by applicable law. + +(eval-when-compile (defvar gnuplot-eldoc-hash nil)) +(setq gnuplot-eldoc-hash (let ((tbl (make-hash-table :test 'equal)) (alist '(("x11" "set terminal x11 { | window \"\"} [more ...]" "set terminal x11 { | window \"\"} + {title \"\"} + {{no}enhanced} {font } + {linewidth LW} + {{no}persist} {{no}raise} {{no}ctrlq} + {{no}replotonresize} + {close} + {size XX,YY} {position XX,YY} +set terminal x11 {reset}") ("wxt" "set term wxt {} [more ...]" "set term wxt {} + {size ,} {position ,} + {background | nobackground} + {{no}enhanced} + {font } {fontscale } + {title \"title\"} + {linewidth } {butt|rounded|square} + {dashlength
} + {{no}persist} + {{no}raise} + {{no}ctrl} + {close}") ("windows" "set terminal windows {} [more ...]" "set terminal windows {} + {color | monochrome} + {solid | dashed} + {rounded | butt} + {enhanced | noenhanced} + {font } + {fontscale } + {linewidth } + {pointscale } + {background } + {title \"Plot Window Title\"} + {{size | wsize} ,} + {position ,} + {docked {layout ,} | standalone} + {close}") ("tpic" "set terminal tpic ") ("tkcanvas" "set terminal tkcanvas {tcl | perl | perltkx | python | ruby | rexx} [more ...]" "set terminal tkcanvas {tcl | perl | perltkx | python | ruby | rexx} + {standalone | input} + {interactive} + {rounded | butt} + {nobackground | background } + {{no}rottext} + {size ,} + {{no}enhanced} + {externalimages | pixels}") ("tgif" "set terminal tgif {portrait | landscape | default} {<[x,y]>} [more ...]" "set terminal tgif {portrait | landscape | default} {<[x,y]>} + {monochrome | color} + {{linewidth | lw} } + {solid | dashed} + {font \"{,}\"}") ("tek40" "set terminal sixeltek {} {mono|color|colors } {size ,} [more ...]" "set terminal sixeltek {} {mono|color|colors } {size ,} + {animate}") ("svg" "set terminal svg {size , {|fixed|dynamic}} [more ...]" "set terminal svg {size , {|fixed|dynamic}} + {mouse} {standalone | jsdir } + {name } + {font \"{,}\"} {{no}enhanced} + {fontscale } + {rounded|butt|square} {solid|dashed} {linewidth } + {background }") ("regis" "set terminal regis {4 | 16}\"") ("pstricks" "set terminal pstricks [more ...]" "set terminal pstricks + {unit | size {unit},{unit}} + {standalone | input} + {blacktext | colortext | colourtext} + {linewidth } {rounded | butt} + {pointscale } + {psarrows | gparrows} + {background } + {pstricks | pdftricks2}") ("pdf" "set terminal pdf {monochrome|color|colour} [more ...]" "set terminal pdf {monochrome|color|colour} + {{no}enhanced} + {fname \"\"} {fsize } + {font \"{,}\"} {fontscale } + {linewidth } {rounded|butt} + {dl }} + {size {unit},{unit}}") ("dospc" "set terminal dospc [more ...]" "set terminal dospc + {{no}{enhanced}} + {fontscale } {pointsize } {linewidth }") ("pbm" "set terminal pbm {} {} {size ,}") ("mif" "set terminal mif {color | colour | monochrome} {polyline | vectors} [more ...]" "set terminal mif {color | colour | monochrome} {polyline | vectors} + {help | ?}") ("mp" "set term mp {color | colour | monochrome} [more ...]" "set term mp {color | colour | monochrome} + {solid | dashed} + {notex | tex | latex} + {magnification } + {psnfss | psnfss-version7 | nopsnfss} + {prologues } + {a4paper} + {amstex} + {\" {,}\"} ") ("lua" "set terminal lua | \"\" [more ...]" "set terminal lua | \"\" + { ...} + {help}") ("latex" "set terminal {latex | emtex} {default | {courier|roman} {}} [more ...]" "set terminal {latex | emtex} {default | {courier|roman} {}} + {size {unit}, {unit}} {rotate | norotate} + {color | monochrome}") ("imagen" "set terminal imagen {} {portrait | landscape} [more ...]" "set terminal imagen {} {portrait | landscape} + {[,]}") ("hppj" "set terminal hppj {FNT5X9 | FNT9X17 | FNT13X25}") ("hpljii" "set terminal hpljii | hpdj {}") ("hpgl" "set terminal hpgl {} {eject} {fontscale }") ("hp500c" "set terminal hp500c {} {}") ("gpic" "set terminal gpic { }") ("ggi" "set terminal ggi [acceleration ] [[mode] {mode}]") ("png_" "set terminal png [more ...]" "set terminal png + {{no}enhanced} + {{no}transparent} {{no}interlace} + {{no}truecolor} {rounded|butt} + {linewidth } {dashlength
} + {tiny | small | medium | large | giant} + {font \" {,}\"} {fontscale } + {size ,} {{no}crop} + {background }") ("fig" "set terminal fig {monochrome | color} [more ...]" "set terminal fig {monochrome | color} + {small | big | size {in|cm},{in|cm}} + {landscape | portrait} + {pointsmax } + {font \"{,}\"} {fontsize } + {textnormal | {textspecial texthidden textrigid}} + {{linewidth|lw} }") ("epson_180dpi" "set terminal dpu414 {small | medium | large} {normal | draft}") ("epson_180dpi" "set terminal nec_cp6 {monochrome | colour | draft}") ("emf" "set terminal emf {color | monochrome} [more ...]" "set terminal emf {color | monochrome} + {enhanced {noproportional}} + {rounded | butt} + {linewidth } {dashlength
} + {size XX,YY} {background } + {font \"{,}\"} + {fontscale }") ("eepic" "set terminal eepic {default} {color|monochrome|dashed} [more ...]" "set terminal eepic {default} {color|monochrome|dashed} + {rotate} {size XX,YY} + {small|tiny|}") ("dumb" "set terminal dumb {size ,} {[no]feed} [more ...]" "set terminal dumb {size ,} {[no]feed} + {aspect {,}} + {[no]enhanced} + {fillchar {solid|\"\"}} + {[no]attributes} + {mono|ansi|ansi256|ansirgb}") ("svga" "set terminal svga {font \"\"} [more ...]" "set terminal svga {font \"\"} + {{no}enhanced} + {background } + {linewidth|lw } + {pointscale|ps } + {fontscale|fs }") ("corel" "set terminal corel {monochrome | color} {\"\" {}} [more ...]" "set terminal corel {monochrome | color} {\"\" {}} + { { }}") ("context" "set term context {default} [more ...]" "set term context {default} + {defaultsize | size | size {in|cm}, {in|cm}} + {input | standalone} + {timestamp | notimestamp} + {noheader | header \"
\"} + {color | colour | monochrome} + {rounded | mitered | beveled} {round | butt | squared} + {dashed | solid} {dashlength | dl
} + {linewidth | lw } + {fontscale } + {mppoints | texpoints} + {inlineimages | externalimages} + {defaultfont | font \"{}{,}\"}") ("cgm" "set terminal cgm {color | monochrome} {solid | dashed} {{no}rotate} [more ...]" "set terminal cgm {color | monochrome} {solid | dashed} {{no}rotate} + {} {width } {linewidth } + {font \",\"} + {background }") ("canvas" "set terminal canvas {size , } {background } [more ...]" "set terminal canvas {size , } {background } + {font {}{,}} | {fsize } + {{no}enhanced} {linewidth } + {rounded | butt | square} + {dashlength
} + {standalone {mousing} | name ''} + {jsdir 'URL/for/javascripts'} + {title ''}") ("be" "set terminal be {reset} {}") ("aqua" "set terminal aqua {} {title \"\"} {size } [more ...]" "set terminal aqua {} {title \"\"} {size } + {font \"{,}\"} + {linewidth }\"} + {{no}enhanced} {solid|dashed} {dl }}") ("aifm" "set terminal aifm {color|monochrome} {\"\"} {}") ("While" "while () { [more ...]" "while () { + +}") ("warn" "warn \"message\"") ("vfill" "vfill FILE using x:y:z:radius:() [more ...]" "vfill FILE using x:y:z:radius:() +vgfill FILE using x:y:z:radius:()") ("vclear" "vclear {$gridname}") ("linetype_" "unset linetype N") ("toggle" "toggle { | \"plottitle\" | all}") ("test" "test {terminal | palette}") ("system_" "system \"command string\" [more ...]" "system \"command string\" +! command string +output = system(\"command string\") +show variable GPVAL_SYSTEM") ("stats_(Statistical_Summary)" "stats {} 'filename' {matrix | using N{:M}} {name 'prefix'} {{no}output} [more ...]" "stats {} 'filename' {matrix | using N{:M}} {name 'prefix'} {{no}output} +stats $voxelgridname {name 'prefix'}") ("voxel-grid" "splot $voxelgridname with {dots|points} {above } ... [more ...]" "splot $voxelgridname with {dots|points} {above } ... +splot $voxelgridname with isosurface {level } ...") ("matrix" "plot 'file' matrix every {} [more ...]" "plot 'file' matrix every {} + {:{} + {:{} + {:{} + {:{} + {:}}}}}") ("matrix" "sparse matrix=(cols,rows) origin=(x0,y0) dx= dy=") ("data-file" "splot '' {binary } [more ...]" "splot '' {binary } + {{nonuniform|sparse} matrix} + {index } + {every } + {using }") ("splot" "splot {} [more ...]" "splot {} + {} + | {{ | } {datafile-modifiers}} + | + | keyentry + {} {with