aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2005-06-13 20:45:50 +0000
committerStefan Monnier2005-06-13 20:45:50 +0000
commit9ed49065194cae011a97dfa49b08e3b60eb241d7 (patch)
treef648443369bdaa7152c938c1027cc49c5313e726
parentd95da8d3b21026a6ed276288495fbd5b81df3c8c (diff)
downloademacs-9ed49065194cae011a97dfa49b08e3b60eb241d7.tar.gz
emacs-9ed49065194cae011a97dfa49b08e3b60eb241d7.zip
(complete-in-turn): New macro.
(dynamic-completion-table, lazy-completion-table): Add debug info.
-rw-r--r--lisp/subr.el20
1 files changed, 19 insertions, 1 deletions
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.
1923The result of the `dynamic-completion-table' form is a function 1923The result of the `dynamic-completion-table' form is a function
1924that can be used as the ALIST argument to `try-completion' and 1924that can be used as the ALIST argument to `try-completion' and
1925`all-completion'. See Info node `(elisp)Programmed Completion'." 1925`all-completion'. See Info node `(elisp)Programmed Completion'."
1926 (declare (debug (lambda-expr)))
1926 (let ((win (make-symbol "window")) 1927 (let ((win (make-symbol "window"))
1927 (string (make-symbol "string")) 1928 (string (make-symbol "string"))
1928 (predicate (make-symbol "predicate")) 1929 (predicate (make-symbol "predicate"))
@@ -1944,12 +1945,29 @@ ARGS. FUN must return the completion table that will be stored in VAR.
1944If completion is requested in the minibuffer, FUN will be called in the buffer 1945If completion is requested in the minibuffer, FUN will be called in the buffer
1945from which the minibuffer was entered. The return value of 1946from which the minibuffer was entered. The return value of
1946`lazy-completion-table' must be used to initialize the value of VAR." 1947`lazy-completion-table' must be used to initialize the value of VAR."
1948 (declare (debug (symbol lambda-expr def-body)))
1947 (let ((str (make-symbol "string"))) 1949 (let ((str (make-symbol "string")))
1948 `(dynamic-completion-table 1950 `(dynamic-completion-table
1949 (lambda (,str) 1951 (lambda (,str)
1950 (unless (listp ,var) 1952 (unless (listp ,var)
1951 (setq ,var (funcall ',fun ,@args))) 1953 (setq ,var (,fun ,@args)))
1952 ,var)))) 1954 ,var))))
1955
1956(defmacro complete-in-turn (a b)
1957 "Create a completion table that first tries completion in A and then in B.
1958A and B should not be costly (or side-effecting) expressions."
1959 (declare (debug (def-form def-form)))
1960 `(lambda (string predicate mode)
1961 (cond
1962 ((eq mode t)
1963 (or (all-completions string ,a predicate)
1964 (all-completions string ,b predicate)))
1965 ((eq mode nil)
1966 (or (try-completion string ,a predicate)
1967 (try-completion string ,b predicate)))
1968 (t
1969 (or (test-completion string ,a predicate)
1970 (test-completion string ,b predicate))))))
1953 1971
1954;;; Matching and substitution 1972;;; Matching and substitution
1955 1973