comparison lisp/minibuf.el @ 422:95016f13131a r21-2-19

Import from CVS: tag r21-2-19
author cvs
date Mon, 13 Aug 2007 11:25:01 +0200
parents 697ef44129c6
children
comparison
equal deleted inserted replaced
421:fff06e11db74 422:95016f13131a
746 746
747 ;;;; completing-read 747 ;;;; completing-read
748 748
749 (defun completing-read (prompt table 749 (defun completing-read (prompt table
750 &optional predicate require-match 750 &optional predicate require-match
751 initial-contents history) 751 initial-contents history default)
752 "Read a string in the minibuffer, with completion. 752 "Read a string in the minibuffer, with completion.
753 Args: PROMPT, TABLE, PREDICATE, REQUIRE-MATCH, INITIAL-CONTENTS, HISTORY. 753 Args: PROMPT, TABLE, PREDICATE, REQUIRE-MATCH, INITIAL-CONTENTS, HISTORY.
754 PROMPT is a string to prompt with; normally it ends in a colon and a space. 754 PROMPT is a string to prompt with; normally it ends in a colon and a space.
755 TABLE is an alist whose elements' cars are strings, or an obarray. 755 TABLE is an alist whose elements' cars are strings, or an obarray.
756 PREDICATE limits completion to a subset of TABLE. 756 PREDICATE limits completion to a subset of TABLE.
768 In that case, HISTVAR is the history list variable to use, 768 In that case, HISTVAR is the history list variable to use,
769 and HISTPOS is the initial position (the position in the list 769 and HISTPOS is the initial position (the position in the list
770 which INITIAL-CONTENTS corresponds to). 770 which INITIAL-CONTENTS corresponds to).
771 If HISTORY is `t', no history will be recorded. 771 If HISTORY is `t', no history will be recorded.
772 Positions are counted starting from 1 at the beginning of the list. 772 Positions are counted starting from 1 at the beginning of the list.
773 DEFAULT, if non-nil, is the default value.
773 Completion ignores case if the ambient value of 774 Completion ignores case if the ambient value of
774 `completion-ignore-case' is non-nil." 775 `completion-ignore-case' is non-nil."
775 (let ((minibuffer-completion-table table) 776 (let ((minibuffer-completion-table table)
776 (minibuffer-completion-predicate predicate) 777 (minibuffer-completion-predicate predicate)
777 (minibuffer-completion-confirm (if (eq require-match 't) nil t)) 778 (minibuffer-completion-confirm (if (eq require-match 't) nil t))
778 (last-exact-completion nil)) 779 (last-exact-completion nil)
779 (read-from-minibuffer prompt 780 ret)
780 initial-contents 781 (setq ret (read-from-minibuffer prompt
781 (if (not require-match) 782 initial-contents
782 minibuffer-local-completion-map 783 (if (not require-match)
783 minibuffer-local-must-match-map) 784 minibuffer-local-completion-map
784 nil 785 minibuffer-local-must-match-map)
785 history))) 786 nil
787 history))
788 (if (and (string= ret "")
789 default)
790 default
791 ret)))
786 792
787 793
788 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 794 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
789 ;;;; Minibuffer completion commands ;;;; 795 ;;;; Minibuffer completion commands ;;;;
790 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 796 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2105 ;; only include these if the mule feature is present. Strangely, 2111 ;; only include these if the mule feature is present. Strangely,
2106 ;; read-coding-system doesn't. 2112 ;; read-coding-system doesn't.
2107 2113
2108 ;;(if (featurep 'mule) 2114 ;;(if (featurep 'mule)
2109 2115
2110 (defun read-coding-system (prompt) 2116 (defun read-coding-system (prompt &optional default-coding-system)
2111 "Read a coding-system (or nil) from the minibuffer. 2117 "Read a coding-system (or nil) from the minibuffer.
2112 Prompting with string PROMPT." 2118 Prompting with string PROMPT.
2113 (intern (completing-read prompt obarray 'find-coding-system t))) 2119 If the user enters null input, return second argument DEFAULT-CODING-SYSTEM."
2120 (intern (completing-read prompt obarray 'find-coding-system t nil nil
2121 default-coding-system)))
2114 2122
2115 (defun read-non-nil-coding-system (prompt) 2123 (defun read-non-nil-coding-system (prompt)
2116 "Read a non-nil coding-system from the minibuffer. 2124 "Read a non-nil coding-system from the minibuffer.
2117 Prompt with string PROMPT." 2125 Prompt with string PROMPT."
2118 (let ((retval (intern ""))) 2126 (let ((retval (intern "")))