[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/subr.el,v
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/subr.el,v |
Date: |
Fri, 11 Apr 2008 22:28:04 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Stefan Monnier <monnier> 08/04/11 22:28:03
Index: subr.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/subr.el,v
retrieving revision 1.590
retrieving revision 1.591
diff -u -b -r1.590 -r1.591
--- subr.el 10 Apr 2008 11:06:02 -0000 1.590
+++ subr.el 11 Apr 2008 22:28:02 -0000 1.591
@@ -2688,92 +2688,6 @@
(with-current-buffer ,old-buffer
(set-case-table ,old-case-table))))))
-;;;; Constructing completion tables.
-
-(defun complete-with-action (action table string pred)
- "Perform completion ACTION.
-STRING is the string to complete.
-TABLE is the completion table, which should not be a function.
-PRED is a completion predicate.
-ACTION can be one of nil, t or `lambda'."
- ;; (assert (not (functionp table)))
- (funcall
- (cond
- ((null action) 'try-completion)
- ((eq action t) 'all-completions)
- (t 'test-completion))
- string table pred))
-
-(defmacro dynamic-completion-table (fun)
- "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 result of the `dynamic-completion-table' form is a function
-that can be used as the ALIST argument to `try-completion' and
-`all-completion'. See Info node `(elisp)Programmed Completion'."
- (declare (debug (lambda-expr)))
- (let ((win (make-symbol "window"))
- (string (make-symbol "string"))
- (predicate (make-symbol "predicate"))
- (mode (make-symbol "mode")))
- `(lambda (,string ,predicate ,mode)
- (with-current-buffer (let ((,win (minibuffer-selected-window)))
- (if (window-live-p ,win) (window-buffer ,win)
- (current-buffer)))
- (complete-with-action ,mode (,fun ,string) ,string ,predicate)))))
-
-(defmacro lazy-completion-table (var fun)
- ;; We used to have `&rest args' where `args' were evaluated late (at the
- ;; time of the call to `fun'), which was counter intuitive. But to get
- ;; them to be evaluated early, we have to either use lexical-let (which is
- ;; not available in subr.el) or use `(lambda (,str) ...) which prevents the
use
- ;; of lexical-let in the callers.
- ;; So we just removed the argument. Callers can then simply use either of:
- ;; (lazy-completion-table var (lambda () (fun x y)))
- ;; or
- ;; (lazy-completion-table var `(lambda () (fun ',x ',y)))
- ;; or
- ;; (lexical-let ((x x)) ((y y))
- ;; (lazy-completion-table var (lambda () (fun x y))))
- ;; depending on the behavior they want.
- "Initialize variable VAR as a lazy completion table.
-If the completion table VAR is used for the first time (e.g., by passing VAR
-as an argument to `try-completion'), the function FUN is called with no
-arguments. FUN must return the completion table that will be stored in VAR.
-If completion is requested in the minibuffer, FUN will be called in the buffer
-from which the minibuffer was entered. The return value of
-`lazy-completion-table' must be used to initialize the value of VAR.
-
-You should give VAR a non-nil `risky-local-variable' property."
- (declare (debug (symbol lambda-expr)))
- (let ((str (make-symbol "string")))
- `(dynamic-completion-table
- (lambda (,str)
- (when (functionp ,var)
- (setq ,var (,fun)))
- ,var))))
-
-(defmacro complete-in-turn (a b)
- "Create a completion table that first tries completion in A and then in B.
-A and B should not be costly (or side-effecting) expressions."
- (declare (debug (def-form def-form)))
- `(lambda (string predicate mode)
- (cond
- ((eq mode t)
- (or (all-completions string ,a predicate)
- (all-completions string ,b predicate)))
- ((eq mode nil)
- (or (try-completion string ,a predicate)
- (try-completion string ,b predicate)))
- (t
- (or (test-completion string ,a predicate)
- (test-completion string ,b predicate))))))
-
;;; Matching and match data.
(defvar save-match-data-internal)
- [Emacs-diffs] Changes to emacs/lisp/subr.el,v, Stefan Monnier, 2008/04/04
- [Emacs-diffs] Changes to emacs/lisp/subr.el,v, Stefan Monnier, 2008/04/05
- [Emacs-diffs] Changes to emacs/lisp/subr.el,v, Stefan Monnier, 2008/04/05
- [Emacs-diffs] Changes to emacs/lisp/subr.el,v, Stefan Monnier, 2008/04/07
- [Emacs-diffs] Changes to emacs/lisp/subr.el,v, Juanma Barranquero, 2008/04/10
- [Emacs-diffs] Changes to emacs/lisp/subr.el,v,
Stefan Monnier <=
- [Emacs-diffs] Changes to emacs/lisp/subr.el,v, Stefan Monnier, 2008/04/19
- [Emacs-diffs] Changes to emacs/lisp/subr.el,v, Stefan Monnier, 2008/04/24