@@ -335,13 +335,20 @@ command line to provide smarter completion and documentation
335335suggestions."
336336 :group 'gnuplot
337337 :type 'boolean
338- :initialize 'custom-set-default
339- :set (lambda (_sym value )
338+ :set (lambda (sym value )
339+ (set sym value)
340+ (cond
341+ (value
342+ (add-hook 'gnuplot-mode-hook 'gnuplot-context-sensitive-mode nil nil )
343+ (add-hook 'gnuplot-comint-mode-hook 'gnuplot-context-sensitive-mode nil nil ))
344+ (t
345+ (remove-hook 'gnuplot-mode-hook 'gnuplot-context-sensitive-mode )
346+ (remove-hook 'gnuplot-comint-mode-hook 'gnuplot-context-sensitive-mode )))
340347 (dolist (buffer (buffer-list ))
341348 (with-current-buffer buffer
342- (when (derived-mode-p 'gnuplot-mode 'gnuplot-comint-mode )
343- ( gnuplot-context-sensitive-mode
344- (if value 1 0 ))))))
349+ (when (and ( derived-mode-p 'gnuplot-mode 'gnuplot-comint-mode )
350+ ( fboundp ' gnuplot-context-sensitive-mode))
351+ (gnuplot-context-sensitive-mode (if value 1 0 ))))))
345352 :link '(emacs-commentary-link " gnuplot-context" ))
346353
347354(defcustom gnuplot-eldoc-mode nil
@@ -512,7 +519,6 @@ non-nil."
512519
513520; ;; --- insertions variables and menus
514521
515- ; ;(load-library "gnuplot-insertions")
516522(defvar gnuplot-mode-insertions-menu nil )
517523(defvar gnuplot-insertions-menu nil
518524 " Menu for insertions in `gnuplot-mode' .
@@ -1953,88 +1959,6 @@ Return a list of keywords."
19531959 " Perform completion in Gnuplot buffers."
19541960 (funcall gnuplot-completion-at-point-function))
19551961
1956- (defvar gnuplot-eldoc-hash nil
1957- " ElDoc strings for gnuplot-mode.
1958-
1959- These have to be compiled from the Gnuplot source tree using
1960- `doc2texi.el' ." )
1961-
1962- ; ; Enable and disable context-sensitive completion
1963- (define-minor-mode gnuplot-context-sensitive-mode
1964- " Use context-sensitive completion and help in gnuplot-mode.
1965-
1966- When context-sensitive mode is enabled, gnuplot-mode tries to
1967- provide more useful completions and help suggestions for built-in
1968- keywords and functions by parsing each command as you type. It
1969- attempts to take into account Gnuplot's many abbreviated
1970- keywords. For example, with point at the end of a line reading
1971- \" plot 'datafile' w \" , typing \\ [completion-at-point] will pop
1972- up a list of plotting styles.
1973-
1974- Key bindings:
1975-
1976- \\ [completion-at-point] will complete the keyword at point based
1977- on its context in the command. To make keyword completion work on
1978- pressing TAB, set `tab-always-indent' to `complete' , or customize
1979- `gnuplot-tab-completion' to make this automatic in gnuplot-mode
1980- buffers.
1981-
1982- \\ [gnuplot-info-at-point] will try to find the most relevant
1983- Gnuplot info node for the construction at point, prompting for a
1984- node name if nothing is found.
1985-
1986- \\ [gnuplot-help-function] will pop up a brief summary of the
1987- syntax at point in the minibuffer. To have one-line syntax
1988- summaries appear in the echo area as you type, toggle
1989- `eldoc-mode' or customize `gnuplot-eldoc-mode' .
1990-
1991- To choose whether to use this mode by default in Gnuplot buffers,
1992- customize the variable
1993- `gnuplot-use-context-sensitive-completion' .
1994-
1995- Note: help strings for eldoc-mode and \\ [gnuplot-help-function]
1996- need to be provided in an Emacs-readable form by the Gnuplot
1997- distribution. See gnuplot-context.el for details."
1998- :keymap
1999- `((,(kbd " C-c C-/" ) . gnuplot-help-function)
2000- (,(kbd " C-c C-d" ) . gnuplot-info-at-point))
2001- (unless (derived-mode-p 'gnuplot-mode 'gnuplot-comint-mode )
2002- (message " Gnuplot context-sensitive mode works only in Gnuplot-mode buffers " )
2003- (setq gnuplot-context-sensitive-mode nil ))
2004- (if gnuplot-context-sensitive-mode
2005- ; ; Turn on
2006- (progn
2007- (load-library " gnuplot-context" )
2008- (load-library " eldoc" )
2009- (setq gnuplot-completion-at-point-function #'gnuplot-context-completion-at-point )
2010-
2011- ; ; Setup Eldoc
2012- (setq-local eldoc-documentation-function #'gnuplot-eldoc-function )
2013- (eldoc-add-command 'completion-at-point ) ; Check for eldoc after completion
2014-
2015- ; ; Try to load Eldoc strings
2016- (when gnuplot-eldoc-mode
2017- (unless gnuplot-eldoc-hash
2018- (condition-case nil
2019- (load-library " gnuplot-eldoc" )
2020- (error
2021- (message " gnuplot-eldoc.el not found. Install it from the Gnuplot distribution. " )
2022- (setq gnuplot-eldoc-hash nil
2023- gnuplot-eldoc-mode nil ))))
2024-
2025- (if gnuplot-eldoc-hash
2026- (eldoc-mode 1 )
2027- (eldoc-mode 0 )))
2028-
2029- ; ; Set up tab-to-complete
2030- (when gnuplot-tab-completion
2031- (setq-local tab-always-indent 'complete )))
2032-
2033- ; ; Turn off
2034- (setq gnuplot-completion-at-point-function #'gnuplot-completion-at-point-info-look )
2035- (setq eldoc-documentation-function nil )
2036- (eldoc-mode 0 )))
2037-
20381962; ; Older completion method using info-look
20391963(defun gnuplot-completion-at-point-info-look ()
20401964 " Return completions of keyword preceding point.
0 commit comments