Skip to content

Commit 2a77249

Browse files
committed
Simplify handling of gnuplot info keywords
1 parent b0de983 commit 2a77249

File tree

2 files changed

+26
-48
lines changed

2 files changed

+26
-48
lines changed

gnuplot-gui.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,8 +1645,8 @@ is non-nil if this is a \\='range widget."
16451645
"A link to an info file for the Gnuplot GUI."
16461646
:action '(lambda (widget &optional event)
16471647
(let ((gnuplot-info-display 'frame))
1648-
(if gnuplot-keywords-pending ; <HW>
1649-
(gnuplot-setup-info-look))
1648+
(when (eq gnuplot--info-keywords 'pending)
1649+
(gnuplot--setup-info-look))
16501650
(gnuplot-info-lookup-symbol (widget-value widget)
16511651
'gnuplot-mode))))
16521652

gnuplot.el

Lines changed: 24 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -246,20 +246,10 @@ beginning the continued command."
246246
;; with info-look, there is no need to carry this list around -- it
247247
;; can be generated on the fly appropriate to the currently installed
248248
;; version of gnuplot.info
249-
(defvar gnuplot-keywords nil
249+
(defvar gnuplot--info-keywords 'pending
250250
"A list of keywords used in GNUPLOT.
251251
These are set by `gnuplot--set-keywords-list' from the values in
252252
`info-lookup-cache'.")
253-
(defvar gnuplot-keywords-pending t ;; <HW>
254-
"A boolean which gets toggled when the info file is probed.")
255-
(defcustom gnuplot-keywords-when 'deferred ;; 'immediately
256-
"This variable controls when the info file is parsed.
257-
The choices are immediately upon starting `gnuplot-mode' or the first
258-
time that data is needed."
259-
:group 'gnuplot
260-
:type
261-
'(radio (const :tag "Parse info file when gnuplot-mode starts" immediately)
262-
(const :tag "Parse info file the first time it is needed" deferred)))
263253

264254
(defcustom gnuplot-use-context-sensitive-completion t
265255
"Non-nil if `gnuplot-context-sensitive-mode' should be enabled by default.
@@ -432,8 +422,7 @@ non-nil."
432422
"---"
433423
["Insert filename at point" gnuplot-insert-filename t]
434424
["Negate set option" gnuplot-negate-option t]
435-
["Keyword help" gnuplot-info-lookup-symbol
436-
(or gnuplot-keywords gnuplot-keywords-pending)]
425+
["Keyword help" gnuplot-info-lookup-symbol]
437426
["Quick help for thing at point" gnuplot-help-function
438427
gnuplot-context-sensitive-mode]
439428
["Info documentation on thing at point"
@@ -1305,8 +1294,7 @@ this function is attached to `gnuplot-after-plot-hook'"
13051294
"---"
13061295
["Insert filename at point" gnuplot-insert-filename t]
13071296
["Negate set option" gnuplot-negate-option t]
1308-
["Keyword help" gnuplot-info-lookup-symbol
1309-
(or gnuplot-keywords gnuplot-keywords-pending)]
1297+
["Keyword help" gnuplot-info-lookup-symbol]
13101298
["Quick help for thing at point" gnuplot-help-function
13111299
gnuplot-context-sensitive-mode]
13121300
["Info documentation on thing at point"
@@ -1788,13 +1776,9 @@ Negatable options are defined in `gnuplot-keywords-negatable-options'."
17881776

17891777
;; set up stuff for info-look (as suggested by <SE>)
17901778
;; modified with suggestion from <MS>
1791-
(defun gnuplot-setup-info-look ()
1779+
(defun gnuplot--setup-info-look ()
17921780
"Setup info-look in the gnuplot buffer.
1793-
1794-
Also set the variable `gnuplot-keywords' and do something sensible if
1795-
info-look was not available."
1796-
(interactive)
1797-
(setq gnuplot-keywords-pending nil)
1781+
Also set the variable `gnuplot--info-keywords'."
17981782
;; TODO Update info layout
17991783
(let ((doc-spec
18001784
'(("(gnuplot)Command_Index" nil "[_a-zA-Z0-9]+")
@@ -1817,10 +1801,10 @@ info-look was not available."
18171801
;; user will not want them lying around
18181802
(and (get-buffer "info dir") (kill-buffer "info dir"))
18191803
(and (get-buffer "info dir<2>") (kill-buffer "info dir<2>")))
1820-
(setq gnuplot-keywords (gnuplot--set-keywords-list)))
1804+
(setq gnuplot--info-keywords (gnuplot--set-keywords-list)))
18211805

18221806
(defun gnuplot--set-keywords-list ()
1823-
"Set `gnuplot-keywords' from `info-lookup-cache'.
1807+
"Set `gnuplot--info-keywords' from `info-lookup-cache'.
18241808
Return a list of keywords."
18251809
(let* ((list (cdr (assoc 'symbol info-lookup-cache)))
18261810
(list (cdr (cdr (assoc 'gnuplot-mode list))))
@@ -1856,16 +1840,16 @@ Return a list of keywords."
18561840
"Return completions of keyword preceding point.
18571841
18581842
Uses the cache of keywords generated by `info-lookup'. See
1859-
`gnuplot-setup-info-look'. If non-nil, the return value is in the form
1843+
`gnuplot--setup-info-look'. If non-nil, the return value is in the form
18601844
\(BEGIN END COMPLETIONS) where BEGIN and END are buffer
18611845
positions and COMPLETIONS is a list."
18621846

1863-
(if gnuplot-keywords-pending ; <HW>
1864-
(gnuplot-setup-info-look))
1847+
(when (eq gnuplot--info-keywords 'pending)
1848+
(gnuplot--setup-info-look))
18651849
(list (condition-case _err
18661850
(save-excursion (backward-sexp 1) (point))
18671851
(error (point)))
1868-
(point) gnuplot-keywords))
1852+
(point) gnuplot--info-keywords))
18691853

18701854

18711855
(defun gnuplot-info-lookup-symbol (symbol &optional mode)
@@ -1875,20 +1859,16 @@ Takes SYMBOL and MODE as arguments exactly as
18751859
`gnuplot--adjust-info-display' to display the info buffer
18761860
according to the value of `gnuplot-info-display'."
18771861
(interactive
1878-
(cond (gnuplot-keywords
1879-
(info-lookup-interactive-arguments 'symbol))
1880-
(gnuplot-keywords-pending ; <HW>
1881-
(gnuplot-setup-info-look)
1882-
(info-lookup-interactive-arguments 'symbol))
1883-
(t
1884-
(list nil (message
1885-
"Help is not available. The gnuplot info file could not be found.")))))
1886-
1887-
(when gnuplot-keywords
1888-
(unless symbol (setq symbol "Commands"))
1889-
(save-window-excursion
1890-
(info-lookup-symbol symbol mode))
1891-
(gnuplot--adjust-info-display)))
1862+
(progn
1863+
(when (eq gnuplot--info-keywords 'pending)
1864+
(gnuplot--setup-info-look))
1865+
(info-lookup-interactive-arguments 'symbol)))
1866+
(when (eq gnuplot--info-keywords 'pending)
1867+
(gnuplot--setup-info-look))
1868+
(unless symbol (setq symbol "Commands"))
1869+
(save-window-excursion
1870+
(info-lookup-symbol symbol mode))
1871+
(gnuplot--adjust-info-display))
18921872

18931873
(defun gnuplot--adjust-info-display ()
18941874
"Displays the *info* buffer in a window or frame.
@@ -1943,8 +1923,8 @@ shown."
19431923
(fboundp 'gnuplot-gui-set-options-and-insert))
19441924
(gnuplot-gui-set-options-and-insert))
19451925
(gnuplot-insertions-show-help-flag
1946-
(if gnuplot-keywords-pending ; <HW>
1947-
(gnuplot-setup-info-look))
1926+
(when (eq gnuplot--info-keywords 'pending)
1927+
(gnuplot--setup-info-look))
19481928
(gnuplot-info-lookup-symbol topic)))))
19491929

19501930
(defun gnuplot-toggle-info-display ()
@@ -2019,9 +1999,6 @@ a list:
20191999

20202000
(set-syntax-table gnuplot-mode-syntax-table)
20212001

2022-
(when (eq gnuplot-keywords-when 'immediately) ; <HW>
2023-
(gnuplot-setup-info-look)) ;; <SE>
2024-
20252002
;; Add syntax-propertizing functions to search for strings and comments
20262003
(setq-local syntax-propertize-function #'gnuplot--syntax-propertize)
20272004
(add-hook 'syntax-propertize-extend-region-functions
@@ -2085,6 +2062,7 @@ following in your .emacs file:
20852062
(define-obsolete-function-alias 'gnuplot-set-display-mode #'gnuplot--set-display-mode "0.8.1")
20862063
(define-obsolete-function-alias 'gnuplot-set-keywords-list #'gnuplot--set-keywords-list "0.8.1")
20872064
(define-obsolete-function-alias 'gnuplot-setup-comint-for-image-mode #'gnuplot--setup-comint-for-image-mode "0.8.1")
2065+
(define-obsolete-function-alias 'gnuplot-setup-info-look #'gnuplot--setup-info-look "0.8.1")
20882066
(define-obsolete-function-alias 'gnuplot-split-string #'gnuplot--split-string "0.8.1")
20892067
(define-obsolete-function-alias 'gnuplot-syntax-propertize-extend-region #'gnuplot--syntax-propertize-extend-region "0.8.1")
20902068

0 commit comments

Comments
 (0)