GNU bug report logs - #10191
dired-query (in dired-aux.el) fails for certain help-char's, Emacs 23 and 24

Previous Next

Package: emacs;

Reported by: Christopher Genovese <genovese.cr <at> gmail.com>

Date: Fri, 2 Dec 2011 06:28:01 UTC

Severity: minor

Done: Stefan Monnier <monnier <at> IRO.UMontreal.CA>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Christopher Genovese <genovese.cr <at> gmail.com>
Subject: bug#10191: closed (Re: bug#10191: dired-query (in dired-aux.el)
 fails for certain help-char's, Emacs 23 and 24)
Date: Fri, 02 Dec 2011 14:19:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#10191: dired-query (in dired-aux.el) fails for certain help-char's, Emacs 23 and 24

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 10191 <at> debbugs.gnu.org.

-- 
10191: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10191
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Christopher Genovese <genovese.cr <at> gmail.com>
Cc: 10191-done <at> debbugs.gnu.org
Subject: Re: bug#10191: dired-query (in dired-aux.el) fails for certain
	help-char's, Emacs 23 and 24
Date: Fri, 02 Dec 2011 09:18:35 -0500
> ; original
> (if help-form
>     (format " [Type yn!q or %s] "
>             (key-description
>              (char-to-string help-char)))
>   " [Type y, n, q or !] ")

> When (characterp help-char) is nil, as in my case, char-to-string raises an
> error.

Thanks.  I've installed the patch below which should fix your problem,


        Stefan


=== modified file 'lisp/dired-aux.el'
--- lisp/dired-aux.el	2011-11-17 09:09:20 +0000
+++ lisp/dired-aux.el	2011-12-02 14:14:09 +0000
@@ -927,8 +927,7 @@
 		 (concat (apply 'format prompt args)
 			 (if help-form
 			     (format " [Type yn!q or %s] "
-				     (key-description
-				      (char-to-string help-char)))
+				     (key-description (vector help-char)))
 			   " [Type y, n, q or !] ")))
 	   (set sym (setq char (read-char-choice prompt char-choices)))
 	   (if (memq char '(?y ?\s ?!)) t)))))


[Message part 3 (message/rfc822, inline)]
From: Christopher Genovese <genovese.cr <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: dired-query (in dired-aux.el) fails for certain help-char's, Emacs 23
	and 24
Date: Fri, 2 Dec 2011 01:27:02 -0500
[Message part 4 (text/plain, inline)]
Whether this is a bug or a ... misunderstanding may be a matter of opinion
because it goes to the nature of help-char. But the problem is easily
fixed in any case.

The function dired-query fails for certain settings of help-char; this
occurs
during the execution of other dired commands (e.g., dired-do-rename-regexp)
without a clear trace of the problem for the user.

For example, I set my help-char to ?\M-\C-h, which works fine in general.
But despite looking like a character, ?\M-\C-h does not satisfy
#'characterp, which causes
the problem. Technically perhaps, help-char should be a character but from
the user's point
of view, both of these should qualify.  While help-event-list can handle
this,
using help-char with such a value works in all the other cases I've seen.

The failure occurs at the following sexp in dired-query (the same code in
23 and 24
despite significant differences in the functions between the two versions):

; original
(if help-form
    (format " [Type yn!q or %s] "
            (key-description
             (char-to-string help-char)))
  " [Type y, n, q or !] ")

When (characterp help-char) is nil, as in my case, char-to-string raises an
error.
Because I find it highly desirable to allow "characters" like ?\M-\C-h for
help-char,
I think this is a bug worth fixing.

Here is a minimal fix for the offending sexp, not my first choice but an
easy change:

; minimal fix
(if (and help-form (characterp help-char))
    (format " [Type yn!q or %s] "
            (key-description
             (char-to-string help-char)))
  " [Type y, n, q or !] ")

Here's a simple fix for the offending sexp that gives better feedback:

; simple fix
(if help-form
    (format " [Type yn!q or %s] "
            (key-description
             (cond
              ((characterp help-char)
               (char-to-string help-char))
              ((eventp help-char)
               (append (event-modifiers help-char)
                       (list (event-basic-type help-char))))
              (t
               "your help char"))))
  " [Type y, n, q or !] ")

Because key-description does not abbreviate symbolic forms of
key modifiers, this gives output like "<control> <meta> h".
For nicer output, the following more elaborate fix could work,
although this *may* be too much for the purpose.

; more (too?) elaborate fix with nicer output
(if help-form
    (format " [Type yn!q or %s] "
            (cond
             ((characterp help-char)
              (key-description (char-to-string help-char)))
             ((eventp help-char)
              (let* ((modifiers
                      (reverse (event-modifiers help-char)))
                     (base
                      (event-basic-type help-char))
                     (mod->str '((meta . "M-")
                                 (control . "C-")
                                 (shift . "S-")
                                 (super . "s-")
                                 (hyper . "H-")
                                 (alt . "A-")
                                 (double . "double-click ")
                                 (triple . "triple-click ")
                                 (drag . "drag ")
                                 (click . "click ")))
                     (modstring  (lambda (mod)
                                   (cdr (assoc mod mod->str)))))
                (apply 'concat
                 (reverse
                  (cons
                    (if (characterp base)
                        (key-description (char-to-string base))
                      (symbol-name base))
                   (mapcar modstring modifiers))))))
             (t
              "your help char")))
  " [Type y, n, q or !] ")


Thanks,

  Chris
[Message part 5 (text/html, inline)]

This bug report was last modified 13 years and 178 days ago.

Previous Next


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