unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#7752: 24.0.50; [PATCH] Add completing-read-function
@ 2010-12-28 23:43 Leo
  2010-12-29  2:54 ` Stefan Monnier
  2011-03-21 15:08 ` Leo
  0 siblings, 2 replies; 3+ messages in thread
From: Leo @ 2010-12-28 23:43 UTC (permalink / raw)
  To: 7752

[-- Attachment #1: Type: text/plain, Size: 371 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-New-variable-completing-read-function.patch --]
[-- Type: text/x-diff, Size: 5845 bytes --]

From 6370abee847415199be3bb86503af408c160b2b9 Mon Sep 17 00:00:00 2001
From: Leo <sdl.web@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@gmail.com>
+
+	* ido.el (ido-read-internal): Fix.
+	(ido-completing-read): Fix compatibility with completing-read.
+
 2010-12-28  Chong Yidong  <cyd@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@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@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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#7752: 24.0.50; [PATCH] Add completing-read-function
  2010-12-28 23:43 bug#7752: 24.0.50; [PATCH] Add completing-read-function Leo
@ 2010-12-29  2:54 ` Stefan Monnier
  2011-03-21 15:08 ` Leo
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2010-12-29  2:54 UTC (permalink / raw)
  To: Leo; +Cc: 7752

> 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





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#7752: 24.0.50; [PATCH] Add completing-read-function
  2010-12-28 23:43 bug#7752: 24.0.50; [PATCH] Add completing-read-function Leo
  2010-12-29  2:54 ` Stefan Monnier
@ 2011-03-21 15:08 ` Leo
  1 sibling, 0 replies; 3+ messages in thread
From: Leo @ 2011-03-21 15:08 UTC (permalink / raw)
  To: 7752-done

Version: 24.1.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-21 15:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-28 23:43 bug#7752: 24.0.50; [PATCH] Add completing-read-function Leo
2010-12-29  2:54 ` Stefan Monnier
2011-03-21 15:08 ` Leo

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).