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

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

bug#6690: 24.0.50; tmm-get-keymap is broken


From: Stefan Monnier
Subject: bug#6690: 24.0.50; tmm-get-keymap is broken
Date: Mon, 02 Aug 2010 01:43:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> emacs -Q
> In several of the `cond' branches the variable `str' is not defined, so
> it is nil from the `let' default initialization.
 
> Then this code raises an error "Wrong type argument: stringp, nil",
> since `str' is not a string:
 
> (unless (eq km 'ignore)
>           (let ((binding (where-is-internal km nil t)))
>             (when binding
>               (setq binding (key-description binding))
>               ;; Try to align the keybindings.
>               (let ((colwidth (min 30 (- (/ (window-width) 2) 10))))
 
> ;; STR is nil - so cannot use `string-width' or `concat'.
 
>                 (setq str
>                       (concat str
>                               (make-string (max 2 (- colwidth
>                                                      (string-width str)
>                                                      (string-width binding)))
>                                            ?\s)
>                               binding))))))
 
Thanks for the report.  Indeed, the code is brittle in this regard.
I could easily work around the problem by checking `str' before taking
its width (concat should work just fine with nil), but before I do that,
I'd like to make sure the result (which would basically treat a nil as
equivalent to "") is right, so could you give some example where the
problem gets triggered (in all "reasonable" cases I can think of, str
ends up being non-nil since otherwise it means the menu entry would
have a valid command and a valid shortcut, but no name).


        Stefan





reply via email to

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