Fixes: debbugs:19250

* lisp/minibuffer.el (completion-table-dynamic): Add arg `switch-buffer'

and change default to stay in the minibuffer when called from
the minibuffer.
(lazy-completion-table): Use this new argument to preserve the
old behavior.

* lisp/progmodes/elisp-mode.el (elisp--local-variables): Don't burp on
incorrect lexical elements (bug#19250).
This commit is contained in:
Stefan Monnier 2014-12-03 13:42:20 -05:00
parent e148a1eaca
commit 41bb375cc7
6 changed files with 38 additions and 19 deletions

View file

@ -363,6 +363,11 @@ helper functions) obsolete.
* Incompatible Lisp Changes in Emacs 25.1
** completion-table-dynamic stays in the minibuffer.
If you want the old behavior of calling the function in the buffer
from which the minibuffer was entered, call it with the new argument
`switch-buffer'.
** window-configurations no longer record the buffers's marks.
** inhibit-modification-hooks now also inhibits lock-file checks, as well as

View file

@ -1,3 +1,14 @@
2014-12-03 Stefan Monnier <monnier@iro.umontreal.ca>
* minibuffer.el (completion-table-dynamic): Add arg `switch-buffer'
and change default to stay in the minibuffer when called from
the minibuffer (bug#19250).
(lazy-completion-table): Use this new argument to preserve the
old behavior.
* progmodes/elisp-mode.el (elisp--local-variables): Don't burp on
incorrect lexical elements (bug#19250).
2014-12-03 Eric S. Raymond <esr@snark.thyrsus.com>
* files.el (file-tree-walk): Lisp translation of ANSI ftw(3).
@ -23,8 +34,7 @@
* vc-hooks.el: Bind vc-delete-file to Ctrl-x v delete.
* vc.el (vc-expand-dirs): Now takes a second BACKEND argument,
improving behavior on directories using multiple file-oriented
VCSes.
improving behavior on directories using multiple file-oriented VCSes.
* vc/vc.el and all backends: API simplification; clear-headers
is no longer a public method. It is now local to the one place

View file

@ -169,13 +169,15 @@ ACTION can be one of nil, t or `lambda'."
(t 'test-completion))
string table pred))))
(defun completion-table-dynamic (fun)
(defun completion-table-dynamic (fun &optional switch-buffer)
"Use function FUN as a dynamic completion table.
FUN is called with one argument, the string for which completion is required,
and it should return an alist containing all the intended possible completions.
This alist may be a full list of possible completions so that FUN can ignore
the value of its argument. If completion is performed in the minibuffer,
FUN will be called in the buffer from which the minibuffer was entered.
the value of its argument.
If SWITCH-BUFFER is non-nil and completion is performed in the
minibuffer, FUN will be called in the buffer from which the minibuffer
was entered.
The result of the `completion-table-dynamic' form is a function
that can be used as the COLLECTION argument to `try-completion' and
@ -187,9 +189,10 @@ See also the related function `completion-table-with-cache'."
;; `fun' is not supposed to return another function but a plain old
;; completion table, whose boundaries are always trivial.
nil
(with-current-buffer (let ((win (minibuffer-selected-window)))
(if (window-live-p win) (window-buffer win)
(current-buffer)))
(with-current-buffer (if (not switch-buffer) (current-buffer)
(let ((win (minibuffer-selected-window)))
(if (window-live-p win) (window-buffer win)
(current-buffer))))
(complete-with-action action (funcall fun string) string pred)))))
(defun completion-table-with-cache (fun &optional ignore-case)
@ -228,7 +231,8 @@ You should give VAR a non-nil `risky-local-variable' property."
(lambda (,str)
(when (functionp ,var)
(setq ,var (funcall #',fun)))
,var))))
,var)
'do-switch-buffer)))
(defun completion-table-case-fold (table &optional dont-fold)
"Return new completion TABLE that is case insensitive.

View file

@ -323,8 +323,8 @@
(let ((file (pcomplete-arg 1)))
(completion-table-dynamic
(lambda (_string)
(pcmpl-gnu-with-file-buffer file
(mapcar #'tar-header-name tar-parse-info)))))
(pcmpl-gnu-with-file-buffer
file (mapcar #'tar-header-name tar-parse-info)))))
(pcomplete-entries))
nil 'identity))))

View file

@ -293,7 +293,7 @@ Blank lines separate paragraphs. Semicolons start comments.
(let* ((sexp (condition-case nil
(car (read-from-string
(concat txt "elisp--witness--lisp" closer)))
(end-of-file nil)))
((invalid-read-syntax end-of-file) nil)))
(macroexpand-advice (lambda (expander form &rest args)
(condition-case nil
(apply expander form args)

View file

@ -45,13 +45,13 @@
(defun completion-table-with-cache (fun &optional ignore-case)
;; See eg bug#11906.
(let* (last-arg last-result
(new-fun
(lambda (arg)
(if (and last-arg (string-prefix-p last-arg arg ignore-case))
last-result
(prog1
(setq last-result (funcall fun arg))
(setq last-arg arg))))))
(new-fun
(lambda (arg)
(if (and last-arg (string-prefix-p last-arg arg ignore-case))
last-result
(prog1
(setq last-result (funcall fun arg))
(setq last-arg arg))))))
(completion-table-dynamic new-fun)))))
(eval-when-compile
(unless (fboundp 'setq-local)