emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#10191: closed (dired-query (in dired-aux.el) fails


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#10191: closed (dired-query (in dired-aux.el) fails for certain help-char's, Emacs 23 and 24)
Date: Fri, 02 Dec 2011 14:19:01 +0000

Your message dated Fri, 02 Dec 2011 09:18:35 -0500
with message-id <address@hidden>
and subject line Re: bug#10191: dired-query (in dired-aux.el) fails for certain 
help-char's, Emacs 23 and 24
has caused the debbugs.gnu.org bug report #10191,
regarding dired-query (in dired-aux.el) fails for certain help-char's, Emacs 23 
and 24
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
10191: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10191
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- 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 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



--- End Message ---
--- Begin Message --- 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 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux)
> ; 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)))))



--- End Message ---

reply via email to

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