unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Dani Moncayo <dmoncayo@gmail.com>
Cc: 12443@debbugs.gnu.org
Subject: bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy)
Date: Fri, 14 Sep 2012 11:56:50 -0400	[thread overview]
Message-ID: <jwvy5kchakk.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAH8Pv0jv4PE3GbzoS1cb9x+wcORutLoEvogytNKa=tT4PS-BPA@mail.gmail.com> (Dani Moncayo's message of "Fri, 14 Sep 2012 15:53:51 +0200")

> I see no reason for this inconsistency,

Agreed.  The officially sanctioned behavior is to use "(default ...)".

> neither I see the need for the "default " part.

That would make the job of minibuffer-electric-default-mode harder
(more false positives).

> So, hereby I propose to fix this, i.e., to omit the "default " in
> those commands where this is currently shown.

I find the "(default ...)" text to use up too much space for my own taste, so
I use the patch below to rewrite it on-the-fly to "[...]".


        Stefan


Using submit branch file:///home/monnier/src/emacs/bzr/trunk/
=== modified file 'lisp/minibuf-eldef.el'
--- lisp/minibuf-eldef.el	2012-04-09 13:05:48 +0000
+++ lisp/minibuf-eldef.el	2012-09-14 15:54:47 +0000
@@ -34,15 +34,17 @@
 ;;; Code:
 
 (defvar minibuffer-default-in-prompt-regexps
-  '(("\\( (default\\>.*)\\):? \\'" . 1) ("\\( \\[.*\\]\\):? *\\'" . 1))
+  '(("\\( (default\\(?: is\\)? \\(.*\\))\\):? \\'" 1 " [\\2]")
+    ("\\( \\[.*\\]\\):? *\\'" 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.
 
-Each entry is either a string, which should be a regexp matching the
-default portion of the prompt, or a cons cell, who's car is a regexp
-matching the default part of the prompt, and who's cdr indicates the
-regexp subexpression that matched.")
+Each entry is of the form (REGEXP MATCH-NUM &optional REWRITE),
+where REGEXP should match the default part of the prompt,
+MATCH-NUM is the subgroup that matched the actual default indicator,
+and REWRITE, if present, is a string to pass to `replace-match' that
+should be displayed in its place.")
 
 \f
 ;;; Internal variables
@@ -85,15 +87,25 @@
 	;; See the prompt contains a default input indicator
 	(while regexps
 	  (setq match (pop regexps))
-	  (if (re-search-forward (if (stringp match) match (car match)) nil t)
-	      (setq regexps nil)
+	  (if (re-search-forward (car match) nil t)
+              (if (consp (cddr match))
+                  (let ((inhibit-read-only t)
+                        (buffer-undo-list t)
+                        (props (text-properties-at (match-beginning (cadr match)))))
+                    (replace-match (caddr match) nil nil nil (cadr match))
+                    (set-text-properties (match-beginning (cadr match))
+                                         (match-end (cadr match))
+                                         props)
+                    (setq match nil)
+                    (goto-char (point-min)))
+                (setq regexps nil))
 	    (setq match nil)))))
     (if (not match)
 	;; Nope, so just make sure our post-command-hook isn't left around.
 	(remove-hook 'post-command-hook #'minibuf-eldef-update-minibuffer t)
       ;; Yup; set things up so we can frob the prompt as the state of
       ;; the input string changes.
-      (setq match (if (consp match) (cdr match) 0))
+      (setq match (cadr match))
       (setq minibuf-eldef-overlay
 	    (make-overlay (match-beginning match) (match-end match)))
       (setq minibuf-eldef-showing-default-in-prompt t)
@@ -124,10 +136,6 @@
 	   (overlay-put minibuf-eldef-overlay 'intangible t)))))
 
 \f
-;;; Note this definition must be at the end of the file, because
-;;; `define-minor-mode' actually calls the mode-function if the
-;;; associated variable is non-nil, which requires that all needed
-;;; 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.






  reply	other threads:[~2012-09-14 15:56 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-14 13:53 bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy) Dani Moncayo
2012-09-14 15:56 ` Stefan Monnier [this message]
2012-09-14 16:39   ` Drew Adams
2012-09-14 19:17     ` Dani Moncayo
2012-09-14 19:10   ` Dani Moncayo
2012-09-14 19:41     ` Stefan Monnier
2012-09-14 20:42       ` Dani Moncayo
2012-09-14 20:50         ` Jambunathan K
2012-09-14 20:55           ` Drew Adams
2012-09-14 22:47         ` Juri Linkov
2020-08-25 12:30           ` Lars Ingebrigtsen
2020-08-25 12:55             ` Stefan Kangas
2020-08-25 13:45               ` Stefan Monnier
2020-08-25 15:19               ` Lars Ingebrigtsen
2020-08-25 15:34                 ` Drew Adams
2020-08-25 16:19                 ` Stefan Kangas
2020-08-25 18:23                 ` Juri Linkov
2020-08-25 19:12                   ` Lars Ingebrigtsen
2020-08-25 20:00                   ` Stefan Monnier
2020-08-26 12:10                     ` Lars Ingebrigtsen
2020-08-27 18:48                       ` Juri Linkov
2020-08-28 14:11                         ` Lars Ingebrigtsen
2020-08-28 15:21                           ` Stefan Monnier
2020-08-30 13:16                             ` Lars Ingebrigtsen
2020-09-06 15:02                             ` Lars Ingebrigtsen
2020-09-06 17:46                               ` Lars Ingebrigtsen
2020-09-06 18:10                                 ` Lars Ingebrigtsen
2020-09-06 18:49                                 ` Drew Adams
2020-09-06 20:18                                   ` Michael Heerdegen
2020-09-06 20:38                                     ` Lars Ingebrigtsen
2020-09-06 20:42                                       ` Lars Ingebrigtsen
2020-09-06 21:55                                         ` Michael Heerdegen
2020-09-06 21:57                                           ` Lars Ingebrigtsen
2020-09-06 21:50                                       ` Michael Heerdegen
2020-09-06 21:56                                         ` Lars Ingebrigtsen
2020-09-07 18:46                                 ` Juri Linkov
2020-09-07 19:27                                   ` Lars Ingebrigtsen
2020-09-08 18:32                                     ` Juri Linkov
2020-09-08 20:37                                       ` Lars Ingebrigtsen
2020-09-09 18:50                                         ` Juri Linkov
2020-09-10 13:14                                           ` Lars Ingebrigtsen
2020-09-11  9:11                                             ` Andrii Kolomoiets
2020-09-11 12:53                                               ` Lars Ingebrigtsen
2020-09-14  8:40                                                 ` Andrii Kolomoiets
2020-09-14 11:15                                                   ` Lars Ingebrigtsen
2020-10-13  2:31                                                     ` Lars Ingebrigtsen
2020-09-12 19:04                                             ` Juri Linkov
2020-09-13  8:53                                               ` Juri Linkov
2020-09-13 14:30                                                 ` Eli Zaretskii
2020-09-13 13:00                                               ` Lars Ingebrigtsen
2020-09-07 20:11                                   ` Lars Ingebrigtsen
2021-01-17 19:05                               ` bug#12443: 24.2.50; Default values in the minibuffer prompt (fix Basil L. Contovounesios
2021-01-18 16:40                                 ` Lars Ingebrigtsen
2021-01-18 18:06                                   ` Basil L. Contovounesios
2020-08-28 14:13                         ` bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy) Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvy5kchakk.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=12443@debbugs.gnu.org \
    --cc=dmoncayo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).