From ea7826ba52b21e97c27ccf4859eaeb8dca61319b Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Thu, 27 Feb 2014 00:01:22 -0800 Subject: [PATCH] Small doc related to new completion functions * doc/lispref/minibuf.texi (Programmed Completion): Mention completion-table-with-cache. * lisp/minibuffer.el (completion-table-dynamic) (completion-table-with-cache): Doc fixes. * etc/NEWS: Related markup. Unrelated copyedit. --- doc/lispref/ChangeLog | 5 +++++ doc/lispref/minibuf.texi | 7 +++++++ etc/NEWS | 6 ++++-- lisp/ChangeLog | 3 +++ lisp/minibuffer.el | 14 +++++++++----- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 6a105a03b3b..6eb45dc3f4f 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,8 @@ +2014-02-27 Glenn Morris + + * minibuf.texi (Programmed Completion): + Mention completion-table-with-cache. + 2014-02-25 Glenn Morris * display.texi (Window Systems): diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index d618912de8a..fded0dfdd92 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -1814,6 +1814,13 @@ possible completions of it. You can think of and the interface for programmed completion functions. @end defun +@defun completion-table-with-cache function &optional ignore-case +This is a wrapper for @code{completion-table-dynamic} that saves the +last argument-result pair. This means that multiple lookups with the +same argument only need to call @var{function} once. This can be useful +when a slow operation is involved, such as calling an external process. +@end defun + @node Completion in Buffers @subsection Completion in Ordinary Buffers @cindex inline completion diff --git a/etc/NEWS b/etc/NEWS index b224457b233..5a1863254d4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1183,15 +1183,17 @@ Either use `completion-all-completions', which returns highlighted strings (including for partial or substring completion), or call `completion-hilit-commonality' to add the highlight. ++++ *** New function `completion-table-with-cache' is a wrapper for `completion-table-dynamic' that caches the result of the last lookup. ++++ *** New function `completion-table-merge' to combine several completion tables by merging their completions. ** New minor modes `prettify-symbols-mode' and `global-prettify-symbols-mode' -let you enable symbol prettification (replacing a string like "lambda" with -the Greek lambda character). +display specified symbols as composed characters. E.g., in Emacs Lisp mode, +this replaces the string "lambda" with the Greek lambda character. ** Terminal changes diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0198c0f8dc5..66514f7488c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2014-02-27 Glenn Morris + * minibuffer.el (completion-table-dynamic) + (completion-table-with-cache): Doc fixes. + * emacs-lisp/crm.el (crm-default-separator, crm-separator) (completing-read-multiple): Doc fixes. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 95e45260f85..88ab94f0521 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -179,7 +179,9 @@ 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 -`all-completions'. See Info node `(elisp)Programmed Completion'." +`all-completions'. See Info node `(elisp)Programmed Completion'. + +See also the related function `completion-table-with-cache'." (lambda (string pred action) (if (or (eq (car-safe action) 'boundaries) (eq action 'metadata)) ;; `fun' is not supposed to return another function but a plain old @@ -191,13 +193,15 @@ that can be used as the COLLECTION argument to `try-completion' and (complete-with-action action (funcall fun string) string pred))))) (defun completion-table-with-cache (fun &optional ignore-case) - "Create dynamic completion table from FUN, with cache. -This wraps `completion-table-dynamic', but saves the last + "Create dynamic completion table from function FUN, with cache. +This is a wrapper for `completion-table-dynamic' that saves the last argument-result pair from FUN, so that several lookups with the same argument (or with an argument that starts with the first one) -only need to call FUN once. Most useful when FUN performs a relatively -slow operation, such as calling an external process (see Bug#11906). +only need to call FUN once. This can be useful when FUN performs a +relatively slow operation, such as calling an external process. + When IGNORE-CASE is non-nil, FUN is expected to be case-insensitive." + ;; See eg bug#11906. (let* (last-arg last-result (new-fun (lambda (arg) -- 2.11.4.GIT