1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-06 03:40:56 -08:00

New variable completing-read-function to customize completing-read

This commit is contained in:
Leo Liu 2011-03-20 18:35:27 +08:00
parent 7d476bdec5
commit 3ec03f7e46
5 changed files with 51 additions and 5 deletions

View file

@ -81,6 +81,9 @@ error, its exit status is 1.
** Completion can cycle, depending on completion-cycle-threshold. ** Completion can cycle, depending on completion-cycle-threshold.
** `completing-read' can be customized using the new variable
`completing-read-function'
** auto-mode-case-fold is now enabled by default. ** auto-mode-case-fold is now enabled by default.
+++ +++

View file

@ -1,3 +1,8 @@
2011-03-20 Leo <sdl.web@gmail.com>
* ido.el (ido-read-internal): Use completing-read-default.
(ido-completing-read): Fix compatibility with completing-read.
2011-03-20 Christian Ohler <ohler@gnu.org> 2011-03-20 Christian Ohler <ohler@gnu.org>
* emacs-lisp/ert.el (ert-run-tests-batch): Remove unused variable. * emacs-lisp/ert.el (ert-run-tests-batch): Remove unused variable.

View file

@ -1983,7 +1983,7 @@ If INITIAL is non-nil, it specifies the initial input string."
(setq ido-exit nil) (setq ido-exit nil)
(setq ido-final-text (setq ido-final-text
(catch 'ido (catch 'ido
(completing-read (completing-read-default
(ido-make-prompt item prompt) (ido-make-prompt item prompt)
'(("dummy" . 1)) nil nil ; table predicate require-match '(("dummy" . 1)) nil nil ; table predicate require-match
(prog1 ido-text-init (setq ido-text-init nil)) ;initial-contents (prog1 ido-text-init (setq ido-text-init nil)) ;initial-contents
@ -4740,13 +4740,13 @@ See `read-directory-name' for additional parameters."
(concat ido-current-directory filename))))) (concat ido-current-directory filename)))))
;;;###autoload ;;;###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'. "Ido replacement for the built-in `completing-read'.
Read a string in the minibuffer with ido-style completion. 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. 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. CHOICES is a list of strings which are the possible completions.
PREDICATE is currently ignored; it is included to be compatible PREDICATE and INHERIT-INPUT-METHOD is currently ignored; it is included
with `completing-read'. to be compatible with `completing-read'.
If REQUIRE-MATCH is non-nil, the user is not allowed to exit unless 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. 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 If the input is null, `ido-completing-read' returns DEF, or an empty

View file

@ -1,3 +1,9 @@
2011-03-20 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.
2011-03-19 Juanma Barranquero <lekktu@gmail.com> 2011-03-19 Juanma Barranquero <lekktu@gmail.com>
* xfaces.c (Fx_load_color_file): * xfaces.c (Fx_load_color_file):

View file

@ -72,6 +72,8 @@ Lisp_Object Qcompletion_ignore_case;
Lisp_Object Qminibuffer_completion_table; Lisp_Object Qminibuffer_completion_table;
Lisp_Object Qminibuffer_completion_predicate; Lisp_Object Qminibuffer_completion_predicate;
Lisp_Object Qminibuffer_completion_confirm; Lisp_Object Qminibuffer_completion_confirm;
Lisp_Object Qcompleting_read_default;
Lisp_Object Vcompleting_read_function;
Lisp_Object Quser_variable_p; Lisp_Object Quser_variable_p;
Lisp_Object Qminibuffer_default; Lisp_Object Qminibuffer_default;
@ -1674,7 +1676,27 @@ If INHERIT-INPUT-METHOD is non-nil, the minibuffer inherits
the current input method and the setting of `enable-multibyte-characters'. the current input method and the setting of `enable-multibyte-characters'.
Completion ignores case if the ambient value of 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 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; Lisp_Object val, histvar, histpos, position;
@ -1972,6 +1994,9 @@ syms_of_minibuf (void)
minibuf_save_list = Qnil; minibuf_save_list = Qnil;
staticpro (&minibuf_save_list); 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"); Qcompletion_ignore_case = intern_c_string ("completion-ignore-case");
staticpro (&Qcompletion_ignore_case); staticpro (&Qcompletion_ignore_case);
@ -2116,6 +2141,12 @@ If the value is `confirm-after-completion', the user may exit with an
doc: /* Non-nil means completing file names. */); doc: /* Non-nil means completing file names. */);
Vminibuffer_completing_file_name = Qnil; 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, DEFVAR_LISP ("minibuffer-help-form", Vminibuffer_help_form,
doc: /* Value that `help-form' takes on inside the minibuffer. */); doc: /* Value that `help-form' takes on inside the minibuffer. */);
Vminibuffer_help_form = Qnil; Vminibuffer_help_form = Qnil;
@ -2191,4 +2222,5 @@ properties. */);
defsubr (&Stest_completion); defsubr (&Stest_completion);
defsubr (&Sassoc_string); defsubr (&Sassoc_string);
defsubr (&Scompleting_read); defsubr (&Scompleting_read);
defsubr (&Scompleting_read_default);
} }