From: Stefan Monnier Date: Mon, 13 Jun 2005 20:45:50 +0000 (+0000) Subject: (complete-in-turn): New macro. X-Git-Tag: emacs-pretest-22.0.90~8995 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9ed49065194cae011a97dfa49b08e3b60eb241d7;p=emacs.git (complete-in-turn): New macro. (dynamic-completion-table, lazy-completion-table): Add debug info. --- diff --git a/lisp/subr.el b/lisp/subr.el index ca1d47fede8..9371df1a794 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1923,6 +1923,7 @@ 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")) @@ -1944,12 +1945,29 @@ ARGS. 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." + (declare (debug (symbol lambda-expr def-body))) (let ((str (make-symbol "string"))) `(dynamic-completion-table (lambda (,str) (unless (listp ,var) - (setq ,var (funcall ',fun ,@args))) + (setq ,var (,fun ,@args))) ,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 substitution