bug#5423: Multiline y-or-n prompt in files.el

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Stefan Monnier
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)





Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Lennart Borgman (gmail)
On Tue, Jan 19, 2010 at 2:51 PM, Stefan Monnier
<[hidden email]> 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?




Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Helmut Eller-2
In reply to this post by Stefan Monnier
* 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






Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Lennart Borgman (gmail)
On Tue, Jan 19, 2010 at 3:56 PM, Helmut Eller <[hidden email]> 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.





Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Drew Adams
In reply to this post by Lennart Borgman (gmail)
> 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.





Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Juri Linkov
In reply to this post by Stefan Monnier
> 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/




Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Lennart Borgman (gmail)
On Wed, Jan 20, 2010 at 2:59 AM, Juri Linkov <[hidden email]> 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?




Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Stefan Kangas
In reply to this post by Stefan Monnier
Stefan Monnier <[hidden email]> 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.  ;-)



Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Stefan Monnier
>> 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




Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Stephen Berman
On Thu, 19 Nov 2020 00:15:04 -0500 Stefan Monnier <[hidden email]> 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



Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

martin rudalics
 > 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



Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Eli Zaretskii
In reply to this post by Stephen Berman
> From: Stephen Berman <[hidden email]>
> Date: Thu, 19 Nov 2020 10:33:28 +0100
> Cc: Stefan Kangas <[hidden email]>, [hidden email]
>
> $ 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.



Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Juri Linkov-2
In reply to this post by Stephen Berman
> $ 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:


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)))
Reply | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Juri Linkov-2
>> $ 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 | Threaded
Open this post in threaded view
|

bug#5423: Multiline y-or-n prompt in files.el

Stefan Monnier
> 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