all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Miles Bader <miles@lsi.nec.co.jp>
Cc: Juri Linkov <juri@jurta.org>,
	wl@gnu.org, emacs-devel@gnu.org,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	rms@gnu.org
Subject: Re: minibuffer-eldef
Date: Wed, 02 Jun 2004 18:50:12 +0900	[thread overview]
Message-ID: <buollj6e1bf.fsf@mctpc71.ucom.lsi.nec.co.jp> (raw)
In-Reply-To: <m3u0xuv10f.fsf@kfs-l.imdomain.dk> (Kim F. Storm's message of "02 Jun 2004 10:04:48 +0200")

[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]

storm@cua.dk (Kim F. Storm) writes:
> Couldn't minibuffer-electric-default-mode automatically
> change (default X) to [X] ?

Hmmm, clever!

Try the attached patch, and then eval the following function and do:

   (setq minibuf-eldef-frob-function 'minibuf-eldef-squirk-default)

   (defun minibuf-eldef-squirk-default (overlay state)
     (cond (state
            (unless (overlay-get overlay 'replacement)
              (let ((string 
                     (buffer-substring (overlay-start overlay)
                                       (overlay-end overlay))))
                (setq string 
                      (replace-regexp-in-string " *(default `?\\(.*\\)'?)"
                                                " [\\1]"
                                                string))
                (overlay-put overlay 'replacement string)))
            (overlay-put overlay 'display (overlay-get overlay 'replacement)))
           (t
            (overlay-put overlay 'invisible t)
            (overlay-put overlay 'intangible t)
            (overlay-put overlay 'display nil))))


The only (slight) problem is that it uses a `display' property, which
can be annoying if you want to manually copy the value of the default
or something.  It could probably do something more clever like only
overlaying the bracketting portions of the default or something.

-Miles


Patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: +minibuf-default-frob.patch --]
[-- Type: text/x-patch, Size: 1676 bytes --]

--- orig/lisp/minibuf-eldef.el
+++ mod/lisp/minibuf-eldef.el
@@ -1,6 +1,6 @@
 ;;; minibuf-eldef.el --- Only show defaults in prompts when applicable
 ;;
-;; Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc.
 ;;
 ;; Author: Miles Bader <miles@gnu.org>
 ;; Keywords: convenience
@@ -46,6 +46,8 @@
 matching the default part of the prompt, and who's cdr indicates the
 regexp subexpression that matched.")
 
+(defvar minibuf-eldef-frob-function nil)
+
 \f
 ;;; Internal variables
 
@@ -103,7 +105,11 @@
 	    (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))))
+      (add-hook 'post-command-hook #'minibuf-eldef-update-minibuffer nil t)
+      (when minibuf-eldef-frob-function
+	(funcall minibuf-eldef-frob-function
+		 minibuf-eldef-overlay
+		 minibuf-eldef-showing-default-in-prompt)))))
 
 ;; post-command-hook to swap prompts when necessary
 (defun minibuf-eldef-update-minibuffer ()
@@ -118,7 +124,11 @@
     ;; swap state
     (setq minibuf-eldef-showing-default-in-prompt
 	  (not minibuf-eldef-showing-default-in-prompt))
-    (cond (minibuf-eldef-showing-default-in-prompt
+    (cond (minibuf-eldef-frob-function
+	   (funcall minibuf-eldef-frob-function
+		    minibuf-eldef-overlay
+		    minibuf-eldef-showing-default-in-prompt))
+	  (minibuf-eldef-showing-default-in-prompt
 	   (overlay-put minibuf-eldef-overlay 'invisible nil)
 	   (overlay-put minibuf-eldef-overlay 'intangible nil))
 	  (t

[-- Attachment #3: Type: text/plain, Size: 80 bytes --]

-- 
.Numeric stability is probably not all that important when you're guessing.

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  reply	other threads:[~2004-06-02  9:50 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-28 16:20 improving query-replace and query-replace-regexp Werner LEMBERG
2004-05-28 22:20 ` Stefan Monnier
2004-05-29 17:02   ` Richard Stallman
2004-05-29 17:05     ` Werner LEMBERG
2004-05-29 17:50       ` Miles Bader
2004-05-29 20:45         ` Werner LEMBERG
2004-05-29 21:15     ` Juri Linkov
2004-05-29 21:31       ` Miles Bader
2004-05-30 20:59         ` Juri Linkov
2004-06-01 23:48           ` Stefan Monnier
     [not found]             ` < 8765aadbgb.fsf@mail.jurta.org>
2004-06-02  0:04             ` Miles Bader
2004-06-02  0:10               ` Stefan Monnier
2004-06-02  0:17                 ` Miles Bader
2004-06-02 17:37                 ` Richard Stallman
2004-06-02 17:37               ` Richard Stallman
2004-06-02  0:56             ` Juri Linkov
2004-06-02  1:48               ` Miles Bader
2004-06-02  1:58                 ` minibuffer-eldef (was: improving query-replace and query-replace-regexp) Stefan Monnier
2004-06-02  2:15                   ` minibuffer-eldef Miles Bader
2004-06-02  3:25                     ` minibuffer-eldef Stefan Monnier
2004-06-02  3:42                       ` minibuffer-eldef Miles Bader
2004-06-02  7:01                         ` minibuffer-eldef David Kastrup
2004-06-02  7:15                           ` minibuffer-eldef Miles Bader
2004-06-02 22:55                             ` minibuffer-eldef Richard Stallman
2004-06-03  7:19                               ` minibuffer-eldef David Kastrup
2004-06-03  7:34                                 ` minibuffer-eldef Miles Bader
2004-06-03  8:13                                   ` minibuffer-eldef David Kastrup
2004-06-03 22:40                                     ` minibuffer-eldef Miles Bader
2004-06-03  7:39                                 ` minibuffer-eldef Stephan Stahl
2004-06-03  8:06                                   ` minibuffer-eldef David Kastrup
2004-06-03  8:43                                     ` minibuffer-eldef Stephan Stahl
2004-06-03 12:21                                 ` minibuffer-eldef Stefan Monnier
2004-06-03 12:35                                   ` minibuffer-eldef David Kastrup
2004-06-04  1:35                                 ` minibuffer-eldef Juri Linkov
2004-06-02  8:04                       ` minibuffer-eldef Kim F. Storm
2004-06-02  9:50                         ` Miles Bader [this message]
2004-06-02  8:32                       ` minibuffer-eldef Werner LEMBERG
2004-06-02 17:37                 ` improving query-replace and query-replace-regexp Richard Stallman
2004-06-02 17:52                   ` David Kastrup
2004-06-03  1:28                   ` Miles Bader
2004-06-03  2:29                     ` Stefan Monnier
2004-06-03  4:52                       ` Miles Bader
2004-06-03  7:22                     ` David Kastrup
2004-06-04  2:03                       ` Richard Stallman
2004-06-07  4:28                         ` Miles Bader
2004-06-02  0:16         ` Kevin Rodgers
2004-06-02  0:32           ` Miles Bader
2004-06-03 18:35             ` Kevin Rodgers
2004-06-03 18:57               ` Stefan Monnier
2004-06-03 22:20                 ` Miles Bader
2004-06-04 17:33                   ` Richard Stallman
2004-06-02  0:59           ` Juri Linkov
2004-07-03  9:45   ` Juri Linkov
2004-07-04 17:03     ` Richard Stallman
2004-07-05 19:43       ` David Kastrup
2004-05-29 10:57 ` Miles Bader
2004-05-29 11:58   ` Kai Grossjohann
2004-05-29 12:03     ` Miles Bader
2004-05-30 14:30       ` Richard Stallman
2004-05-29 12:21     ` Werner LEMBERG
2004-05-29 15:51 ` Stefan Daschek

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

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

  git send-email \
    --in-reply-to=buollj6e1bf.fsf@mctpc71.ucom.lsi.nec.co.jp \
    --to=miles@lsi.nec.co.jp \
    --cc=emacs-devel@gnu.org \
    --cc=juri@jurta.org \
    --cc=miles@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=rms@gnu.org \
    --cc=wl@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.