aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-02-22 23:38:29 -0500
committerStefan Monnier2012-02-22 23:38:29 -0500
commitb291b57241a4e46013db0989991635364fb4beb2 (patch)
tree200c070183634546660f8e59eab34515ff9aadda
parent371fb833991718335bf5b3661bd4bb209c51ba11 (diff)
downloademacs-b291b57241a4e46013db0989991635364fb4beb2.tar.gz
emacs-b291b57241a4e46013db0989991635364fb4beb2.zip
* lisp/minibuffer.el (completion-table-with-context): Fix inf-loop.
Reported by Aaron S. Hawley <aaron.s.hawley@gmail.com>.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/minibuffer.el49
2 files changed, 30 insertions, 24 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4be77a90c6c..ee3c486d5ff 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12012-02-23 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * minibuffer.el (completion-table-with-context): Fix inf-loop.
4 Reported by Aaron S. Hawley <aaron.s.hawley@gmail.com>.
5
12012-02-23 Glenn Morris <rgm@gnu.org> 62012-02-23 Glenn Morris <rgm@gnu.org>
2 7
3 * emacs-lisp/authors.el (authors-aliases, authors-fixed-case) 8 * emacs-lisp/authors.el (authors-aliases, authors-fixed-case)
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 8564cc2009b..2414baf8e3c 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -226,30 +226,31 @@ case sensitive instead."
226 226
227(defun completion-table-with-context (prefix table string pred action) 227(defun completion-table-with-context (prefix table string pred action)
228 ;; TODO: add `suffix' maybe? 228 ;; TODO: add `suffix' maybe?
229 ;; Notice that `pred' may not be a function in some abusive cases. 229 (let ((pred
230 (when (functionp pred) 230 (if (not (functionp pred))
231 (setq pred 231 ;; Notice that `pred' may not be a function in some abusive cases.
232 ;; Predicates are called differently depending on the nature of 232 pred
233 ;; the completion table :-( 233 ;; Predicates are called differently depending on the nature of
234 (cond 234 ;; the completion table :-(
235 ((vectorp table) ;Obarray. 235 (cond
236 (lambda (sym) (funcall pred (concat prefix (symbol-name sym))))) 236 ((vectorp table) ;Obarray.
237 ((hash-table-p table) 237 (lambda (sym) (funcall pred (concat prefix (symbol-name sym)))))
238 (lambda (s _v) (funcall pred (concat prefix s)))) 238 ((hash-table-p table)
239 ((functionp table) 239 (lambda (s _v) (funcall pred (concat prefix s))))
240 (lambda (s) (funcall pred (concat prefix s)))) 240 ((functionp table)
241 (t ;Lists and alists. 241 (lambda (s) (funcall pred (concat prefix s))))
242 (lambda (s) 242 (t ;Lists and alists.
243 (funcall pred (concat prefix (if (consp s) (car s) s)))))))) 243 (lambda (s)
244 (if (eq (car-safe action) 'boundaries) 244 (funcall pred (concat prefix (if (consp s) (car s) s)))))))))
245 (let* ((len (length prefix)) 245 (if (eq (car-safe action) 'boundaries)
246 (bound (completion-boundaries string table pred (cdr action)))) 246 (let* ((len (length prefix))
247 (list* 'boundaries (+ (car bound) len) (cdr bound))) 247 (bound (completion-boundaries string table pred (cdr action))))
248 (let ((comp (complete-with-action action table string pred))) 248 (list* 'boundaries (+ (car bound) len) (cdr bound)))
249 (cond 249 (let ((comp (complete-with-action action table string pred)))
250 ;; In case of try-completion, add the prefix. 250 (cond
251 ((stringp comp) (concat prefix comp)) 251 ;; In case of try-completion, add the prefix.
252 (t comp))))) 252 ((stringp comp) (concat prefix comp))
253 (t comp))))))
253 254
254(defun completion-table-with-terminator (terminator table string pred action) 255(defun completion-table-with-terminator (terminator table string pred action)
255 "Construct a completion table like TABLE but with an extra TERMINATOR. 256 "Construct a completion table like TABLE but with an extra TERMINATOR.