GNU bug report logs - #5423
Multiline y-or-n prompt in files.el

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> IRO.UMontreal.CA>

Date: Tue, 19 Jan 2010 13:56:02 UTC

Severity: normal

Tags: moreinfo

Merged with 18340

Found in versions 23.1.91, 24.4.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5423 in the body.
You can then email your comments to 5423 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Tue, 19 Jan 2010 13:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 19 Jan 2010 13:56:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: bug-gnu-emacs <at> gnu.org
Subject: Multiline y-or-n prompt in files.el
Date: Tue, 19 Jan 2010 08:51:27 -0500
Package: Emacs
Version: 23.1.91

find-file-noselect has a multiline y-or-n-p prompt if the file is
already visited and modified (and in a different rawness).  That only
works when the minibuffer can be resized, sadly.  In my case (separate
minibuffer), I only see the beginning of the prompt.


        Stefan



In GNU Emacs 23.1.91.1 (i686-pc-linux-gnu, GTK+ Version 2.18.3)
 of 2010-01-17 on ceviche
Windowing system distributor `The X.Org Foundation', version 11.0.10704000
configured using `configure  'CFLAGS=-Wall -Wno-pointer-sign -DUSE_LISP_UNION_TYPE -DSYNC_INPUT -DENABLE_CHECKING -DXASSERTS -DFONTSET_DEBUG -g -O1 -I/usr/include/GNUstep' 'LDFLAGS=-L/home/monnier/src/Xaw3d' 'CPPFLAGS=-I/home/monnier/src/Xaw3d''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: fr_CH.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Minibuffer-Area

Minor modes in effect:
  diff-auto-refine-mode: t
  url-handler-mode: t
  global-reveal-mode: t
  reveal-mode: t
  auto-insert-mode: t
  savehist-mode: t
  minibuffer-electric-default-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-y <backspace> C-x C-s M-x M-p <return> C-x C-k <return> 
C-g C-x k <return> M-x M-p <return> C-x k <return> 
C-h f r m a <tab> <return> <switch-frame> <switch-frame> 
<switch-frame> <switch-frame> <select-window> <switch-frame> 
<switch-frame> <switch-frame> <switch-frame> <select-window> 
<switch-frame> <switch-frame> <select-window> <switch-frame> 
<switch-frame> <select-window> <switch-frame> <switch-frame> 
<select-window> <switch-frame> <switch-frame> <select-window> 
<switch-frame> <switch-frame> <select-window> <switch-frame> 
<switch-frame> <select-window> <switch-frame> C-x k 
<return> M-x r m a <tab> <tab> - <tab> b u f <tab> 
<backspace> <backspace> <backspace> <tab> C-g C-h f 
r m a <tab> <return> <switch-frame> <switch-frame> 
<switch-frame> <select-window> <switch-frame> <switch-frame> 
<switch-frame> <select-window> <switch-frame> <switch-frame> 
<select-window> <switch-frame> <switch-frame> <select-window> 
<switch-frame> <switch-frame> <select-window> <switch-frame> 
<help-echo> <switch-frame> <switch-frame> C-x C-c C-u 
M-x M-p <return> M-p <return> <right> C-g <C-down-mouse-3> 
<options> <debug-on-quit> C-u M-x M-p <return> M-p 
<return> C-g <select-window> <switch-frame> <switch-frame> 
<help-echo> <down-mouse-1> <mouse-2> C-c @ C-a <down> 
<left> <right> <down> <left> <right> <down> <left> 
<right> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> C-s 
, \ n C-a C-s a l r e a s y <backspace> <backspace> 
d y C-r C-r C-r C-r C-r C-r C-r C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s <switch-frame> <switch-frame> C-a 
C-s i s SPC a l r e a d y SPC v i s i C-a <C-left> 
<right> <up> <left> <right> <down> <left> <right> <down> 
<left> <right> <up> <left> <right> <down> <left> <right> 
<down> <left> <right> <down> <left> <right> <up> <up> 
<left> <right> <up> <left> <right> <up> <left> <right> 
<down> <left> <right> <down> <left> <right> <down> 
<left> <right> <down> <left> <right> <down> <left> 
<right> <down> <left> <right> <down> <left> <right> 
<down> <left> <right> <up> <left> <right> <help-echo> 
<switch-frame> <switch-frame> <select-window> M-x r 
e p o - e m - b u <tab> <return>

Recent messages:
Quit
Debug on Quit enabled globally
The file TP1-plans is already visited literally,
meaning no coding system decoding, format conversion, or local variables.
You have asked to visit it normally,
but Emacs can only visit a file in one way at a time.

Do you want to revisit the file normally now? (y or n) 
Entering debugger...
Mark saved where search started [3 times]

Load-path shadows:
/usr/share/emacs23/site-lisp/bbdb/bbdb-com hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-com
/usr/share/emacs23/site-lisp/bbdb/bbdb-ftp hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-ftp
/usr/share/emacs23/site-lisp/bbdb/bbdb-rmail hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-rmail
/usr/share/emacs23/site-lisp/bbdb/bbdb-mhe hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-mhe
/usr/share/emacs23/site-lisp/bbdb/bbdb-gui hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-gui
/usr/share/emacs23/site-lisp/bbdb/bbdb-print hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-print
/usr/share/emacs23/site-lisp/bbdb/bbdb hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb
/usr/share/emacs23/site-lisp/bbdb/bbdb-w3 hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-w3
/usr/share/emacs23/site-lisp/bbdb/bbdb-sc hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-sc
/usr/share/emacs23/site-lisp/bbdb/bbdb-whois hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-whois
/usr/share/emacs23/site-lisp/bbdb/bbdb-snarf hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-snarf
/usr/share/emacs23/site-lisp/bbdb/bbdb-merge hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-merge
/usr/share/emacs23/site-lisp/bbdb/bbdb-vm hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-vm
/usr/share/emacs23/site-lisp/bbdb/bbdb-migrate hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-migrate
/usr/share/emacs23/site-lisp/bbdb/bbdb-gnus hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-gnus
/usr/share/emacs23/site-lisp/bbdb/bbdb-hooks hides /usr/share/emacs/site-lisp/bbdb/lisp/bbdb-hooks

Features:
(shadow sort mail-extr message sendmail ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date gmm-utils wid-edit mailheader canlock hashcash emacsbug
cus-start cus-load edmacro kmacro speedbar sb-image ezimage dframe assoc
find-func rmail mail-utils debug executable copyright smerge-mode
multi-isearch vc-bzr sha1 hex-util filecache diff-mode server noutline
outline easy-mmode flyspell ispell eldoc checkdoc regexp-opt thingatpt
help-mode easymenu view url-handlers url-parse url-vars mm-util
mail-prsvr reveal autoinsert uniquify advice help-fns advice-preload
savehist minibuf-eldef cl cl-19 cl-loaddefs proof-site proof-autoloads
pg-vars bbdb-autoloads agda2 tooltip ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd font-setting tool-bar dnd fontset image fringe
lisp-mode register page newcomment menu-bar rfn-eshadow timer select
scroll-bar mldrag mouse jit-lock font-lock syntax font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev loaddefs button minibuffer faces cus-face files text-properties
overlay md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
system-font-setting font-render-setting gtk x-toolkit x multi-tty emacs)





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Tue, 19 Jan 2010 14:14:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>, 5423 <at> debbugs.gnu.org
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#5423: Multiline y-or-n prompt in files.el
Date: Tue, 19 Jan 2010 15:12:57 +0100
On Tue, Jan 19, 2010 at 2:51 PM, Stefan Monnier
<monnier <at> iro.umontreal.ca> wrote:
> Package: Emacs
> Version: 23.1.91
>
> find-file-noselect has a multiline y-or-n-p prompt if the file is
> already visited and modified (and in a different rawness).  That only
> works when the minibuffer can be resized, sadly.  In my case (separate
> minibuffer), I only see the beginning of the prompt.


Is not the right fix to allow minibuffer resizing even when the
minibuffer frame is separate?

I have never heard of the problem with resizing the minibuffer. Is
that documented somewhere?





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Tue, 19 Jan 2010 14:14:02 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Tue, 19 Jan 2010 15:00:03 GMT) Full text and rfc822 format available.

Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Helmut Eller <eller.helmut <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#5423: Multiline y-or-n prompt in files.el
Date: Tue, 19 Jan 2010 15:56:49 +0100
* Lennart Borgman [2010-01-19 15:12+0100] writes:

> Is not the right fix to allow minibuffer resizing even when the
> minibuffer frame is separate?
>
> I have never heard of the problem with resizing the minibuffer. Is
> that documented somewhere?

There is the variable resize-mini-windows.  I set that to nil and
multiline messages are very annoying.

Helmut






Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Tue, 19 Jan 2010 15:18:01 GMT) Full text and rfc822 format available.

Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Helmut Eller <eller.helmut <at> gmail.com>
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#5423: Multiline y-or-n prompt in files.el
Date: Tue, 19 Jan 2010 16:17:02 +0100
On Tue, Jan 19, 2010 at 3:56 PM, Helmut Eller <eller.helmut <at> gmail.com> wrote:
> * Lennart Borgman [2010-01-19 15:12+0100] writes:
>
>> Is not the right fix to allow minibuffer resizing even when the
>> minibuffer frame is separate?
>>
>> I have never heard of the problem with resizing the minibuffer. Is
>> that documented somewhere?
>
> There is the variable resize-mini-windows.  I set that to nil and
> multiline messages are very annoying.


I can agreee multiline message are annoying, but I do not find
multiline prompts annoying. It seems a bit wrong that they are coupled
to each other.





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Tue, 19 Jan 2010 15:37:02 GMT) Full text and rfc822 format available.

Message #20 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Drew Adams" <drew.adams <at> oracle.com>
To: "'Lennart Borgman'" <lennart.borgman <at> gmail.com>,
	"'Stefan Monnier'" <monnier <at> iro.umontreal.ca>, <5423 <at> debbugs.gnu.org>
Cc: bug-gnu-emacs <at> gnu.org
Subject: RE: bug#5423: Multiline y-or-n prompt in files.el
Date: Tue, 19 Jan 2010 07:35:55 -0800
> Is not the right fix to allow minibuffer resizing even when the
> minibuffer frame is separate?
> 
> I have never heard of the problem with resizing the minibuffer. Is
> that documented somewhere?

Please, _no_.

A standalone minibuffer frame's size and its other defined qualities should be
respected. Respect the user.






Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Tue, 19 Jan 2010 15:37:02 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Wed, 20 Jan 2010 02:18:01 GMT) Full text and rfc822 format available.

Message #26 received at 5423 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 5423 <at> debbugs.gnu.org
Subject: Re: bug#5423: Multiline y-or-n prompt in files.el
Date: Wed, 20 Jan 2010 03:59:44 +0200
> find-file-noselect has a multiline y-or-n-p prompt if the file is
> already visited and modified (and in a different rawness).  That only
> works when the minibuffer can be resized, sadly.  In my case (separate
> minibuffer), I only see the beginning of the prompt.

I think multiline text should be displayed in a separate window
above the minibuffer.  I guess this configuration will also work
for the case where the minibuffer is displayed in a separate frame.

-- 
Juri Linkov
http://www.jurta.org/emacs/




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Wed, 20 Jan 2010 02:53:02 GMT) Full text and rfc822 format available.

Message #29 received at 5423 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 5423 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#5423: Multiline y-or-n prompt in files.el
Date: Wed, 20 Jan 2010 03:52:07 +0100
On Wed, Jan 20, 2010 at 2:59 AM, Juri Linkov <juri <at> jurta.org> wrote:
>> find-file-noselect has a multiline y-or-n-p prompt if the file is
>> already visited and modified (and in a different rawness).  That only
>> works when the minibuffer can be resized, sadly.  In my case (separate
>> minibuffer), I only see the beginning of the prompt.
>
> I think multiline text should be displayed in a separate window
> above the minibuffer.  I guess this configuration will also work
> for the case where the minibuffer is displayed in a separate frame.

That sounds a bit strange to me, but maybe I am misunderstanding something?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Thu, 19 Nov 2020 02:53:02 GMT) Full text and rfc822 format available.

Message #32 received at 5423 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 5423 <at> debbugs.gnu.org
Subject: Re: bug#5423: Multiline y-or-n prompt in files.el
Date: Wed, 18 Nov 2020 18:51:57 -0800
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:

> Package: Emacs
> Version: 23.1.91
>
> find-file-noselect has a multiline y-or-n-p prompt if the file is
> already visited and modified (and in a different rawness).  That only
> works when the minibuffer can be resized, sadly.  In my case (separate
> minibuffer), I only see the beginning of the prompt.

That was 10 years ago, so just to check in: is this still an issue?

(We normally check in once a decade to verify that no bug has been
unduly fixed.  ;-)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Thu, 19 Nov 2020 05:16:02 GMT) Full text and rfc822 format available.

Message #35 received at 5423 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 5423 <at> debbugs.gnu.org
Subject: Re: bug#5423: Multiline y-or-n prompt in files.el
Date: Thu, 19 Nov 2020 00:15:04 -0500
>> find-file-noselect has a multiline y-or-n-p prompt if the file is
>> already visited and modified (and in a different rawness).  That only
>> works when the minibuffer can be resized, sadly.  In my case (separate
>> minibuffer), I only see the beginning of the prompt.
>
> That was 10 years ago, so just to check in: is this still an issue?

I'd be surprised if it's been fixed, but I must admit that I can't
remember how to trigger this,


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Thu, 19 Nov 2020 09:34:01 GMT) Full text and rfc822 format available.

Message #38 received at 5423 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 5423 <at> debbugs.gnu.org, Stefan Kangas <stefan <at> marxist.se>
Subject: Re: bug#5423: Multiline y-or-n prompt in files.el
Date: Thu, 19 Nov 2020 10:33:28 +0100
On Thu, 19 Nov 2020 00:15:04 -0500 Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:

>>> find-file-noselect has a multiline y-or-n-p prompt if the file is
>>> already visited and modified (and in a different rawness).  That only
>>> works when the minibuffer can be resized, sadly.  In my case (separate
>>> minibuffer), I only see the beginning of the prompt.
>>
>> That was 10 years ago, so just to check in: is this still an issue?
>
> I'd be surprised if it's been fixed, but I must admit that I can't
> remember how to trigger this,

I'm not sure just what you meant with "beginning of the prompt", but
what I see is only the last line of the entire prompt message:
"The file test is already visited literally,
meaning no coding system handling, format conversion, or local variables.
You have edited the buffer.  Now you have asked to visit the file normally,
but Emacs can visit a file in only one way at a time.

Do you want to save the file, and visit it normally instead? "

To reproduce:

$ touch /tmp/test
$ emacs -Q --eval "(setq resize-mini-windows nil)" /tmp/test
M-x find-file-literally RET /tmp/test RET
=> The minibuffer displays only:
Do you want to save the file, and visit it literally instead? (y or no)

By repeatedly typing `C-p' you can see the entire message line by line.
Tested on current master.  (There also seems to be another separate bug:
that with the above recipe the prompt message seems inappropriate.)

Steve Berman




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Thu, 19 Nov 2020 10:04:02 GMT) Full text and rfc822 format available.

Message #41 received at 5423 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Stephen Berman <stephen.berman <at> gmx.net>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 5423 <at> debbugs.gnu.org, Stefan Kangas <stefan <at> marxist.se>
Subject: Re: bug#5423: Multiline y-or-n prompt in files.el
Date: Thu, 19 Nov 2020 11:03:17 +0100
> I'm not sure just what you meant with "beginning of the prompt", but
> what I see is only the last line of the entire prompt message:
> "The file test is already visited literally,
> meaning no coding system handling, format conversion, or local variables.
> You have edited the buffer.  Now you have asked to visit the file normally,
> but Emacs can visit a file in only one way at a time.
>
> Do you want to save the file, and visit it normally instead? "

Why can't that prompt just say

"File's buffer modified, save it and visit file normally afterwards?"

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Thu, 19 Nov 2020 14:48:01 GMT) Full text and rfc822 format available.

Message #44 received at 5423 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: 5423 <at> debbugs.gnu.org, stefan <at> marxist.se, monnier <at> iro.umontreal.ca
Subject: Re: bug#5423: Multiline y-or-n prompt in files.el
Date: Thu, 19 Nov 2020 16:47:17 +0200
> From: Stephen Berman <stephen.berman <at> gmx.net>
> Date: Thu, 19 Nov 2020 10:33:28 +0100
> Cc: Stefan Kangas <stefan <at> marxist.se>, 5423 <at> debbugs.gnu.org
> 
> $ touch /tmp/test
> $ emacs -Q --eval "(setq resize-mini-windows nil)" /tmp/test
> M-x find-file-literally RET /tmp/test RET
> => The minibuffer displays only:
> Do you want to save the file, and visit it literally instead? (y or no)

The original report didn't say anything about setting
resize-mini-windows to nil.  In fact, the original report didn't
provide any details to explain why a separate minibuffer frame doesn't
have enough space to display several lines of text.  So I think we
don't have a clear understanding of the problem, and should request
details.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Fri, 20 Nov 2020 08:32:02 GMT) Full text and rfc822 format available.

Message #47 received at 5423 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: 5423 <at> debbugs.gnu.org, Stefan Kangas <stefan <at> marxist.se>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#5423: Multiline y-or-n prompt in files.el
Date: Fri, 20 Nov 2020 10:30:59 +0200
[Message part 1 (text/plain, inline)]
> $ touch /tmp/test
> $ emacs -Q --eval "(setq resize-mini-windows nil)" /tmp/test
> M-x find-file-literally RET /tmp/test RET
> => The minibuffer displays only:
> Do you want to save the file, and visit it literally instead? (y or no)

Exactly like a week ago in bug#42708 we added support for C-h to
read-char-from-minibuffer used by dired-query with help-form,
this patch does the same for y-or-n-p used by find-file-noselect
with help-form:

[y-or-n-p-help-form.patch (text/x-diff, inline)]
diff --git a/lisp/files.el b/lisp/files.el
index 3565b7f571..b61bbc05ad 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2310,22 +2310,27 @@ find-file-noselect
 			    ;; hexl-mode or image-mode.
 			    (memq major-mode '(hexl-mode image-mode)))
 		  (if (buffer-modified-p)
-		      (if (y-or-n-p
-			   (format
-			    (if rawfile
-				"The file %s is already visited normally,
+		      (if (let ((help-form
+                                 (format-message
+                                  (if rawfile "\
+The file %s is already visited normally,
 and you have edited the buffer.  Now you have asked to visit it literally,
 meaning no coding system handling, format conversion, or local variables.
-Emacs can visit a file in only one way at a time.
-
-Do you want to save the file, and visit it literally instead? "
-				"The file %s is already visited literally,
+Emacs can visit a file in only one way at a time."
+                                    "\
+The file %s is already visited literally,
 meaning no coding system handling, format conversion, or local variables.
 You have edited the buffer.  Now you have asked to visit the file normally,
-but Emacs can visit a file in only one way at a time.
-
+but Emacs can visit a file in only one way at a time.")
+                                  (file-name-nondirectory filename))))
+                            (y-or-n-p
+			     (format
+			      (if rawfile
+				  "\
+Do you want to save the file, and visit it literally instead? "
+				"\
 Do you want to save the file, and visit it normally instead? ")
-			    (file-name-nondirectory filename)))
+			      (file-name-nondirectory filename))))
 			  (progn
 			    (save-buffer)
 			    (find-file-noselect-1 buf filename nowarn
@@ -2341,22 +2346,27 @@ find-file-noselect
 						  rawfile truename number)
 			  (error (if rawfile "File already visited non-literally"
 				   "File already visited literally"))))
-		    (if (y-or-n-p
-			 (format
-			  (if rawfile
-			      "The file %s is already visited normally.
+		    (if (let ((help-form
+                               (format-message
+                                (if rawfile "\
+The file %s is already visited normally.
 You have asked to visit it literally,
 meaning no coding system decoding, format conversion, or local variables.
-But Emacs can visit a file in only one way at a time.
-
-Do you want to revisit the file literally now? "
-			    "The file %s is already visited literally,
+But Emacs can visit a file in only one way at a time."
+                                  "\
+The file %s is already visited literally,
 meaning no coding system decoding, format conversion, or local variables.
 You have asked to visit it normally,
-but Emacs can visit a file in only one way at a time.
-
+but Emacs can visit a file in only one way at a time.")
+                                (file-name-nondirectory filename))))
+                          (y-or-n-p
+			   (format
+			    (if rawfile
+			        "\
+Do you want to revisit the file literally now? "
+			      "\
 Do you want to revisit the file normally now? ")
-			  (file-name-nondirectory filename)))
+			    (file-name-nondirectory filename))))
 			(find-file-noselect-1 buf filename nowarn
 					      rawfile truename number)
 		      (error (if rawfile "File already visited non-literally"
diff --git a/lisp/subr.el b/lisp/subr.el
index d437e14501..d02a3611e0 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2902,7 +2902,13 @@ y-or-n-p
 		    (concat prompt
 			    (if (or (zerop l) (eq ?\s (aref prompt (1- l))))
 				"" " ")
-			    (if dialog "" "(y or n) "))))))
+			    (if dialog ""
+                              (if help-form
+                                  (format "(y, n or %s) "
+		                          (key-description
+                                           (vector help-char)))
+                                  "(y or n) "
+                                  )))))))
     (cond
      (noninteractive
       (setq prompt (funcall padded prompt))
@@ -2911,6 +2917,7 @@ y-or-n-p
 	  (let ((str (read-string temp-prompt)))
 	    (cond ((member str '("y" "Y")) (setq answer 'act))
 		  ((member str '("n" "N")) (setq answer 'skip))
+		  ((and (member str '("h" "H")) help-form) (print help-form))
 		  (t (setq temp-prompt (concat "Please answer y or n.  "
 					       prompt))))))))
      ((and (display-popup-menus-p)
@@ -2923,10 +2930,18 @@ y-or-n-p
       (setq prompt (funcall padded prompt))
       (let* ((empty-history '())
              (enable-recursive-minibuffers t)
+             (msg help-form)
+             (keymap (let ((map (make-composed-keymap
+                                 y-or-n-p-map query-replace-map)))
+                       (when help-form
+                         (define-key map (vector help-char)
+                           (lambda ()
+                             (interactive)
+                             (let ((help-form msg)) ; lexically bound msg
+                               (help-form-show)))))
+                       map))
              (str (read-from-minibuffer
-                   prompt nil
-                   (make-composed-keymap y-or-n-p-map query-replace-map)
-                   nil
+                   prompt nil keymap nil
                    (or y-or-n-p-history-variable 'empty-history))))
         (setq answer (if (member str '("y" "Y")) 'act 'skip)))))
     (let ((ret (eq answer 'act)))

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5423; Package emacs. (Sat, 21 Nov 2020 19:53:02 GMT) Full text and rfc822 format available.

Message #50 received at 5423 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 5423 <at> debbugs.gnu.org, Stephen Berman <stephen.berman <at> gmx.net>,
 Stefan Kangas <stefan <at> marxist.se>
Subject: Re: bug#5423: Multiline y-or-n prompt in files.el
Date: Sat, 21 Nov 2020 21:50:54 +0200
>> $ touch /tmp/test
>> $ emacs -Q --eval "(setq resize-mini-windows nil)" /tmp/test
>> M-x find-file-literally RET /tmp/test RET
>> => The minibuffer displays only:
>> Do you want to save the file, and visit it literally instead? (y or no)
>
> Exactly like a week ago in bug#42708 we added support for C-h to
> read-char-from-minibuffer used by dired-query with help-form,
> this patch does the same for y-or-n-p used by find-file-noselect
> with help-form:

Pushed to master, but I don't know if this bug report can be closed now?




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Sat, 21 Nov 2020 21:24:02 GMT) Full text and rfc822 format available.

Notification sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
bug acknowledged by developer. (Sat, 21 Nov 2020 21:24:02 GMT) Full text and rfc822 format available.

Message #55 received at 5423-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> linkov.net>
Cc: 5423-done <at> debbugs.gnu.org, Stephen Berman <stephen.berman <at> gmx.net>,
 Stefan Kangas <stefan <at> marxist.se>
Subject: Re: bug#5423: Multiline y-or-n prompt in files.el
Date: Sat, 21 Nov 2020 16:23:04 -0500
> Pushed to master,

Thanks, this is even better than just fixing the original problem.

> but I don't know if this bug report can be closed now?

I think it can,


        Stefan





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 20 Dec 2020 12:24:05 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Mon, 11 Oct 2021 11:42:02 GMT) Full text and rfc822 format available.

Forcibly Merged 5423 18340. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Mon, 11 Oct 2021 11:42:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 08 Nov 2021 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 282 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.