GNU bug report logs - #7752
24.0.50; [PATCH] Add completing-read-function

Previous Next

Package: emacs;

Reported by: Leo <sdl.web <at> gmail.com>

Date: Tue, 28 Dec 2010 23:37:02 UTC

Severity: wishlist

Tags: patch

Found in version 24.0.50

Fixed in version 24.1.

Done: Leo <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7752 in the body.
You can then email your comments to 7752 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca, drew.adams <at> oracle.com, bug-gnu-emacs <at> gnu.org:
bug#7752; Package emacs. (Tue, 28 Dec 2010 23:37:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to monnier <at> iro.umontreal.ca, drew.adams <at> oracle.com, bug-gnu-emacs <at> gnu.org. (Tue, 28 Dec 2010 23:37:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.50; [PATCH] Add completing-read-function
Date: Tue, 28 Dec 2010 23:43:25 +0000
[Message part 1 (text/plain, inline)]
The attached patch (against 24) adds completing-read-function for
customising the behaviour of completing-read. See also the discussion in
emacs-devel: http://thread.gmane.org/gmane.emacs.devel/134000

(I am in the process of setting up an Emacs bzr repo and familiarising
 myself with bzr. I expect to be able to commit this myself in the
 beginning of February.)

Leo

[0001-New-variable-completing-read-function.patch (text/x-diff, inline)]
From 6370abee847415199be3bb86503af408c160b2b9 Mon Sep 17 00:00:00 2001
From: Leo <sdl.web <at> gmail.com>
Date: Tue, 28 Dec 2010 23:30:48 +0000
Subject: [PATCH] New variable completing-read-function

that can be used to customize completing-read.
---
 lisp/ChangeLog |    5 +++++
 lisp/ido.el    |    8 ++++----
 src/ChangeLog  |    6 ++++++
 src/minibuf.c  |   33 ++++++++++++++++++++++++++++++++-
 4 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f9443cf..a778f94 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2010-12-28  Leo <sdl.web <at> gmail.com>
+
+	* ido.el (ido-read-internal): Fix.
+	(ido-completing-read): Fix compatibility with completing-read.
+
 2010-12-28  Chong Yidong  <cyd <at> stupidchicken.com>
 
 	* tool-bar.el (tool-bar-setup): Remove :enable conditions, which
diff --git a/lisp/ido.el b/lisp/ido.el
index 84ae931..ff38ae7 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -1984,7 +1984,7 @@ If INITIAL is non-nil, it specifies the initial input string."
 	(setq ido-exit nil)
 	(setq ido-final-text
 	      (catch 'ido
-		(completing-read
+		(completing-read-default
 		 (ido-make-prompt item prompt)
 		 '(("dummy" . 1)) nil nil ; table predicate require-match
 		 (prog1 ido-text-init (setq ido-text-init nil))	;initial-contents
@@ -4741,13 +4741,13 @@ See `read-directory-name' for additional parameters."
 	  (concat ido-current-directory filename)))))
 
 ;;;###autoload
-(defun ido-completing-read (prompt choices &optional predicate require-match initial-input hist def)
+(defun ido-completing-read (prompt choices &optional predicate require-match initial-input hist def inherit-input-method)
   "Ido replacement for the built-in `completing-read'.
 Read a string in the minibuffer with ido-style completion.
 PROMPT is a string to prompt with; normally it ends in a colon and a space.
 CHOICES is a list of strings which are the possible completions.
-PREDICATE is currently ignored; it is included to be compatible
- with `completing-read'.
+PREDICATE and INHERIT-INPUT-METHOD is currently ignored; it is included
+ to be compatible with `completing-read'.
 If REQUIRE-MATCH is non-nil, the user is not allowed to exit unless
  the input is (or completes to) an element of CHOICES or is null.
  If the input is null, `ido-completing-read' returns DEF, or an empty
diff --git a/src/ChangeLog b/src/ChangeLog
index 96e697a..02c60a2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2010-12-28  Leo <sdl.web <at> gmail.com>
+
+	* minibuf.c (completing-read-function): New variable.
+	(completing-read-default): Rename from completing-read.
+	(completing-read): Call completing-read-function.
+
 2010-12-28  Andreas Schwab  <schwab <at> linux-m68k.org>
 
 	* xterm.h (x_alloc_lighter_color_for_widget): Restore declaration.
diff --git a/src/minibuf.c b/src/minibuf.c
index 0f3def6..ee6b56b 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -130,6 +130,7 @@ Lisp_Object Vminibuffer_completion_table, Qminibuffer_completion_table;
 Lisp_Object Vminibuffer_completion_predicate, Qminibuffer_completion_predicate;
 Lisp_Object Vminibuffer_completion_confirm, Qminibuffer_completion_confirm;
 Lisp_Object Vminibuffer_completing_file_name;
+Lisp_Object Qcompleting_read_default, Vcompleting_read_function;
 
 Lisp_Object Quser_variable_p;
 
@@ -1726,7 +1727,27 @@ If INHERIT-INPUT-METHOD is non-nil, the minibuffer inherits
   the current input method and the setting of `enable-multibyte-characters'.
 
 Completion ignores case if the ambient value of
-  `completion-ignore-case' is non-nil.  */)
+  `completion-ignore-case' is non-nil.
+
+See also `completing-read-function'.  */)
+  (Lisp_Object prompt, Lisp_Object collection, Lisp_Object predicate, Lisp_Object require_match, Lisp_Object initial_input, Lisp_Object hist, Lisp_Object def, Lisp_Object inherit_input_method)
+{
+  Lisp_Object args[9];
+  args[0] = Vcompleting_read_function;
+  args[1] = prompt;
+  args[2] = collection;
+  args[3] = predicate;
+  args[4] = require_match;
+  args[5] = initial_input;
+  args[6] = hist;
+  args[7] = def;
+  args[8] = inherit_input_method;
+  return Ffuncall (9, args);
+}
+
+DEFUN ("completing-read-default", Fcompleting_read_default, Scompleting_read_default, 2, 8, 0,
+       doc: /* Default method for reading from the minibuffer with completion.
+See `completing-read' for the meaning of the arguments.  */)
   (Lisp_Object prompt, Lisp_Object collection, Lisp_Object predicate, Lisp_Object require_match, Lisp_Object initial_input, Lisp_Object hist, Lisp_Object def, Lisp_Object inherit_input_method)
 {
   Lisp_Object val, histvar, histpos, position;
@@ -2024,6 +2045,9 @@ syms_of_minibuf (void)
   minibuf_save_list = Qnil;
   staticpro (&minibuf_save_list);
 
+  Qcompleting_read_default = intern_c_string ("completing-read-default");
+  staticpro (&Qcompleting_read_default);
+
   Qcompletion_ignore_case = intern_c_string ("completion-ignore-case");
   staticpro (&Qcompletion_ignore_case);
 
@@ -2163,6 +2187,12 @@ If the value is `confirm-after-completion', the user may exit with an
 	       doc: /* Non-nil means completing file names.  */);
   Vminibuffer_completing_file_name = Qnil;
 
+  DEFVAR_LISP ("completing-read-function",
+               &Vcompleting_read_function,
+               doc: /* The function called by `completing-read' to do the work.
+It should accept the same arguments as `completing-read'.  */);
+  Vcompleting_read_function = Qcompleting_read_default;
+
   DEFVAR_LISP ("minibuffer-help-form", &Vminibuffer_help_form,
 	       doc: /* Value that `help-form' takes on inside the minibuffer.  */);
   Vminibuffer_help_form = Qnil;
@@ -2238,5 +2268,6 @@ properties.  */);
   defsubr (&Stest_completion);
   defsubr (&Sassoc_string);
   defsubr (&Scompleting_read);
+  defsubr (&Scompleting_read_default);
 }
 
-- 
1.7.3.4


Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7752; Package emacs. (Wed, 29 Dec 2010 02:49:01 GMT) Full text and rfc822 format available.

Message #8 received at 7752 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Leo <sdl.web <at> gmail.com>
Cc: 7752 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#7752: 24.0.50; [PATCH] Add completing-read-function
Date: Tue, 28 Dec 2010 21:54:51 -0500
> The attached patch (against 24) adds completing-read-function for
> customising the behaviour of completing-read. See also the discussion in
> emacs-devel: http://thread.gmane.org/gmane.emacs.devel/134000

Looks good.

> (I am in the process of setting up an Emacs bzr repo and familiarising
>  myself with bzr. I expect to be able to commit this myself in the
>  beginning of February.)

Hopefully, it'll take you less time than that to commit your
first patch.


        Stefan




Reply sent to Leo <sdl.web <at> gmail.com>:
You have taken responsibility. (Mon, 21 Mar 2011 15:10:03 GMT) Full text and rfc822 format available.

Notification sent to Leo <sdl.web <at> gmail.com>:
bug acknowledged by developer. (Mon, 21 Mar 2011 15:10:04 GMT) Full text and rfc822 format available.

Message #13 received at 7752-done <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: 7752-done <at> debbugs.gnu.org
Subject: Re: bug#7752: 24.0.50; [PATCH] Add completing-read-function
Date: Mon, 21 Mar 2011 23:08:55 +0800
Version: 24.1.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 19 Apr 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 124 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.