diff lisp/minibuf.el @ 430:a5df635868b2 r21-2-23

Import from CVS: tag r21-2-23
author cvs
date Mon, 13 Aug 2007 11:29:08 +0200
parents 3ecd8885ac67
children 9d177e8d4150
line wrap: on
line diff
--- a/lisp/minibuf.el	Mon Aug 13 11:28:16 2007 +0200
+++ b/lisp/minibuf.el	Mon Aug 13 11:29:08 2007 +0200
@@ -344,7 +344,8 @@
                                     keymap
                                     readp
                                     history
-				    abbrev-table)
+				    abbrev-table
+				    default)
   "Read a string from the minibuffer, prompting with string PROMPT.
 If optional second arg INITIAL-CONTENTS is non-nil, it is a string
   to be inserted into the minibuffer before reading input.
@@ -366,6 +367,8 @@
   Positions are counted starting from 1 at the beginning of the list.
 Sixth arg ABBREV-TABLE, if non-nil, becomes the value of `local-abbrev-table'
   in the minibuffer.
+Seventh arg DEFAULT, if non-nil, will be returned when user enters
+  an empty string.
 
 See also the variable completion-highlight-first-word-only for control over
   completion display."
@@ -490,8 +493,13 @@
                (let* ((val (progn (set-buffer buffer)
                                   (if minibuffer-exit-hook
                                       (run-hooks 'minibuffer-exit-hook))
-                                  (buffer-string)))
-                    (histval val)
+                                  (if (and (eq (char-after (point-min)) nil)
+					   default)
+				      default
+				    (buffer-string))))
+		      (histval (if (and default (string= val ""))
+				   default
+				 val))
                       (err nil))
                  (if readp
                      (condition-case e
@@ -784,7 +792,9 @@
 					minibuffer-local-completion-map
 				      minibuffer-local-must-match-map)
 				    nil
-				    history))
+				    history
+				    nil
+				    default))
     (if (and (string= ret "")
 	     default)
 	default
@@ -1434,7 +1444,8 @@
         result)
     (while (progn
              (setq result (completing-read prompt alist nil require-match
-					   nil 'buffer-history))
+					   nil 'buffer-history 
+					   (if default (buffer-name default))))
              (cond ((not (equal result ""))
                     nil)
                    ((not require-match)