branch: elpa/gnuplot commit 2a772492845d353d79fc2b224a09eaae5e848ccb Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Simplify handling of gnuplot info keywords --- gnuplot-gui.el | 4 ++-- gnuplot.el | 70 ++++++++++++++++++++-------------------------------------- 2 files changed, 26 insertions(+), 48 deletions(-) diff --git a/gnuplot-gui.el b/gnuplot-gui.el index 3fa79aa7aa..0ba3bffc4e 100644 --- a/gnuplot-gui.el +++ b/gnuplot-gui.el @@ -1645,8 +1645,8 @@ is non-nil if this is a \\='range widget." "A link to an info file for the Gnuplot GUI." :action '(lambda (widget &optional event) (let ((gnuplot-info-display 'frame)) - (if gnuplot-keywords-pending ; <HW> - (gnuplot-setup-info-look)) + (when (eq gnuplot--info-keywords 'pending) + (gnuplot--setup-info-look)) (gnuplot-info-lookup-symbol (widget-value widget) 'gnuplot-mode)))) diff --git a/gnuplot.el b/gnuplot.el index ba52663f28..3ac042d274 100644 --- a/gnuplot.el +++ b/gnuplot.el @@ -246,20 +246,10 @@ beginning the continued command." ;; with info-look, there is no need to carry this list around -- it ;; can be generated on the fly appropriate to the currently installed ;; version of gnuplot.info -(defvar gnuplot-keywords nil +(defvar gnuplot--info-keywords 'pending "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-pending t ;; <HW> - "A boolean which gets toggled when the info file is probed.") -(defcustom gnuplot-keywords-when 'deferred ;; 'immediately - "This variable controls when the info file is parsed. -The choices are immediately upon starting `gnuplot-mode' or the first -time that data is needed." - :group 'gnuplot - :type - '(radio (const :tag "Parse info file when gnuplot-mode starts" immediately) - (const :tag "Parse info file the first time it is needed" deferred))) (defcustom gnuplot-use-context-sensitive-completion t "Non-nil if `gnuplot-context-sensitive-mode' should be enabled by default. @@ -432,8 +422,7 @@ non-nil." "---" ["Insert filename at point" gnuplot-insert-filename t] ["Negate set option" gnuplot-negate-option t] - ["Keyword help" gnuplot-info-lookup-symbol - (or gnuplot-keywords gnuplot-keywords-pending)] + ["Keyword help" gnuplot-info-lookup-symbol] ["Quick help for thing at point" gnuplot-help-function gnuplot-context-sensitive-mode] ["Info documentation on thing at point" @@ -1305,8 +1294,7 @@ this function is attached to `gnuplot-after-plot-hook'" "---" ["Insert filename at point" gnuplot-insert-filename t] ["Negate set option" gnuplot-negate-option t] - ["Keyword help" gnuplot-info-lookup-symbol - (or gnuplot-keywords gnuplot-keywords-pending)] + ["Keyword help" gnuplot-info-lookup-symbol] ["Quick help for thing at point" gnuplot-help-function gnuplot-context-sensitive-mode] ["Info documentation on thing at point" @@ -1788,13 +1776,9 @@ Negatable options are defined in `gnuplot-keywords-negatable-options'." ;; set up stuff for info-look (as suggested by <SE>) ;; modified with suggestion from <MS> -(defun gnuplot-setup-info-look () +(defun gnuplot--setup-info-look () "Setup info-look in the gnuplot buffer. - -Also set the variable `gnuplot-keywords' and do something sensible if -info-look was not available." - (interactive) - (setq gnuplot-keywords-pending nil) +Also set the variable `gnuplot--info-keywords'." ;; TODO Update info layout (let ((doc-spec '(("(gnuplot)Command_Index" nil "[_a-zA-Z0-9]+") @@ -1817,10 +1801,10 @@ info-look was not available." ;; 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--info-keywords (gnuplot--set-keywords-list))) (defun gnuplot--set-keywords-list () - "Set `gnuplot-keywords' from `info-lookup-cache'. + "Set `gnuplot--info-keywords' from `info-lookup-cache'. Return a list of keywords." (let* ((list (cdr (assoc 'symbol info-lookup-cache))) (list (cdr (cdr (assoc 'gnuplot-mode list)))) @@ -1856,16 +1840,16 @@ Return a list of keywords." "Return completions of keyword preceding point. Uses the cache of keywords generated by `info-lookup'. See -`gnuplot-setup-info-look'. If non-nil, the return value is in the form +`gnuplot--setup-info-look'. If non-nil, the return value is in the form \(BEGIN END COMPLETIONS) where BEGIN and END are buffer positions and COMPLETIONS is a list." - (if gnuplot-keywords-pending ; <HW> - (gnuplot-setup-info-look)) + (when (eq gnuplot--info-keywords 'pending) + (gnuplot--setup-info-look)) (list (condition-case _err (save-excursion (backward-sexp 1) (point)) (error (point))) - (point) gnuplot-keywords)) + (point) gnuplot--info-keywords)) (defun gnuplot-info-lookup-symbol (symbol &optional mode) @@ -1875,20 +1859,16 @@ Takes SYMBOL and MODE as arguments exactly as `gnuplot--adjust-info-display' to display the info buffer according to the value of `gnuplot-info-display'." (interactive - (cond (gnuplot-keywords - (info-lookup-interactive-arguments 'symbol)) - (gnuplot-keywords-pending ; <HW> - (gnuplot-setup-info-look) - (info-lookup-interactive-arguments 'symbol)) - (t - (list nil (message - "Help is not available. The gnuplot info file could not be found."))))) - - (when gnuplot-keywords - (unless symbol (setq symbol "Commands")) - (save-window-excursion - (info-lookup-symbol symbol mode)) - (gnuplot--adjust-info-display))) + (progn + (when (eq gnuplot--info-keywords 'pending) + (gnuplot--setup-info-look)) + (info-lookup-interactive-arguments 'symbol))) + (when (eq gnuplot--info-keywords 'pending) + (gnuplot--setup-info-look)) + (unless symbol (setq symbol "Commands")) + (save-window-excursion + (info-lookup-symbol symbol mode)) + (gnuplot--adjust-info-display)) (defun gnuplot--adjust-info-display () "Displays the *info* buffer in a window or frame. @@ -1943,8 +1923,8 @@ shown." (fboundp 'gnuplot-gui-set-options-and-insert)) (gnuplot-gui-set-options-and-insert)) (gnuplot-insertions-show-help-flag - (if gnuplot-keywords-pending ; <HW> - (gnuplot-setup-info-look)) + (when (eq gnuplot--info-keywords 'pending) + (gnuplot--setup-info-look)) (gnuplot-info-lookup-symbol topic))))) (defun gnuplot-toggle-info-display () @@ -2019,9 +1999,6 @@ a list: (set-syntax-table gnuplot-mode-syntax-table) - (when (eq gnuplot-keywords-when 'immediately) ; <HW> - (gnuplot-setup-info-look)) ;; <SE> - ;; Add syntax-propertizing functions to search for strings and comments (setq-local syntax-propertize-function #'gnuplot--syntax-propertize) (add-hook 'syntax-propertize-extend-region-functions @@ -2085,6 +2062,7 @@ following in your .emacs file: (define-obsolete-function-alias 'gnuplot-set-display-mode #'gnuplot--set-display-mode "0.8.1") (define-obsolete-function-alias 'gnuplot-set-keywords-list #'gnuplot--set-keywords-list "0.8.1") (define-obsolete-function-alias 'gnuplot-setup-comint-for-image-mode #'gnuplot--setup-comint-for-image-mode "0.8.1") +(define-obsolete-function-alias 'gnuplot-setup-info-look #'gnuplot--setup-info-look "0.8.1") (define-obsolete-function-alias 'gnuplot-split-string #'gnuplot--split-string "0.8.1") (define-obsolete-function-alias 'gnuplot-syntax-propertize-extend-region #'gnuplot--syntax-propertize-extend-region "0.8.1")