From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy) Date: Fri, 14 Sep 2012 11:56:50 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1347638245 23369 80.91.229.3 (14 Sep 2012 15:57:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Sep 2012 15:57:25 +0000 (UTC) Cc: 12443@debbugs.gnu.org To: Dani Moncayo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 14 17:57:27 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TCYGe-0005k0-BA for geb-bug-gnu-emacs@m.gmane.org; Fri, 14 Sep 2012 17:57:20 +0200 Original-Received: from localhost ([::1]:58837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCYGa-0006EP-Li for geb-bug-gnu-emacs@m.gmane.org; Fri, 14 Sep 2012 11:57:16 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCYGS-0006EG-St for bug-gnu-emacs@gnu.org; Fri, 14 Sep 2012 11:57:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TCYGO-0001zd-A0 for bug-gnu-emacs@gnu.org; Fri, 14 Sep 2012 11:57:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52689) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCYGO-0001zY-7W for bug-gnu-emacs@gnu.org; Fri, 14 Sep 2012 11:57:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TCYHJ-0004K2-TE for bug-gnu-emacs@gnu.org; Fri, 14 Sep 2012 11:58:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Sep 2012 15:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12443 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12443-submit@debbugs.gnu.org id=B12443.134763827216598 (code B ref 12443); Fri, 14 Sep 2012 15:58:01 +0000 Original-Received: (at 12443) by debbugs.gnu.org; 14 Sep 2012 15:57:52 +0000 Original-Received: from localhost ([127.0.0.1]:34002 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TCYH9-0004Jf-S7 for submit@debbugs.gnu.org; Fri, 14 Sep 2012 11:57:52 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:36701) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TCYH7-0004JW-Ei for 12443@debbugs.gnu.org; Fri, 14 Sep 2012 11:57:50 -0400 Original-Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q8EFuptJ013164; Fri, 14 Sep 2012 11:56:51 -0400 Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id EFD40B4071; Fri, 14 Sep 2012 11:56:50 -0400 (EDT) In-Reply-To: (Dani Moncayo's message of "Fri, 14 Sep 2012 15:53:51 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:64291 Archived-At: > 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.") ;;; 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))))) -;;; 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.