]> code.delx.au - gnu-emacs/blobdiff - lisp/minibuf-eldef.el
(normal-splash-screen, fancy-splash-screens-1): Add a reference to the Lisp
[gnu-emacs] / lisp / minibuf-eldef.el
index 866869d99c77dbd11f1e0beaa8e8e104a8b1482a..d1c407c6eca4d6e6f69b4fa1372e7b543bb6ec7e 100644 (file)
@@ -1,6 +1,7 @@
 ;;; minibuf-eldef.el --- Only show defaults in prompts when applicable
 ;;
-;; Copyright (C) 2000 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006 Free Software Foundation, Inc.
 ;;
 ;; Author: Miles Bader <miles@gnu.org>
 ;; Keywords: convenience
@@ -19,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 ;;
@@ -36,7 +37,7 @@
 ;;; Code:
 
 (defvar minibuffer-default-in-prompt-regexps
-  '(("\\( (default\\>.*)\\):? \\'" . 1))
+  '(("\\( (default\\>.*)\\):? \\'" . 1) ("\\( \\[.*\\]\\):? *\\'" . 1))
   "*A list of regexps matching the parts of minibuffer prompts showing defaults.
 When `minibuffer-electric-default-mode' is active, these regexps are
 used to identify the portions of prompts to elide.
@@ -51,7 +52,7 @@ regexp subexpression that matched.")
 
 ;; A list of minibuffers to which we've added a post-command-hook.
 (defvar minibuf-eldef-frobbed-minibufs nil)
-      
+
 ;;; The following are all local variables in the minibuffer
 
 ;; Input pre-inserted into the minibuffer before the user can edit it.
@@ -76,15 +77,14 @@ regexp subexpression that matched.")
 (defun minibuf-eldef-setup-minibuffer ()
   "Set up a minibuffer for `minibuffer-electric-default-mode'.
 The prompt and initial input should already have been inserted."
-  (let ((prompt (field-string-no-properties (point-min)))
-       (regexps minibuffer-default-in-prompt-regexps)
+  (let ((regexps minibuffer-default-in-prompt-regexps)
        (match nil)
        (inhibit-point-motion-hooks t))
     (save-excursion
       (save-restriction
        ;; Narrow to only the prompt
        (goto-char (point-min))
-       (narrow-to-region (point) (field-end))
+       (narrow-to-region (point) (minibuffer-prompt-end))
        ;; See the prompt contains a default input indicator
        (while regexps
          (setq match (pop regexps))
@@ -101,7 +101,7 @@ The prompt and initial input should already have been inserted."
            (make-overlay (match-beginning match) (match-end match)))
       (setq minibuf-eldef-showing-default-in-prompt t)
       (setq minibuf-eldef-initial-input
-           (field-string-no-properties (point-max)))
+           (minibuffer-contents-no-properties))
       (setq minibuf-eldef-initial-buffer-length (point-max))
       (add-to-list 'minibuf-eldef-frobbed-minibufs (current-buffer))
       (add-hook 'post-command-hook #'minibuf-eldef-update-minibuffer nil t))))
@@ -114,7 +114,7 @@ This is intended to be used as a minibuffer post-command-hook for
 been set up by `minibuf-eldef-setup-minibuffer'."
   (unless (eq minibuf-eldef-showing-default-in-prompt
              (and (= (point-max) minibuf-eldef-initial-buffer-length)
-                  (string-equal (field-string-no-properties (point-max))
+                  (string-equal (minibuffer-contents-no-properties)
                                 minibuf-eldef-initial-input)))
     ;; swap state
     (setq minibuf-eldef-showing-default-in-prompt
@@ -133,7 +133,7 @@ been set up by `minibuf-eldef-setup-minibuffer'."
 ;;; functions be already defined.  [This is arguably a bug in d-m-m]
 ;;;###autoload
 (define-minor-mode minibuffer-electric-default-mode
-  "Toggle Minibuffer Electric Default mode
+  "Toggle Minibuffer Electric Default mode.
 When active, minibuffer prompts that show a default value only show the
 default when it's applicable -- that is, when hitting RET would yield
 the default value.  If the user modifies the input such that hitting RET
@@ -158,4 +158,5 @@ Returns non-nil if the new state is enabled."
 
 (provide 'minibuf-eldef)
 
+;; arch-tag: 7e421fae-c275-4729-b0da-7836af377d3d
 ;;; minibuf-eldef.el ends here