Skip to content

Commit cc547ce

Browse files
authored
Fix completion-at-point functions (#74)
According to the Emacs documentation the completion functions should not prefilter the candidates themselves. It is up to the completion UI to perform the filtering. By deferring the filtering to the completion UI various completion styles like substring, flex or orderless can be used. In contrast, the old implementation enforced prefix matching.
1 parent 7138b13 commit cc547ce

File tree

2 files changed

+10
-32
lines changed

2 files changed

+10
-32
lines changed

gnuplot-context.el

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,23 +2054,11 @@ there."
20542054

20552055
(defun gnuplot-context-completion-at-point ()
20562056
"Return completions of keyword preceding point, using context."
2057-
(let* ((end (point))
2058-
(beg
2059-
(save-excursion
2060-
(skip-syntax-backward "w_" (gnuplot-point-at-beginning-of-command))
2061-
(point)))
2062-
(word nil)
2063-
(completions (gnuplot-completions)))
2064-
2065-
(setq word (buffer-substring beg end)
2066-
completions (all-completions word completions))
2067-
2068-
(if completions
2069-
(list beg end completions)
2070-
(if (not (equal "" word))
2071-
(message "No gnuplot keywords complete '%s'" word)
2072-
(message "No completions at point"))
2073-
nil)))
2057+
(list (save-excursion
2058+
(skip-syntax-backward "w_" (gnuplot-point-at-beginning-of-command))
2059+
(point))
2060+
(point)
2061+
(gnuplot-completions)))
20742062

20752063
;; Eldoc help
20762064
(defun gnuplot-eldoc-function ()

gnuplot.el

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ beginning the continued command."
315315
"A list of keywords used in GNUPLOT.
316316
These are set by `gnuplot-set-keywords-list' from the values in
317317
`info-lookup-cache'.")
318-
(defvar gnuplot-keywords-alist nil) ;; For all-completions
319318
(defvar gnuplot-keywords-pending t ;; <HW>
320319
"A boolean which gets toggled when the info file is probed.")
321320
(defcustom gnuplot-keywords-when 'deferred ;; 'immediately
@@ -1944,8 +1943,7 @@ See the comments in `gnuplot-info-hook'."
19441943
;; user will not want them lying around
19451944
(and (get-buffer "info dir") (kill-buffer "info dir"))
19461945
(and (get-buffer "info dir<2>") (kill-buffer "info dir<2>")))
1947-
(setq gnuplot-keywords (gnuplot-set-keywords-list))
1948-
(setq gnuplot-keywords-alist (mapcar 'list gnuplot-keywords)))
1946+
(setq gnuplot-keywords (gnuplot-set-keywords-list)))
19491947

19501948
(defun gnuplot-set-keywords-list ()
19511949
"Set `gnuplot-keywords' from `info-lookup-cache'.
@@ -2078,18 +2076,10 @@ positions and COMPLETIONS is a list."
20782076

20792077
(if gnuplot-keywords-pending ; <HW>
20802078
(gnuplot-setup-info-look))
2081-
(let* ((end (point))
2082-
(beg (condition-case _err
2083-
(save-excursion (backward-sexp 1) (point))
2084-
(error (point))))
2085-
(patt (buffer-substring beg end))
2086-
(pattern (if (string-match "\\([^ \t]*\\)\\s-+$" patt)
2087-
(match-string 1 patt) patt))
2088-
(completions (all-completions pattern gnuplot-keywords-alist)))
2089-
(if completions
2090-
(list beg end completions)
2091-
(message "No gnuplot keywords complete '%s'" pattern)
2092-
nil)))
2079+
(list (condition-case _err
2080+
(save-excursion (backward-sexp 1) (point))
2081+
(error (point)))
2082+
(point) gnuplot-keywords))
20932083

20942084

20952085
(defun gnuplot-info-lookup-symbol (symbol &optional mode)

0 commit comments

Comments
 (0)