From: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>
To: martin rudalics <rudalics@gmx.at>
Cc: 35564@debbugs.gnu.org
Subject: bug#35564: 27.0.50; [PATCH] Tweak dired-do-shell-command warning about "wildcard" characters
Date: Mon, 06 May 2019 21:40:01 +0200 [thread overview]
Message-ID: <877eb3e5im.fsf@gmail.com> (raw)
In-Reply-To: <071cc96c-1bf2-f331-8f9e-b3c54a7452da@gmx.at> (martin rudalics's message of "Sun, 5 May 2019 10:44:21 +0200")
[-- Attachment #1: Type: text/plain, Size: 2917 bytes --]
martin rudalics <rudalics@gmx.at> writes:
>> [1] Compare:
>>
>> (let ((prompt "foobar "))
>> (add-face-text-property 3 6 'warning nil prompt)
>> (yes-or-no-p prompt))
>>
>> With:
>>
>> (let ((prompt "foobar "))
>> (add-face-text-property 3 6 'warning nil prompt)
>> (y-or-n-p prompt))
>
> 'y-or-n-p' propertizes the prompt rigidly as
>
> (read-key (propertize (if (memq answer scroll-actions)
> prompt
> (concat "Please answer y or n. "
> prompt))
> 'face 'minibuffer-prompt)))))
>
> while 'yes-or-no-p' carefully applies 'minibuffer-prompt-properties'
> to any text properties provided with PROMPT.
Well, that's interesting.
I dug into yes-or-no-p until I came across `read_minibuf()'; is this the
code you are referring to?
if (PT > BEG)
{
Fput_text_property (make_fixnum (BEG), make_fixnum (PT),
Qfront_sticky, Qt, Qnil);
Fput_text_property (make_fixnum (BEG), make_fixnum (PT),
Qrear_nonsticky, Qt, Qnil);
Fput_text_property (make_fixnum (BEG), make_fixnum (PT),
Qfield, Qt, Qnil);
if (CONSP (Vminibuffer_prompt_properties))
{
/* We want to apply all properties from
`minibuffer-prompt-properties' to the region normally,
but if the `face' property is present, add that
property to the end of the face properties to avoid
overwriting faces. */
Lisp_Object list = Vminibuffer_prompt_properties;
while (CONSP (list))
{
Lisp_Object key = XCAR (list);
list = XCDR (list);
if (CONSP (list))
{
Lisp_Object val = XCAR (list);
list = XCDR (list);
if (EQ (key, Qface))
Fadd_face_text_property (make_fixnum (BEG),
make_fixnum (PT), val, Qt, Qnil);
else
Fput_text_property (make_fixnum (BEG), make_fixnum (PT),
key, val, Qnil);
}
}
}
}
If one were to fix the issue of y-or-n-p hardcoding the face property,
what would be the best way to go?
1. Make a C DEFUN out of this snippet, and have it called by
`read_minibuf()' and `y-or-n-p'.
2. Re-implement this snippet as an Elisp defun, and have it called by
`read_minibuf()' and `y-or-n-p'.
3. (Re-implement this snippet within `y-or-n-p'.)
(FWIW, the attached patch seems to work as a workaround, but I assume
solutions 1 or 2 would be better, by virtue of reusing code)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-y-or-no-p-keep-the-supplied-prompt-s-face.patch --]
[-- Type: text/x-patch, Size: 1735 bytes --]
From 9ea712779d725a23fe8f4acd7b934b0a64a1f1ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legouguec@gmail.com>
Date: Mon, 6 May 2019 21:26:37 +0200
Subject: [PATCH] Make y-or-no-p keep the supplied prompt's face
* lisp/subr.el (y-or-n-p): append the minibuffer-prompt face instead
of overwriting the prompt's face property.
---
lisp/subr.el | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index f68f9dd419..8d224ff5bb 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2647,11 +2647,15 @@ y-or-n-p
(let ((cursor-in-echo-area t))
(when minibuffer-auto-raise
(raise-frame (window-frame (minibuffer-window))))
- (read-key (propertize (if (memq answer scroll-actions)
- prompt
- (concat "Please answer y or n. "
- prompt))
- 'face 'minibuffer-prompt)))))
+ (read-key
+ (let ((prompt-maybe-please
+ (if (memq answer scroll-actions)
+ prompt
+ (concat "Please answer y or n. " prompt))))
+ (add-face-text-property
+ 0 (1- (length prompt-maybe-please))
+ 'minibuffer-prompt t prompt-maybe-please)
+ prompt-maybe-please)))))
(setq answer (lookup-key query-replace-map (vector key) t))
(cond
((memq answer '(skip act)) nil)
--
2.21.0
[-- Attachment #3: Type: text/plain, Size: 37 bytes --]
Thanks for your help!
Kévin
next prev parent reply other threads:[~2019-05-06 19:40 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-04 18:01 bug#35564: 27.0.50; [PATCH] Tweak dired-do-shell-command warning about "wildcard" characters Kévin Le Gouguec
2019-05-05 8:44 ` martin rudalics
2019-05-06 19:40 ` Kévin Le Gouguec [this message]
2019-05-07 8:15 ` martin rudalics
2019-05-07 13:19 ` Drew Adams
2019-05-08 20:42 ` Kévin Le Gouguec
2019-05-08 22:39 ` Drew Adams
2019-05-09 8:13 ` martin rudalics
2019-05-09 14:17 ` Drew Adams
2019-05-09 17:51 ` martin rudalics
2019-05-09 20:04 ` Drew Adams
2019-06-09 11:08 ` bug#35564: [PATCH v2] Tweak dired " Kévin Le Gouguec
2019-06-12 12:23 ` Noam Postavsky
2019-06-12 14:29 ` Stefan Monnier
2019-06-13 6:19 ` Kévin Le Gouguec
2019-06-13 7:58 ` Stefan Monnier
2019-06-13 16:53 ` npostavs
2019-06-18 8:52 ` Kévin Le Gouguec
2019-06-19 0:12 ` Noam Postavsky
2019-06-26 6:16 ` bug#35564: [PATCH v3] " Kévin Le Gouguec
2019-06-26 13:27 ` Drew Adams
2019-06-27 5:58 ` Kévin Le Gouguec
2019-06-26 14:33 ` Stefan Monnier
2019-06-27 6:15 ` Kévin Le Gouguec
2019-06-27 23:31 ` Noam Postavsky
2019-06-28 6:15 ` Kévin Le Gouguec
2019-06-28 15:35 ` Drew Adams
2019-06-28 17:58 ` Kévin Le Gouguec
2019-06-28 18:43 ` Drew Adams
2019-06-29 13:48 ` Noam Postavsky
2019-06-29 14:30 ` Drew Adams
2019-06-29 14:13 ` Eli Zaretskii
2019-07-03 19:47 ` bug#35564: [PATCH v4] " Kévin Le Gouguec
2019-07-12 15:10 ` Kévin Le Gouguec
2019-07-27 11:20 ` Eli Zaretskii
2019-07-27 17:26 ` Kévin Le Gouguec
2019-07-27 22:22 ` Michael Heerdegen
2019-07-29 3:29 ` Michael Heerdegen
2019-07-29 18:11 ` Juri Linkov
2019-07-29 19:01 ` Kévin Le Gouguec
2019-08-02 5:26 ` Michael Heerdegen
2019-08-08 10:40 ` Kévin Le Gouguec
2019-08-08 21:06 ` Juri Linkov
2019-08-09 12:43 ` Kévin Le Gouguec
2019-08-09 18:03 ` Juri Linkov
2019-08-15 20:56 ` Juri Linkov
2019-08-19 4:55 ` Kévin Le Gouguec
2019-07-27 22:03 ` Basil L. Contovounesios
2019-07-27 23:32 ` Kévin Le Gouguec
2019-07-27 23:41 ` Basil L. Contovounesios
2019-10-10 18:45 ` bug#35564: [PATCH v5] " Kévin Le Gouguec
2019-10-22 15:10 ` Kévin Le Gouguec
2019-10-22 16:58 ` Michael Heerdegen
2019-10-22 21:32 ` Kévin Le Gouguec
2019-11-10 20:29 ` Juri Linkov
2019-11-14 7:02 ` Kévin Le Gouguec
2019-11-16 20:23 ` Juri Linkov
2019-10-22 20:43 ` Juri Linkov
2019-10-22 21:11 ` Kévin Le Gouguec
2019-10-27 21:40 ` Juri Linkov
2019-10-30 21:59 ` Juri Linkov
2019-11-04 6:36 ` Kévin Le Gouguec
2019-11-05 22:22 ` Juri Linkov
2019-11-07 22:17 ` Juri Linkov
2019-11-10 20:18 ` Juri Linkov
2019-12-18 7:11 ` Kévin Le Gouguec
2019-12-19 22:01 ` Juri Linkov
2019-12-20 8:53 ` Eli Zaretskii
2019-12-20 20:34 ` Kévin Le Gouguec
2019-12-21 7:08 ` Eli Zaretskii
2019-12-22 16:02 ` Kévin Le Gouguec
2019-12-20 20:43 ` Kévin Le Gouguec
2019-12-21 7:08 ` Eli Zaretskii
2020-09-20 11:42 ` Lars Ingebrigtsen
2020-09-20 12:04 ` Kévin Le Gouguec
2020-09-20 12:18 ` 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=877eb3e5im.fsf@gmail.com \
--to=kevin.legouguec@gmail.com \
--cc=35564@debbugs.gnu.org \
--cc=rudalics@gmx.at \
/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).