emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 41bb375: Fixes: debbugs:19250


From: Stefan Monnier
Subject: [Emacs-diffs] master 41bb375: Fixes: debbugs:19250
Date: Wed, 03 Dec 2014 18:42:36 +0000

branch: master
commit 41bb375cc71c70fbe9b405272abf0d5f345eee2a
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    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).
---
 etc/NEWS                     |    5 +++++
 lisp/ChangeLog               |   14 ++++++++++++--
 lisp/minibuffer.el           |   18 +++++++++++-------
 lisp/pcmpl-gnu.el            |    4 ++--
 lisp/progmodes/elisp-mode.el |    2 +-
 lisp/progmodes/octave.el     |   14 +++++++-------
 6 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 9786f3a..f3890a5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b79b918..a70917e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
+2014-12-03  Stefan Monnier  <address@hidden>
+
+       * 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  <address@hidden>
 
        * 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
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index c9ce381..0bee13b 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -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.
diff --git a/lisp/pcmpl-gnu.el b/lisp/pcmpl-gnu.el
index bcab1f7..3d769b1 100644
--- a/lisp/pcmpl-gnu.el
+++ b/lisp/pcmpl-gnu.el
@@ -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))))
 
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 2be81a5..ba70f90 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -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)
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index 25b0815..7d96363 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]