update packages
This commit is contained in:
@@ -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
|
||||
@@ -2054,23 +2060,11 @@ there."
|
||||
|
||||
(defun gnuplot-context-completion-at-point ()
|
||||
"Return completions of keyword preceding point, using context."
|
||||
(let* ((end (point))
|
||||
(beg
|
||||
(save-excursion
|
||||
(skip-syntax-backward "w_" (gnuplot-point-at-beginning-of-command))
|
||||
(point)))
|
||||
(word nil)
|
||||
(completions (gnuplot-completions)))
|
||||
|
||||
(setq word (buffer-substring beg end)
|
||||
completions (all-completions word completions))
|
||||
|
||||
(if completions
|
||||
(list beg end completions)
|
||||
(if (not (equal "" word))
|
||||
(message "No gnuplot keywords complete '%s'" word)
|
||||
(message "No completions at point"))
|
||||
nil)))
|
||||
(list (save-excursion
|
||||
(skip-syntax-backward "w_" (gnuplot-point-at-beginning-of-command))
|
||||
(point))
|
||||
(point)
|
||||
(gnuplot-completions)))
|
||||
|
||||
;; Eldoc help
|
||||
(defun gnuplot-eldoc-function ()
|
||||
@@ -2192,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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -58,37 +58,9 @@
|
||||
;;; Code:
|
||||
|
||||
(require 'gnuplot)
|
||||
(eval-and-compile
|
||||
(condition-case ()
|
||||
(progn
|
||||
(require 'widget)
|
||||
(require 'wid-edit))
|
||||
(error nil)))
|
||||
(require 'widget)
|
||||
(require 'wid-edit)
|
||||
(require 'cl-lib)
|
||||
(eval-when-compile ; suppress some compiler warnings
|
||||
(defvar gnuplot-quote-character nil)
|
||||
(defvar gnuplot-info-display nil)
|
||||
(defvar gnuplot-mode-map nil))
|
||||
|
||||
;; (eval-when-compile
|
||||
;; (require 'wid-edit))
|
||||
|
||||
(eval-and-compile ; I need this!
|
||||
(if (fboundp 'split-string)
|
||||
()
|
||||
(defun split-string (string &optional pattern)
|
||||
"Return a list of substrings of STRING which are separated by PATTERN.
|
||||
If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
|
||||
(or pattern
|
||||
(setq pattern "[ \f\t\n\r\v]+"))
|
||||
;; The FSF version of this function takes care not to cons in case
|
||||
;; of infloop. Maybe we should synch?
|
||||
(let (parts (start 0))
|
||||
(while (string-match pattern string start)
|
||||
(setq parts (cons (substring string start (match-beginning 0)) parts)
|
||||
start (match-end 0)))
|
||||
(nreverse (cons (substring string start) parts)))) ))
|
||||
|
||||
|
||||
|
||||
;;; customizable variables
|
||||
@@ -833,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
|
||||
@@ -854,16 +827,16 @@ This alist is formed at load time by appending together
|
||||
|
||||
;;; user interface to the widget-y stuff
|
||||
|
||||
;;;###autoload
|
||||
(defun gnuplot-gui-mouse-set (event)
|
||||
"Use the mouse to begin setting options using a GUI interface.
|
||||
EVENT is a mouse event. Bound to \\[gnuplot-gui-mouse-set]
|
||||
Note that \"plot\", \"splot\", \"fit\", and \"cntrparam\" are not
|
||||
currently supported."
|
||||
(interactive "@e")
|
||||
(when (fboundp 'widget-create)
|
||||
(save-excursion
|
||||
(mouse-set-point event)
|
||||
(gnuplot-gui-set-options-and-insert))))
|
||||
(save-excursion
|
||||
(mouse-set-point event)
|
||||
(gnuplot-gui-set-options-and-insert)))
|
||||
|
||||
(defun gnuplot-gui-get-frame-param (param)
|
||||
(cdr (assoc param gnuplot-gui-frame-parameters)))
|
||||
@@ -871,88 +844,89 @@ 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
|
||||
frame. Bound to \\[gnuplot-gui-set-options-and-insert]
|
||||
Note that \"cntrparam\" is not currently supported."
|
||||
(interactive)
|
||||
(when (fboundp 'widget-create)
|
||||
(let ((begin (gnuplot-point-at-beginning-of-command))
|
||||
(end (save-excursion (end-of-line) (point-marker)))
|
||||
(termin (concat "\\(,\\s-*" (regexp-quote "\\") "\\|;\\)"))
|
||||
(set nil) (term nil))
|
||||
(save-excursion
|
||||
;; there can be more then one command per line
|
||||
(if (re-search-forward termin end "to_limit")
|
||||
(progn (backward-char (length (match-string 1)))
|
||||
(setq end (point-marker))))
|
||||
(goto-char begin)
|
||||
(skip-syntax-forward "-" end)
|
||||
;; various constructions are recognized here. at the end of this
|
||||
;; cond, point should be just after the word whose arguments are
|
||||
;; to be set
|
||||
(cond ((looking-at "set\\s-+")
|
||||
(setq set t)
|
||||
(goto-char (match-end 0))
|
||||
(if (looking-at "\\sw+") (goto-char (match-end 0)))
|
||||
(when (string-match "^ter" (gnuplot-this-word)) ; terminal?
|
||||
(setq term t)
|
||||
(forward-word 1))
|
||||
(when (string-match "^\\(da\\|fu\\)" (gnuplot-this-word))
|
||||
(unless (looking-at "\\s-+st")
|
||||
(insert " style") (forward-word 1))
|
||||
(forward-word 1)))
|
||||
((looking-at (concat "\\(cd\\|ca\\|lo\\|pa\\|pr\\|sa\\|u\\)"
|
||||
"\\w*"
|
||||
"[\\s-\\']"))
|
||||
(let ((begin (gnuplot-point-at-beginning-of-command))
|
||||
(end (save-excursion (end-of-line) (point-marker)))
|
||||
(termin (concat "\\(,\\s-*" (regexp-quote "\\") "\\|;\\)"))
|
||||
(set nil) (term nil))
|
||||
(save-excursion
|
||||
;; there can be more then one command per line
|
||||
(if (re-search-forward termin end "to_limit")
|
||||
(progn (backward-char (length (match-string 1)))
|
||||
(setq end (point-marker))))
|
||||
(goto-char begin)
|
||||
(skip-syntax-forward "-" end)
|
||||
;; various constructions are recognized here. at the end of this
|
||||
;; cond, point should be just after the word whose arguments are
|
||||
;; to be set
|
||||
(cond ((looking-at "set\\s-+")
|
||||
(setq set t)
|
||||
(goto-char (match-end 0))
|
||||
(if (looking-at "\\sw+") (goto-char (match-end 0)))
|
||||
(when (string-match "^ter" (gnuplot-this-word)) ; terminal?
|
||||
(setq term t)
|
||||
(forward-word 1))
|
||||
;;(goto-char (match-end 0)))
|
||||
(t
|
||||
(when (string-match "^\\(da\\|fu\\)" (gnuplot-this-word))
|
||||
(unless (looking-at "\\s-+st")
|
||||
(insert " style") (forward-word 1))
|
||||
(forward-word 1)))
|
||||
(if (> (point) end) (goto-char end))
|
||||
(let* ((w (gnuplot-this-word))
|
||||
(wd (try-completion w gnuplot-gui-all-types))
|
||||
(word "") wrd list)
|
||||
(cond ((equal wd t) (setq word w))
|
||||
((equal wd nil) (setq word w))
|
||||
((assoc wd gnuplot-gui-all-types) (setq word wd))
|
||||
(t (setq wd nil)))
|
||||
(cond ((equal (string-match "^\\s-*$" w) 0)
|
||||
(message "Blank line"))
|
||||
((and wd (stringp word))
|
||||
(gnuplot-gui-correct-command word set term begin)
|
||||
(setq gnuplot-gui-alist nil
|
||||
gnuplot-gui-current-string
|
||||
(buffer-substring-no-properties (point) end))
|
||||
(gnuplot-gui-set-alist word gnuplot-gui-current-string)
|
||||
(let* ((old-height (gnuplot-gui-get-frame-param 'height))
|
||||
(old-top (gnuplot-gui-get-frame-param 'top)))
|
||||
(when (or
|
||||
(and (equal gnuplot-gui-plot-splot-fit-style 'complete)
|
||||
(cl-member word '("plot" "splot" "fit")
|
||||
((looking-at (concat "\\(cd\\|ca\\|lo\\|pa\\|pr\\|sa\\|u\\)"
|
||||
"\\w*"
|
||||
"[\\s-\\']"))
|
||||
(forward-word 1))
|
||||
;;(goto-char (match-end 0)))
|
||||
(t
|
||||
(forward-word 1)))
|
||||
(if (> (point) end) (goto-char end))
|
||||
(let* ((w (gnuplot-this-word))
|
||||
(wd (try-completion w gnuplot-gui-all-types))
|
||||
(word "") wrd list)
|
||||
(cond ((equal wd t) (setq word w))
|
||||
((equal wd nil) (setq word w))
|
||||
((assoc wd gnuplot-gui-all-types) (setq word wd))
|
||||
(t (setq wd nil)))
|
||||
(cond ((equal (string-match "^\\s-*$" w) 0)
|
||||
(message "Blank line"))
|
||||
((and wd (stringp word))
|
||||
(gnuplot-gui-correct-command word set term begin)
|
||||
(setq gnuplot-gui-alist nil
|
||||
gnuplot-gui-current-string
|
||||
(buffer-substring-no-properties (point) end))
|
||||
(gnuplot-gui-set-alist word gnuplot-gui-current-string)
|
||||
(let* ((old-height (gnuplot-gui-get-frame-param 'height))
|
||||
(old-top (gnuplot-gui-get-frame-param 'top)))
|
||||
(when (or
|
||||
(and (equal gnuplot-gui-plot-splot-fit-style 'complete)
|
||||
(cl-member word '("plot" "splot" "fit")
|
||||
:test 'string=))
|
||||
(equal word "test"))
|
||||
(gnuplot-gui-set-frame-param 'height 32)
|
||||
(gnuplot-gui-set-frame-param 'top 50))
|
||||
(gnuplot-gui-prompt-for-frame word)
|
||||
(when (or
|
||||
(and (equal gnuplot-gui-plot-splot-fit-style 'complete)
|
||||
(cl-member word '("plot" "splot" "fit")
|
||||
(equal word "test"))
|
||||
(gnuplot-gui-set-frame-param 'height 32)
|
||||
(gnuplot-gui-set-frame-param 'top 50))
|
||||
(gnuplot-gui-prompt-for-frame word)
|
||||
(when (or
|
||||
(and (equal gnuplot-gui-plot-splot-fit-style 'complete)
|
||||
(cl-member word '("plot" "splot" "fit")
|
||||
:test 'string=))
|
||||
(equal word "test"))
|
||||
(gnuplot-gui-set-frame-param 'height old-height)
|
||||
(gnuplot-gui-set-frame-param 'top old-top)) ))
|
||||
((setq wrd (car (all-completions w '(("cntrparam")))))
|
||||
(message
|
||||
"Setting arguments for %S is currently unsuported in gnuplot-mode"
|
||||
wrd))
|
||||
((setq list (all-completions w gnuplot-gui-all-types))
|
||||
(message "%S could be one of %S" w list))
|
||||
(t
|
||||
(message
|
||||
"%S is not a gnuplot command which takes options" w)))) ))))
|
||||
(equal word "test"))
|
||||
(gnuplot-gui-set-frame-param 'height old-height)
|
||||
(gnuplot-gui-set-frame-param 'top old-top)) ))
|
||||
((setq wrd (car (all-completions w '(("cntrparam")))))
|
||||
(message
|
||||
"Setting arguments for %S is currently unsuported in gnuplot-mode"
|
||||
wrd))
|
||||
((setq list (all-completions w gnuplot-gui-all-types))
|
||||
(message "%S could be one of %S" w list))
|
||||
(t
|
||||
(message
|
||||
"%S is not a gnuplot command which takes options" w)))) )))
|
||||
|
||||
;;;###autoload
|
||||
(defun gnuplot-gui-toggle-popup ()
|
||||
(interactive)
|
||||
(setq gnuplot-gui-popup-flag (not gnuplot-gui-popup-flag))
|
||||
@@ -961,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)
|
||||
@@ -1342,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)
|
||||
@@ -1382,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))))
|
||||
@@ -1392,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
|
||||
@@ -1405,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)
|
||||
@@ -1455,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)) " ")
|
||||
"" )))
|
||||
@@ -1480,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)
|
||||
@@ -1516,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)) )
|
||||
@@ -1550,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)
|
||||
@@ -1604,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)
|
||||
@@ -1614,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))
|
||||
@@ -1640,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)))))
|
||||
@@ -1657,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)))))
|
||||
@@ -1666,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)))))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(define-package "gnuplot" "20210104.1052" "Major-mode and interactive frontend for gnuplot"
|
||||
(define-package "gnuplot" "20220102.1637" "Major-mode and interactive frontend for gnuplot"
|
||||
'((emacs "24.3"))
|
||||
:commit "116cad8e09024223f97e81b0a4503cef20de9bf5" :authors
|
||||
:commit "d1a6a606dcb389a7c91a6b0d9fb995434df561be" :authors
|
||||
'(("Jon Oddie")
|
||||
("Bruce Ravel")
|
||||
("Phil Type"))
|
||||
|
||||
@@ -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
|
||||
@@ -315,7 +312,6 @@ beginning the continued command."
|
||||
"A list of keywords used in GNUPLOT.
|
||||
These are set by `gnuplot-set-keywords-list' from the values in
|
||||
`info-lookup-cache'.")
|
||||
(defvar gnuplot-keywords-alist nil) ;; For all-completions
|
||||
(defvar gnuplot-keywords-pending t ;; <HW>
|
||||
"A boolean which gets toggled when the info file is probed.")
|
||||
(defcustom gnuplot-keywords-when 'deferred ;; 'immediately
|
||||
@@ -335,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
|
||||
@@ -359,12 +362,12 @@ 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)
|
||||
value
|
||||
(not (gnuplot-display-images-p)))
|
||||
(not (display-images-p)))
|
||||
(progn
|
||||
(message "Displaying images is not supported.")
|
||||
(set variable nil))
|
||||
@@ -390,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.
|
||||
@@ -404,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."
|
||||
@@ -424,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))
|
||||
@@ -462,7 +464,7 @@ non-nil."
|
||||
:style toggle
|
||||
:selected (null gnuplot-inline-image-mode)]
|
||||
["In Comint buffer" gnuplot-inline-display-mode
|
||||
:active (gnuplot-display-images-p)
|
||||
:active (display-images-p)
|
||||
:style toggle
|
||||
:selected (eq gnuplot-inline-image-mode 'comint)]
|
||||
["In dedicated buffer" gnuplot-dedicated-display-mode
|
||||
@@ -501,10 +503,8 @@ non-nil."
|
||||
gnuplot-info-at-point
|
||||
gnuplot-context-sensitive-mode]
|
||||
["Show gnuplot process buffer" gnuplot-show-gnuplot-buffer t]
|
||||
["Set arguments at point" gnuplot-gui-set-options-and-insert
|
||||
(fboundp 'gnuplot-gui-set-options-and-insert)]
|
||||
["Swap plot/splot/fit lists in GUI" gnuplot-gui-swap-simple-complete
|
||||
(fboundp 'gnuplot-gui-swap-simple-complete)]
|
||||
["Set arguments at point" gnuplot-gui-set-options-and-insert t]
|
||||
["Swap plot/splot/fit lists in GUI" gnuplot-gui-swap-simple-complete t]
|
||||
"---"
|
||||
["Customize gnuplot" gnuplot-customize t]
|
||||
"---"
|
||||
@@ -515,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'.
|
||||
@@ -547,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.
|
||||
@@ -840,19 +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 (fboundp 'gnuplot-gui-toggle-popup)
|
||||
:style toggle :selected (and (fboundp 'gnuplot-gui-toggle-popup)
|
||||
gnuplot-gui-popup-flag)]))
|
||||
|
||||
(defun gnuplot-setup-menubar ()
|
||||
"Initial setup of gnuplot and insertions menus."
|
||||
@@ -991,48 +985,43 @@ These are highlighted using `font-lock-constant-face'.")
|
||||
(gnuplot-make-regexp gnuplot-keywords-negatable-options))
|
||||
|
||||
;; Set up colorization for gnuplot.
|
||||
(defvar gnuplot-font-lock-keywords nil)
|
||||
(defvar gnuplot-font-lock-syntactic-keywords nil)
|
||||
(defvar gnuplot-font-lock-defaults nil)
|
||||
(defvar gnuplot-font-lock-keywords
|
||||
(list
|
||||
;; stuff in brackets, sugg. by <LB>
|
||||
'("\\[\\([^]]+\\)\\]" 1 font-lock-constant-face)
|
||||
|
||||
(when (featurep 'font-lock) ; <KL>
|
||||
(setq gnuplot-font-lock-keywords
|
||||
(list
|
||||
;; stuff in brackets, sugg. by <LB>
|
||||
'("\\[\\([^]]+\\)\\]" 1 font-lock-constant-face)
|
||||
;; variable/function definitions
|
||||
'("\\(\\(\\sw\\|\\s_\\)+\\s-*\\((\\s-*\\(\\sw\\|\\s_\\)*\\s-*\\(,\\s-*\\sw*\\)*\\s-*)\\)?\\s-*=\\)[^=]"
|
||||
1 font-lock-variable-name-face)
|
||||
|
||||
;; variable/function definitions
|
||||
'("\\(\\(\\sw\\|\\s_\\)+\\s-*\\((\\s-*\\(\\sw\\|\\s_\\)*\\s-*\\(,\\s-*\\sw*\\)*\\s-*)\\)?\\s-*=\\)[^=]"
|
||||
1 font-lock-variable-name-face)
|
||||
;; built-in function names
|
||||
(cons (gnuplot-make-regexp gnuplot-keywords-builtin-functions)
|
||||
font-lock-function-name-face)
|
||||
|
||||
;; built-in function names
|
||||
(cons (gnuplot-make-regexp gnuplot-keywords-builtin-functions)
|
||||
font-lock-function-name-face)
|
||||
;; reserved words associated with plotting <AL>
|
||||
(cons (gnuplot-make-regexp gnuplot-keywords-plotting)
|
||||
font-lock-type-face)
|
||||
(cons (gnuplot-make-regexp gnuplot-keywords-plotting-styles)
|
||||
font-lock-function-name-face)
|
||||
|
||||
;; reserved words associated with plotting <AL>
|
||||
(cons (gnuplot-make-regexp gnuplot-keywords-plotting)
|
||||
font-lock-type-face)
|
||||
(cons (gnuplot-make-regexp gnuplot-keywords-plotting-styles)
|
||||
font-lock-function-name-face)
|
||||
;; (s)plot -- also thing (s)plotted
|
||||
'("\\<s?plot\\>" . font-lock-keyword-face)
|
||||
;; '("\\<s?plot\\s-+\\([^'\" ]+\\)[) \n,\\\\]"
|
||||
;; 1 font-lock-variable-name-face)
|
||||
|
||||
;; (s)plot -- also thing (s)plotted
|
||||
'("\\<s?plot\\>" . font-lock-keyword-face)
|
||||
;; '("\\<s?plot\\s-+\\([^'\" ]+\\)[) \n,\\\\]"
|
||||
;; 1 font-lock-variable-name-face)
|
||||
;; other common commands
|
||||
(cons (gnuplot-make-regexp gnuplot-keywords-misc)
|
||||
font-lock-constant-face)
|
||||
(cons "!.*$" font-lock-constant-face))) ; what is this for? jjo
|
||||
|
||||
;; other common commands
|
||||
(cons (gnuplot-make-regexp gnuplot-keywords-misc)
|
||||
font-lock-constant-face)
|
||||
(cons "!.*$" font-lock-constant-face))) ; what is this for? jjo
|
||||
|
||||
(setq gnuplot-font-lock-defaults
|
||||
'(gnuplot-font-lock-keywords
|
||||
nil ; Use syntactic fontification
|
||||
t ; Use case folding
|
||||
nil ; No extra syntax
|
||||
;; calls `gnuplot-beginning-of-continuation'
|
||||
;; to find a safe place to begin syntactic highlighting
|
||||
beginning-of-defun)))
|
||||
(defvar gnuplot-font-lock-defaults
|
||||
'(gnuplot-font-lock-keywords
|
||||
nil ; Use syntactic fontification
|
||||
t ; Use case folding
|
||||
nil ; No extra syntax
|
||||
;; calls `gnuplot-beginning-of-continuation'
|
||||
;; to find a safe place to begin syntactic highlighting
|
||||
beginning-of-defun))
|
||||
|
||||
;; Some corner cases in Gnuplot's comment and string syntax are
|
||||
;; difficult to handle accurately using Emacs's built-in syntax tables
|
||||
@@ -1058,32 +1047,31 @@ These are highlighted using `font-lock-constant-face'.")
|
||||
;; normal syntax-table parser, which is accurate enough for most
|
||||
;; normal cases. (See the definition of `gnuplot-mode-syntax-table'.)
|
||||
(defalias 'gnuplot-syntax-propertize
|
||||
(when (fboundp 'syntax-propertize-rules)
|
||||
(syntax-propertize-rules
|
||||
;; Double quoted strings
|
||||
((rx
|
||||
(group "\"")
|
||||
(* (or (seq "\\" anything)
|
||||
(not (any "\"" "\n"))))
|
||||
(group (or "\"" "\n" buffer-end)))
|
||||
(1 "|") (2 "|"))
|
||||
(syntax-propertize-rules
|
||||
;; Double quoted strings
|
||||
((rx
|
||||
(group "\"")
|
||||
(* (or (seq "\\" anything)
|
||||
(not (any "\"" "\n"))))
|
||||
(group (or "\"" "\n" buffer-end)))
|
||||
(1 "|") (2 "|"))
|
||||
|
||||
;; Single quoted strings
|
||||
((rx
|
||||
(group "'")
|
||||
(* (or (seq "\\" "\n")
|
||||
"''"
|
||||
(not (any "'" "\n"))))
|
||||
(group (or "'" "\n" buffer-end)))
|
||||
(1 "|") (2 "|"))
|
||||
;; Single quoted strings
|
||||
((rx
|
||||
(group "'")
|
||||
(* (or (seq "\\" "\n")
|
||||
"''"
|
||||
(not (any "'" "\n"))))
|
||||
(group (or "'" "\n" buffer-end)))
|
||||
(1 "|") (2 "|"))
|
||||
|
||||
;; Comments
|
||||
((rx
|
||||
(group "#")
|
||||
(* (or (seq "\\" "\n")
|
||||
any))
|
||||
(or (group "\n") buffer-end))
|
||||
(1 "!") (2 "!")))))
|
||||
;; Comments
|
||||
((rx
|
||||
(group "#")
|
||||
(* (or (seq "\\" "\n")
|
||||
any))
|
||||
(or (group "\n") buffer-end))
|
||||
(1 "!") (2 "!"))))
|
||||
|
||||
(defun gnuplot-syntax-propertize-extend-region (start end)
|
||||
"Expand the region to `syntax-propertize' for strings and comments.
|
||||
@@ -1357,14 +1345,11 @@ This keeps that buffer from growing excessively in size. Normally,
|
||||
this function is attached to `gnuplot-after-plot-hook'"
|
||||
(if (> gnuplot-buffer-max-size 0)
|
||||
(with-current-buffer gnuplot-buffer
|
||||
(let ((nlines (count-lines (point-min) (point-max)))
|
||||
(kill-whole-line t))
|
||||
(while (> nlines gnuplot-buffer-max-size)
|
||||
(let ((gnuplot-lines (count-lines (point-min) (point-max))))
|
||||
(dotimes (_n (- gnuplot-lines gnuplot-buffer-max-size))
|
||||
(goto-char (point-min))
|
||||
(kill-line)
|
||||
(setq nlines (1- nlines)))
|
||||
(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
|
||||
@@ -1412,17 +1397,16 @@ buffer."
|
||||
(set-syntax-table gnuplot-mode-syntax-table)
|
||||
|
||||
(setq font-lock-defaults gnuplot-font-lock-defaults)
|
||||
(set (make-local-variable 'parse-sexp-lookup-properties) t)
|
||||
(set (make-local-variable 'syntax-propertize-function)
|
||||
#'gnuplot-syntax-propertize)
|
||||
(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
|
||||
@@ -1436,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
|
||||
@@ -1458,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)
|
||||
@@ -1475,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
|
||||
@@ -1552,11 +1535,6 @@ gnuplot process buffer will be displayed in a window."
|
||||
|
||||
(defvar gnuplot-image-buffer-name "*gnuplot output*")
|
||||
|
||||
(defun gnuplot-display-images-p ()
|
||||
"Inline images require GNU Emacs."
|
||||
(and (fboundp 'display-images-p)
|
||||
(display-images-p)))
|
||||
|
||||
(defun gnuplot-external-display-mode ()
|
||||
"Display image in external."
|
||||
(interactive)
|
||||
@@ -1590,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'."
|
||||
@@ -1601,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
|
||||
@@ -1612,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)
|
||||
@@ -1649,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))
|
||||
@@ -1801,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)
|
||||
@@ -1813,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))
|
||||
@@ -1899,9 +1877,7 @@ Negatable options are defined in `gnuplot-keywords-negatable-options'."
|
||||
(defun gnuplot-customize ()
|
||||
"Customize `gnuplot-mode'."
|
||||
(interactive)
|
||||
(if (fboundp 'customize-group)
|
||||
(customize-group "gnuplot")
|
||||
(message "The Custom library is not installed.")))
|
||||
(customize-group "gnuplot"))
|
||||
|
||||
|
||||
|
||||
@@ -1945,8 +1921,7 @@ See the comments in `gnuplot-info-hook'."
|
||||
;; user will not want them lying around
|
||||
(and (get-buffer "info dir") (kill-buffer "info dir"))
|
||||
(and (get-buffer "info dir<2>") (kill-buffer "info dir<2>")))
|
||||
(setq gnuplot-keywords (gnuplot-set-keywords-list))
|
||||
(setq gnuplot-keywords-alist (mapcar 'list gnuplot-keywords)))
|
||||
(setq gnuplot-keywords (gnuplot-set-keywords-list)))
|
||||
|
||||
(defun gnuplot-set-keywords-list ()
|
||||
"Set `gnuplot-keywords' from `info-lookup-cache'.
|
||||
@@ -1980,94 +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
|
||||
(set (make-local-variable 'eldoc-documentation-function)
|
||||
'gnuplot-eldoc-function)
|
||||
(eldoc-add-command 'completion-at-point) ; Check for eldoc after completion
|
||||
(when (fboundp 'comint-dynamic-complete)
|
||||
(eldoc-add-command 'comint-dynamic-complete))
|
||||
|
||||
;; 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
|
||||
(set (make-local-variable 'tab-always-indent) 'complete))
|
||||
|
||||
(message "Gnuplot context-sensitive help & completion enabled."))
|
||||
|
||||
;; Turn off
|
||||
(setq gnuplot-completion-at-point-function #'gnuplot-completion-at-point-info-look)
|
||||
(setq eldoc-documentation-function nil)
|
||||
(eldoc-mode 0)
|
||||
(message "Gnuplot context-sensitive help & completion disabled.")))
|
||||
|
||||
;; Older completion method using info-look
|
||||
(defun gnuplot-completion-at-point-info-look ()
|
||||
"Return completions of keyword preceding point.
|
||||
@@ -2079,18 +1966,10 @@ positions and COMPLETIONS is a list."
|
||||
|
||||
(if gnuplot-keywords-pending ; <HW>
|
||||
(gnuplot-setup-info-look))
|
||||
(let* ((end (point))
|
||||
(beg (condition-case _err
|
||||
(save-excursion (backward-sexp 1) (point))
|
||||
(error (point))))
|
||||
(patt (buffer-substring beg end))
|
||||
(pattern (if (string-match "\\([^ \t]*\\)\\s-+$" patt)
|
||||
(match-string 1 patt) patt))
|
||||
(completions (all-completions pattern gnuplot-keywords-alist)))
|
||||
(if completions
|
||||
(list beg end completions)
|
||||
(message "No gnuplot keywords complete '%s'" pattern)
|
||||
nil)))
|
||||
(list (condition-case _err
|
||||
(save-excursion (backward-sexp 1) (point))
|
||||
(error (point)))
|
||||
(point) gnuplot-keywords))
|
||||
|
||||
|
||||
(defun gnuplot-info-lookup-symbol (symbol &optional mode)
|
||||
@@ -2109,7 +1988,7 @@ according to the value of `gnuplot-info-display'."
|
||||
(list nil (message
|
||||
"Help is not available. The gnuplot info file could not be found.")))))
|
||||
|
||||
(when (and (featurep 'info-look) gnuplot-keywords)
|
||||
(when gnuplot-keywords
|
||||
(unless symbol (setq symbol "Commands"))
|
||||
(save-window-excursion
|
||||
(info-lookup-symbol symbol mode))
|
||||
@@ -2164,8 +2043,8 @@ shown."
|
||||
(setq topic (downcase (match-string 2 string))
|
||||
term (match-string 4 string))
|
||||
(if (string= topic "terminal") (setq topic (downcase term)))))
|
||||
(cond ((and (fboundp 'gnuplot-gui-set-options-and-insert)
|
||||
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>
|
||||
@@ -2241,16 +2120,16 @@ a list:
|
||||
(use-local-map gnuplot-mode-map)
|
||||
(setq major-mode 'gnuplot-mode
|
||||
mode-name "Gnuplot")
|
||||
(set (make-local-variable 'comment-start) "# ")
|
||||
(set (make-local-variable 'comment-end) "")
|
||||
(set (make-local-variable 'comment-column) 32)
|
||||
(set (make-local-variable 'comment-start-skip) "#[ \t]*")
|
||||
(set (make-local-variable 'indent-line-function) 'gnuplot-indent-line)
|
||||
(setq-local comment-start "# ")
|
||||
(setq-local comment-end "")
|
||||
(setq-local comment-column 32)
|
||||
(setq-local comment-start-skip "#[ \t]*")
|
||||
(setq-local indent-line-function #'gnuplot-indent-line)
|
||||
|
||||
(set (make-local-variable 'beginning-of-defun-function) 'gnuplot-beginning-of-defun)
|
||||
(set (make-local-variable 'end-of-defun-function) 'gnuplot-end-of-continuation)
|
||||
(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)
|
||||
|
||||
@@ -2258,22 +2137,16 @@ a list:
|
||||
(gnuplot-setup-info-look)) ;; <SE>
|
||||
|
||||
;; Add syntax-propertizing functions to search for strings and comments
|
||||
(set (make-local-variable 'syntax-propertize-function)
|
||||
#'gnuplot-syntax-propertize)
|
||||
(setq-local syntax-propertize-function #'gnuplot-syntax-propertize)
|
||||
(add-hook 'syntax-propertize-extend-region-functions
|
||||
#'gnuplot-syntax-propertize-extend-region nil t)
|
||||
|
||||
;; Set up font-lock
|
||||
(setq font-lock-defaults gnuplot-font-lock-defaults)
|
||||
(set (make-local-variable 'font-lock-multiline) t)
|
||||
(set (make-local-variable 'parse-sexp-lookup-properties) t)
|
||||
(setq-local font-lock-multiline t)
|
||||
(setq-local parse-sexp-lookup-properties t)
|
||||
|
||||
(if (fboundp 'widget-create) ; gnuplot-gui
|
||||
(condition-case ()
|
||||
(require 'gnuplot-gui)
|
||||
(error nil)))
|
||||
(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))
|
||||
@@ -2304,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
|
||||
|
||||
Reference in New Issue
Block a user