;;; Code:
(defgroup minibuffer nil
- "Controling the behaviour of the minibuffer."
+ "Controling the behavior of the minibuffer."
:group 'environment)
CODE, which says what kind of things to do.
CODE can be nil, t or `lambda'.
nil means to return the best completion of STRING, nil if there is none,
- or t if it is was already a unique completion.
+ or t if it is already a unique completion.
t means to return a list of all possible completions of STRING.
`lambda' means to return t if STRING is a valid completion as it stands.")
to be inserted into the minibuffer before reading input.
If INITIAL-CONTENTS is (STRING . POSITION), the initial input
is STRING, but point is placed POSITION characters into the string.
-Third arg KEYMAP is a keymap to use whilst reading;
+Third arg KEYMAP is a keymap to use while reading;
if omitted or nil, the default is `minibuffer-local-map'.
If fourth arg READ is non-nil, then interpret the result as a lisp object
and return that object:
(defun completing-read (prompt table
&optional predicate require-match
- initial-contents history)
+ initial-contents history default)
"Read a string in the minibuffer, with completion.
Args: PROMPT, TABLE, PREDICATE, REQUIRE-MATCH, INITIAL-CONTENTS, HISTORY.
PROMPT is a string to prompt with; normally it ends in a colon and a space.
which INITIAL-CONTENTS corresponds to).
If HISTORY is `t', no history will be recorded.
Positions are counted starting from 1 at the beginning of the list.
+DEFAULT, if non-nil, is the default value.
Completion ignores case if the ambient value of
`completion-ignore-case' is non-nil."
(let ((minibuffer-completion-table table)
(minibuffer-completion-predicate predicate)
(minibuffer-completion-confirm (if (eq require-match 't) nil t))
- (last-exact-completion nil))
- (read-from-minibuffer prompt
- initial-contents
- (if (not require-match)
- minibuffer-local-completion-map
- minibuffer-local-must-match-map)
- nil
- history)))
+ (last-exact-completion nil)
+ ret)
+ (setq ret (read-from-minibuffer prompt
+ initial-contents
+ (if (not require-match)
+ minibuffer-local-completion-map
+ minibuffer-local-must-match-map)
+ nil
+ history))
+ (if (and (string= ret "")
+ default)
+ default
+ ret)))
\f
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(olen (length string))
new
n o ch)
- (cond ((eq system-type 'vax-vms)
- string)
- ((not (string-match regexp string))
- string)
- (t
- (setq n 1)
- (while (string-match regexp string (match-end 0))
- (setq n (1+ n)))
- (setq new (make-string (+ olen n) ?$))
- (setq n 0 o 0)
- (while (< o olen)
- (setq ch (aref string o))
- (aset new n ch)
- (setq o (1+ o) n (1+ n))
- (if (eq ch ?$)
- ;; already aset by make-string initial-value
- (setq n (1+ n))))
- new))))
+ (if (not (string-match regexp string))
+ string
+ (setq n 1)
+ (while (string-match regexp string (match-end 0))
+ (setq n (1+ n)))
+ (setq new (make-string (+ olen n) ?$))
+ (setq n 0 o 0)
+ (while (< o olen)
+ (setq ch (aref string o))
+ (aset new n ch)
+ (setq o (1+ o) n (1+ n))
+ (if (eq ch ?$)
+ ;; already aset by make-string initial-value
+ (setq n (1+ n))))
+ new)))
(defun read-file-name-2 (history prompt dir default
must-match initial-contents
(length dir)))
(t
(un-substitute-in-file-name dir))))
- (val (let ((completion-ignore-case (or completion-ignore-case
- (eq system-type 'vax-vms))))
+ (val
;; Hateful, broken, case-sensitive un*x
;;; (completing-read prompt
;;; completer
;;; must-match
;;; insert
;;; history)
- ;; #### - this is essentially the guts of completing read.
- ;; There should be an elegant way to pass a pair of keymaps to
- ;; completing read, but this will do for now. All sins are
- ;; relative. --Stig
- (let ((minibuffer-completion-table completer)
- (minibuffer-completion-predicate dir)
- (minibuffer-completion-confirm (if (eq must-match 't)
- nil t))
- (last-exact-completion nil))
- (read-from-minibuffer prompt
- insert
- (if (not must-match)
- read-file-name-map
- read-file-name-must-match-map)
- nil
- history)))
+ ;; #### - this is essentially the guts of completing read.
+ ;; There should be an elegant way to pass a pair of keymaps to
+ ;; completing read, but this will do for now. All sins are
+ ;; relative. --Stig
+ (let ((minibuffer-completion-table completer)
+ (minibuffer-completion-predicate dir)
+ (minibuffer-completion-confirm (if (eq must-match 't)
+ nil t))
+ (last-exact-completion nil))
+ (read-from-minibuffer prompt
+ insert
+ (if (not must-match)
+ read-file-name-map
+ read-file-name-must-match-map)
+ nil
+ history))
))
;;; ;; Kludge! Put "/foo/bar" on history rather than "/default//foo/bar"
;;; (let ((hist (cond ((not history) 'minibuffer-history)
(alist #'(lambda ()
(mapcar #'(lambda (x)
(cons (substring x 0 (string-match "=" x))
- 'nil))
+ nil))
process-environment))))
(cond ((eq action 'lambda)
(concat "$" p)
(concat head "$" p)))
(all-completions env (funcall alist))))
- (t ;; 'nil
+ (t ;; nil
;; complete
(let* ((e (funcall alist))
(val (try-completion env e)))
;; all completions
(mapcar #'un-substitute-in-file-name
(file-name-all-completions name dir)))
- (t;; 'nil
+ (t;; nil
;; complete
(let* ((d (or dir default-directory))
(val (file-name-completion name d)))
nil
'directories))))
(mapcar fn
- (cond ((eq system-type 'vax-vms)
- l)
- (t
- ;; Wretched unix
- (delete "." l))))))))
+ ;; Wretched unix
+ (delete "." l))))))
(cond ((eq action 'lambda)
;; complete?
(if (not orig)
;;(if (featurep 'mule)
-(defun read-coding-system (prompt)
+(defun read-coding-system (prompt &optional default-coding-system)
"Read a coding-system (or nil) from the minibuffer.
-Prompting with string PROMPT."
- (intern (completing-read prompt obarray 'find-coding-system t)))
+Prompting with string PROMPT.
+If the user enters null input, return second argument DEFAULT-CODING-SYSTEM."
+ (intern (completing-read prompt obarray 'find-coding-system t nil nil
+ default-coding-system)))
(defun read-non-nil-coding-system (prompt)
"Read a non-nil coding-system from the minibuffer.