Subject: bug#7752: closed (Re: bug#7752: 24.0.50; [PATCH] Add completing-read-function)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 21 Mar 2011 15:10:04 +0000

Your bug report

#7752: 24.0.50; [PATCH] Add completing-read-function

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
7752: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7752
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#7752: 24.0.50; [PATCH] Add completing-read-function
From: Leo <[email-masked]>
To: [email-masked]
Date: Mon, 21 Mar 2011 23:08:55 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 24.1.

Subject: 24.0.50; [PATCH] Add completing-read-function
From: Leo <[email-masked]>
To: [email-masked]
Date: Tue, 28 Dec 2010 23:43:25 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

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

>From 6370abee847415199be3bb86503af408c160b2b9 Mon Sep 17 00:00:00 2001
From: Leo <[email-masked]>
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 <[email-masked]>
+
+	* ido.el (ido-read-internal): Fix.
+	(ido-completing-read): Fix compatibility with completing-read.
+
 2010-12-28  Chong Yidong  <[email-masked]>
 
 	* 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 <[email-masked]>
+
+	* 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  <[email-masked]>
 
 	* 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