changeset 67818:5a83c9ee8aa6

(lazy-completion-table): Remove argument `args'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 26 Dec 2005 15:57:37 +0000
parents b240a2550f91
children b2e009fc75c5
files lisp/ChangeLog lisp/subr.el lispref/minibuf.texi
diffstat 3 files changed, 39 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Dec 26 15:56:49 2005 +0000
+++ b/lisp/ChangeLog	Mon Dec 26 15:57:37 2005 +0000
@@ -1,3 +1,10 @@
+2005-12-26  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* subr.el (lazy-completion-table): Remove argument `args'.
+
+	* textmodes/bibtex.el (bibtex-strings, bibtex-reference-keys):
+	Don't use the `args' argument of lazy-completion-table.
+
 2005-12-27  Nick Roberts  <nickrob@snap.net.nz>
 
 	* descr-text.el (describe-char): Add optional argument for buffer.
@@ -8,12 +15,12 @@
 
 	* descr-text.el (help-fns): Require.  Don't require button for
 	byte compilation.
-	(describe-text-widget): Add help echo for first button.  Use
-	'help-info for second.
+	(describe-text-widget): Add help echo for first button.
+	Use 'help-info for second.
 	(describe-property-list): Use 'help-argument-name instead of 'italic.
 	(describe-text-category): Prompt in minibuffer.  Call help-setup-xref.
-	(describe-char): Use 'help-character-set.  Add help echo.  Use
-	'help-input-method.  Remove superfluous insert.
+	(describe-char): Use 'help-character-set.  Add help echo.
+	Use 'help-input-method.  Remove superfluous insert.
 
 2005-12-25  Richard M. Stallman  <rms@gnu.org>
 
@@ -35,16 +42,16 @@
 
 	* custom.el (custom-push-theme): Fix docstring.
 
-	* cus-edit.el (custom-variable-set, custom-variable-save,
-	custom-variable-save): Custom-quote widget values.
+	* cus-edit.el (custom-variable-set, custom-variable-save)
+	(custom-variable-save): Custom-quote widget values.
 	(customize-save-variable): Fix custom-push-theme call.
 
 2005-12-24  Eli Zaretskii  <eliz@gnu.org>
 
 	* w32-fns.el (w32-batch-update-autoloads): New function.
 
-	* makefile.w32-in (autoloads, $(lisp)/mh-e/mh-loaddefs.el): Use
-	w32-batch-update-autoloads, and don't setq generated-autoload-file
+	* makefile.w32-in (autoloads, $(lisp)/mh-e/mh-loaddefs.el):
+	Use w32-batch-update-autoloads, and don't setq generated-autoload-file
 	from the command line.
 
 2005-12-23  Chong Yidong  <cyd@stupidchicken.com>
@@ -57,15 +64,15 @@
 	customization" button one line up.
 	(custom-themed): New face.
 	(custom-magic-alist): New value, THEMED, for theme settings.
-	(custom-variable-state-set, custom-face-state-set): Check
-	theme-value instead of saved-value.
+	(custom-variable-state-set, custom-face-state-set):
+	Check theme-value instead of saved-value.
 	(custom-variable-reset-standard, custom-face-reset-standard):
 	Remove theme setting entirely.  Recalculate new values.
 	(custom-variable-set, custom-variable-set)
 	(custom-variable-reset-saved, custom-variable-reset-backup)
 	(custom-face-set, custom-face-reset-saved): Update `user' theme.
 	(custom-variable-save): Fix typos.
-	
+
 2005-12-23  Juri Linkov  <juri@jurta.org>
 
 	* emacs-lisp/edebug.el (edebug-all-defs, edebug-all-forms):
--- a/lisp/subr.el	Mon Dec 26 15:56:49 2005 +0000
+++ b/lisp/subr.el	Mon Dec 26 15:57:37 2005 +0000
@@ -2256,20 +2256,33 @@
           ((not ,mode) (try-completion ,string (,fun ,string) ,predicate))
           (t (test-completion ,string (,fun ,string) ,predicate)))))))
 
-(defmacro lazy-completion-table (var fun &rest args)
+(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 arguments
-ARGS.  FUN must return the completion table that will be stored in VAR.
+If the completion table VAR is used for the first tidme (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."
-  (declare (debug (symbol lambda-expr def-body)))
+  (declare (debug (symbol lambda-expr)))
   (let ((str (make-symbol "string")))
     `(dynamic-completion-table
       (lambda (,str)
         (when (functionp ,var)
-          (setq ,var (,fun ,@args)))
+          (setq ,var (,fun)))
         ,var))))
 
 (defmacro complete-in-turn (a b)
--- a/lispref/minibuf.texi	Mon Dec 26 15:56:49 2005 +0000
+++ b/lispref/minibuf.texi	Mon Dec 26 15:57:37 2005 +0000
@@ -768,13 +768,13 @@
 bound to the value of @code{completion-ignore-case}.
 @end defvar
 
-@defmac lazy-completion-table var fun &rest args
+@defmac lazy-completion-table var fun
 This macro provides a way to initialize the variable @var{var} as a
 collection for completion in a lazy way, not computing its actual
 contents until they are first needed.  You use this macro to produce a
 value that you store in @var{var}.  The actual computation of the
 proper value is done the first time you do completion using @var{var}.
-It is done by calling @var{fun} with the arguments @var{args}.  The
+It is done by calling @var{fun} with no arguments.  The
 value @var{fun} returns becomes the permanent value of @var{var}.
 
 Here are two examples of use: