diff options
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 35 | ||||
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/minibuf.c | 81 |
4 files changed, 45 insertions, 81 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 89b33dc7a62..b29a5989791 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-06-22 Leo Liu <sdl.web@gmail.com> | ||
| 2 | |||
| 3 | * minibuffer.el (completing-read-function) | ||
| 4 | (completing-read-default): Move from minibuf.c | ||
| 5 | |||
| 1 | 2011-06-22 Richard Stallman <rms@gnu.org> | 6 | 2011-06-22 Richard Stallman <rms@gnu.org> |
| 2 | 7 | ||
| 3 | * mail/sendmail.el (mail-bury): If Rmail is in use, return nicely | 8 | * mail/sendmail.el (mail-bury): If Rmail is in use, return nicely |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index a7ffc8d061a..32ddfe99707 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -2710,7 +2710,40 @@ filter out additional entries (because TABLE migth not obey PRED)." | |||
| 2710 | (let ((newstr (completion-initials-expand string table pred))) | 2710 | (let ((newstr (completion-initials-expand string table pred))) |
| 2711 | (when newstr | 2711 | (when newstr |
| 2712 | (completion-pcm-try-completion newstr table pred (length newstr))))) | 2712 | (completion-pcm-try-completion newstr table pred (length newstr))))) |
| 2713 | 2713 | ||
| 2714 | (defvar completing-read-function 'completing-read-default | ||
| 2715 | "The function called by `completing-read' to do its work. | ||
| 2716 | It should accept the same arguments as `completing-read'.") | ||
| 2717 | |||
| 2718 | (defun completing-read-default (prompt collection &optional predicate | ||
| 2719 | require-match initial-input | ||
| 2720 | hist def inherit-input-method) | ||
| 2721 | "Default method for reading from the minibuffer with completion. | ||
| 2722 | See `completing-read' for the meaning of the arguments." | ||
| 2723 | |||
| 2724 | (when (consp initial-input) | ||
| 2725 | (setq initial-input | ||
| 2726 | (cons (car initial-input) | ||
| 2727 | ;; `completing-read' uses 0-based index while | ||
| 2728 | ;; `read-from-minibuffer' uses 1-based index. | ||
| 2729 | (1+ (cdr initial-input))))) | ||
| 2730 | |||
| 2731 | (let* ((minibuffer-completion-table collection) | ||
| 2732 | (minibuffer-completion-predicate predicate) | ||
| 2733 | (minibuffer-completion-confirm (unless (eq require-match t) | ||
| 2734 | require-match)) | ||
| 2735 | (keymap (if require-match | ||
| 2736 | (if (memq minibuffer-completing-file-name '(nil lambda)) | ||
| 2737 | minibuffer-local-must-match-map | ||
| 2738 | minibuffer-local-filename-must-match-map) | ||
| 2739 | (if (memq minibuffer-completing-file-name '(nil lambda)) | ||
| 2740 | minibuffer-local-completion-map | ||
| 2741 | minibuffer-local-filename-completion-map))) | ||
| 2742 | (result (read-from-minibuffer prompt initial-input keymap | ||
| 2743 | nil hist def inherit-input-method))) | ||
| 2744 | (when (and (equal result "") def) | ||
| 2745 | (setq result (if (consp def) (car def) def))) | ||
| 2746 | result)) | ||
| 2714 | 2747 | ||
| 2715 | ;; Miscellaneous | 2748 | ;; Miscellaneous |
| 2716 | 2749 | ||
diff --git a/src/ChangeLog b/src/ChangeLog index 78fca60ca28..c7fd7ef5b9d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-06-22 Leo Liu <sdl.web@gmail.com> | ||
| 2 | |||
| 3 | * minibuf.c (Fcompleting_read_default, Vcompleting_read_function): | ||
| 4 | Move to minibuffer.el. | ||
| 5 | |||
| 1 | 2011-06-22 Paul Eggert <eggert@cs.ucla.edu> | 6 | 2011-06-22 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 7 | ||
| 3 | Fixes for GLYPH_DEBUG found by GCC 4.6.0 static checking. | 8 | Fixes for GLYPH_DEBUG found by GCC 4.6.0 static checking. |
diff --git a/src/minibuf.c b/src/minibuf.c index ca2f22df9ed..110b6562b6c 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -72,7 +72,6 @@ Lisp_Object Qcompletion_ignore_case; | |||
| 72 | static Lisp_Object Qminibuffer_completion_table; | 72 | static Lisp_Object Qminibuffer_completion_table; |
| 73 | static Lisp_Object Qminibuffer_completion_predicate; | 73 | static Lisp_Object Qminibuffer_completion_predicate; |
| 74 | static Lisp_Object Qminibuffer_completion_confirm; | 74 | static Lisp_Object Qminibuffer_completion_confirm; |
| 75 | static Lisp_Object Qcompleting_read_default; | ||
| 76 | static Lisp_Object Quser_variable_p; | 75 | static Lisp_Object Quser_variable_p; |
| 77 | 76 | ||
| 78 | static Lisp_Object Qminibuffer_default; | 77 | static Lisp_Object Qminibuffer_default; |
| @@ -1694,7 +1693,7 @@ See also `completing-read-function'. */) | |||
| 1694 | (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) | 1693 | (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) |
| 1695 | { | 1694 | { |
| 1696 | Lisp_Object args[9]; | 1695 | Lisp_Object args[9]; |
| 1697 | args[0] = Vcompleting_read_function; | 1696 | args[0] = Fsymbol_value (intern ("completing-read-function")); |
| 1698 | args[1] = prompt; | 1697 | args[1] = prompt; |
| 1699 | args[2] = collection; | 1698 | args[2] = collection; |
| 1700 | args[3] = predicate; | 1699 | args[3] = predicate; |
| @@ -1705,76 +1704,6 @@ See also `completing-read-function'. */) | |||
| 1705 | args[8] = inherit_input_method; | 1704 | args[8] = inherit_input_method; |
| 1706 | return Ffuncall (9, args); | 1705 | return Ffuncall (9, args); |
| 1707 | } | 1706 | } |
| 1708 | |||
| 1709 | DEFUN ("completing-read-default", Fcompleting_read_default, Scompleting_read_default, 2, 8, 0, | ||
| 1710 | doc: /* Default method for reading from the minibuffer with completion. | ||
| 1711 | See `completing-read' for the meaning of the arguments. */) | ||
| 1712 | (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) | ||
| 1713 | { | ||
| 1714 | Lisp_Object val, histvar, histpos, position; | ||
| 1715 | Lisp_Object init; | ||
| 1716 | int pos = 0; | ||
| 1717 | int count = SPECPDL_INDEX (); | ||
| 1718 | struct gcpro gcpro1; | ||
| 1719 | |||
| 1720 | init = initial_input; | ||
| 1721 | GCPRO1 (def); | ||
| 1722 | |||
| 1723 | specbind (Qminibuffer_completion_table, collection); | ||
| 1724 | specbind (Qminibuffer_completion_predicate, predicate); | ||
| 1725 | specbind (Qminibuffer_completion_confirm, | ||
| 1726 | EQ (require_match, Qt) ? Qnil : require_match); | ||
| 1727 | |||
| 1728 | position = Qnil; | ||
| 1729 | if (!NILP (init)) | ||
| 1730 | { | ||
| 1731 | if (CONSP (init)) | ||
| 1732 | { | ||
| 1733 | position = Fcdr (init); | ||
| 1734 | init = Fcar (init); | ||
| 1735 | } | ||
| 1736 | CHECK_STRING (init); | ||
| 1737 | if (!NILP (position)) | ||
| 1738 | { | ||
| 1739 | CHECK_NUMBER (position); | ||
| 1740 | /* Convert to distance from end of input. */ | ||
| 1741 | pos = XINT (position) - SCHARS (init); | ||
| 1742 | } | ||
| 1743 | } | ||
| 1744 | |||
| 1745 | if (SYMBOLP (hist)) | ||
| 1746 | { | ||
| 1747 | histvar = hist; | ||
| 1748 | histpos = Qnil; | ||
| 1749 | } | ||
| 1750 | else | ||
| 1751 | { | ||
| 1752 | histvar = Fcar_safe (hist); | ||
| 1753 | histpos = Fcdr_safe (hist); | ||
| 1754 | } | ||
| 1755 | if (NILP (histvar)) | ||
| 1756 | histvar = Qminibuffer_history; | ||
| 1757 | if (NILP (histpos)) | ||
| 1758 | XSETFASTINT (histpos, 0); | ||
| 1759 | |||
| 1760 | val = read_minibuf (NILP (require_match) | ||
| 1761 | ? (NILP (Vminibuffer_completing_file_name) | ||
| 1762 | || EQ (Vminibuffer_completing_file_name, Qlambda) | ||
| 1763 | ? Vminibuffer_local_completion_map | ||
| 1764 | : Vminibuffer_local_filename_completion_map) | ||
| 1765 | : (NILP (Vminibuffer_completing_file_name) | ||
| 1766 | || EQ (Vminibuffer_completing_file_name, Qlambda) | ||
| 1767 | ? Vminibuffer_local_must_match_map | ||
| 1768 | : Vminibuffer_local_filename_must_match_map), | ||
| 1769 | init, prompt, make_number (pos), 0, | ||
| 1770 | histvar, histpos, def, 0, | ||
| 1771 | !NILP (inherit_input_method)); | ||
| 1772 | |||
| 1773 | if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (def)) | ||
| 1774 | val = CONSP (def) ? XCAR (def) : def; | ||
| 1775 | |||
| 1776 | RETURN_UNGCPRO (unbind_to (count, val)); | ||
| 1777 | } | ||
| 1778 | 1707 | ||
| 1779 | Lisp_Object Fassoc_string (register Lisp_Object key, Lisp_Object list, Lisp_Object case_fold); | 1708 | Lisp_Object Fassoc_string (register Lisp_Object key, Lisp_Object list, Lisp_Object case_fold); |
| 1780 | 1709 | ||
| @@ -2013,7 +1942,6 @@ syms_of_minibuf (void) | |||
| 2013 | minibuf_save_list = Qnil; | 1942 | minibuf_save_list = Qnil; |
| 2014 | staticpro (&minibuf_save_list); | 1943 | staticpro (&minibuf_save_list); |
| 2015 | 1944 | ||
| 2016 | DEFSYM (Qcompleting_read_default, "completing-read-default"); | ||
| 2017 | DEFSYM (Qcompletion_ignore_case, "completion-ignore-case"); | 1945 | DEFSYM (Qcompletion_ignore_case, "completion-ignore-case"); |
| 2018 | DEFSYM (Qread_file_name_internal, "read-file-name-internal"); | 1946 | DEFSYM (Qread_file_name_internal, "read-file-name-internal"); |
| 2019 | DEFSYM (Qminibuffer_default, "minibuffer-default"); | 1947 | DEFSYM (Qminibuffer_default, "minibuffer-default"); |
| @@ -2132,12 +2060,6 @@ If the value is `confirm-after-completion', the user may exit with an | |||
| 2132 | doc: /* Non-nil means completing file names. */); | 2060 | doc: /* Non-nil means completing file names. */); |
| 2133 | Vminibuffer_completing_file_name = Qnil; | 2061 | Vminibuffer_completing_file_name = Qnil; |
| 2134 | 2062 | ||
| 2135 | DEFVAR_LISP ("completing-read-function", | ||
| 2136 | Vcompleting_read_function, | ||
| 2137 | doc: /* The function called by `completing-read' to do the work. | ||
| 2138 | It should accept the same arguments as `completing-read'. */); | ||
| 2139 | Vcompleting_read_function = Qcompleting_read_default; | ||
| 2140 | |||
| 2141 | DEFVAR_LISP ("minibuffer-help-form", Vminibuffer_help_form, | 2063 | DEFVAR_LISP ("minibuffer-help-form", Vminibuffer_help_form, |
| 2142 | doc: /* Value that `help-form' takes on inside the minibuffer. */); | 2064 | doc: /* Value that `help-form' takes on inside the minibuffer. */); |
| 2143 | Vminibuffer_help_form = Qnil; | 2065 | Vminibuffer_help_form = Qnil; |
| @@ -2214,5 +2136,4 @@ properties. */); | |||
| 2214 | defsubr (&Stest_completion); | 2136 | defsubr (&Stest_completion); |
| 2215 | defsubr (&Sassoc_string); | 2137 | defsubr (&Sassoc_string); |
| 2216 | defsubr (&Scompleting_read); | 2138 | defsubr (&Scompleting_read); |
| 2217 | defsubr (&Scompleting_read_default); | ||
| 2218 | } | 2139 | } |