GNU bug report logs -
#10191
dired-query (in dired-aux.el) fails for certain help-char's, Emacs 23 and 24
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (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 2 (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.