aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorLeo Liu2011-06-23 11:35:05 +0800
committerLeo Liu2011-06-23 11:35:05 +0800
commit4e3232657c0fe231e594fb75bea2daee2388b978 (patch)
tree8508117d2c665def57e5c020f0b9eeef96bc25f1 /lisp
parent5c62d133468c354b47a1643092add8292e084765 (diff)
downloademacs-4e3232657c0fe231e594fb75bea2daee2388b978.tar.gz
emacs-4e3232657c0fe231e594fb75bea2daee2388b978.zip
Move completing-read-function and completing-read-default to elisp
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/minibuffer.el35
2 files changed, 39 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 89b33dc7a62..b29a5989791 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12011-06-22 Leo Liu <sdl.web@gmail.com>
2
3 * minibuffer.el (completing-read-function)
4 (completing-read-default): Move from minibuf.c
5
12011-06-22 Richard Stallman <rms@gnu.org> 62011-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.
2716It 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.
2722See `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