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)
|
||||
|
||||
Reference in New Issue
Block a user