[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#31782: 26.1; dired-recursive-deletes broken

From: Noam Postavsky
Subject: bug#31782: 26.1; dired-recursive-deletes broken
Date: Mon, 30 Jul 2018 21:39:12 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

tags 31782 + patch

Noam Postavsky <address@hidden> writes:

> So, looking at the Bug#30073 fix, the new (currently being introduced in
> Emacs 27) read-answer function looks pretty similar to
> read-multiple-choice.  Perhaps some sharing is in order?

There are differences in both the interface and implementation which
make it difficult to merge these, even though the functionality has some
overlap.  Maybe something could be done later, but for now we'll have to
settle for taking it as is (modulo the fix for the standard value
problem).  Here is the backported patch:

Attachment: 0001-New-function-read-answer-bug-30073.patch
Description: patch

I guess assoc-delete-all should be announced in NEWS too?  Although it
looks like it could be replaced with cl-delete instead.

> Another thing is that the defcustom default value trick doesn't work as
> intended (as far as I understand the intention, at least).
>     ;; For backward compatibility check if short y/n answers are preferred.
>     (defcustom read-answer-short (eq (symbol-function 'yes-or-no-p) 'y-or-n-p)
>       "If non-nil, accept short answers to the question."

> I think we'd want some `auto' setting which would tell read-answer to
> look at the yes-or-no-p function value at run time.

Here's a patch for that against master (I already included this into the
backported patch above).

>From 1059db2520f1aa8d26d2cdb253c57421f647df2e Mon Sep 17 00:00:00 2001
From: Noam Postavsky <address@hidden>
Date: Wed, 4 Jul 2018 22:51:45 -0400
Subject: [PATCH 1/2] Respect non-saved value of `read-short-answer'

* lisp/emacs-lisp/map-ynp.el (read-answer-short): Add an `auto'
(read-answer): Check the function cell of `yes-or-no-p' when
`read-answer-short' is `auto' rather than calling
`custom-reevaluate-setting' which would reset the option to its saved
 lisp/emacs-lisp/map-ynp.el | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el
index 61c04ff7b3..c029c7e1b5 100644
--- a/lisp/emacs-lisp/map-ynp.el
+++ b/lisp/emacs-lisp/map-ynp.el
@@ -257,9 +257,14 @@ map-y-or-n-p
 ;; either long or short answers.
 ;; For backward compatibility check if short y/n answers are preferred.
-(defcustom read-answer-short (eq (symbol-function 'yes-or-no-p) 'y-or-n-p)
-  "If non-nil, accept short answers to the question."
-  :type 'boolean
+(defcustom read-answer-short 'auto
+  "Control whether `read-answer' accepts short answers.
+If t, accept short (single key-press) answers to the question.
+If nil, require long answers.  If `auto', accept short answers if
+the function cell of `yes-or-no-p' is set to `y-or-on-p'."
+  :type '(choice (const :tag "Accept short answers" t)
+                 (const :tag "Require long answer" nil)
+                 (const :tag "Guess preference" auto))
   :version "27.1"
   :group 'minibuffer)
@@ -290,8 +295,9 @@ read-answer
 Return a long answer even in case of accepting short ones.
 When `use-dialog-box' is t, pop up a dialog window to get user input."
-  (custom-reevaluate-setting 'read-answer-short)
-  (let* ((short read-answer-short)
+  (let* ((short (if (eq read-answer-short 'auto)
+                    (eq (symbol-function 'yes-or-no-p) 'y-or-n-p)
+                  read-answer-short))
           (if (assoc "help" answers)

And once backported, we should remove the announcement from 27.1 NEWS,
since the new function it will already be introduced in 26.2:

>From c791639c259abe6e514a4e3ffd62c904cff636e2 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <address@hidden>
Date: Mon, 30 Jul 2018 21:02:07 -0400
Subject: [PATCH 2/2] ; etc/NEWS: Remove read-answer, it was backported to v26

 etc/NEWS | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 5ca1b428de..2825bb9f59 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -913,10 +913,6 @@ higher-level functions.
 some years back.  It now respects 'imagemagick-types-inhibit' as a way
 to disable that.
-** The new function 'read-answer' accepts either long or short answers
-depending on the new customizable variable 'read-answer-short'.
 ** The function 'load' now behaves correctly when loading modules.
 Specifically, it puts the module name into 'load-history', prints
 loading messages if requested, and protects against recursive loads.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]