Discussion:
[emms-help] Why are maps declared with defconst?
Pierre Neidhardt
2017-12-24 15:16:04 UTC
Permalink
I wonder why maps are declared with defconst.

It seems to create issues with Evil, such as defining bindings with a
prefix.
I'm not completely sure why as I haven't dug into Evil internals.

Can we change the definition of the maps to using `defvar`?
--
Pierre Neidhardt
Yoni Rabkin
2017-12-29 16:22:05 UTC
Permalink
Post by Pierre Neidhardt
I wonder why maps are declared with defconst.
It seems to create issues with Evil, such as defining bindings with a
prefix.
I'm not completely sure why as I haven't dug into Evil internals.
Can we change the definition of the maps to using `defvar`?
Yes, this would be a good change. How about the style shown in the Elisp
reference manual "11.6 Tips for Defining Variables Robustly"?
--
"Cut your own wood and it will warm you twice"
Pierre Neidhardt
2017-12-29 18:53:42 UTC
Permalink
Do you mean the following?

(defvar my-mode-map nil
DOCSTRING)
(unless my-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-a" 'my-command)
...
(setq my-mode-map map)))
Yoni Rabkin
2017-12-29 19:27:04 UTC
Permalink
Post by Pierre Neidhardt
Do you mean the following?
(defvar my-mode-map nil
DOCSTRING)
(unless my-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-a" 'my-command)
...
(setq my-mode-map map)))
yup

Personally, I can take it or leave it since it is obviously a kludge to
move the docstring closer to where it makes sense.

So moving to defvar with this or with the old style both sound fine to
me.
--
"Cut your own wood and it will warm you twice"
Pierre Neidhardt
2017-12-29 20:05:36 UTC
Permalink
Post by Yoni Rabkin
Personally, I can take it or leave it since it is obviously a kludge to
move the docstring closer to where it makes sense.
Agreed :)
--
Pierre Neidhardt
Pierre Neidhardt
2017-12-29 21:06:39 UTC
Permalink
On a similar note, why do some maps inherit from text-mode-map?

(set-keymap-parent map text-mode-map)

I tried disabling it, it does not seem to change anything.

Thoughts?
--
Pierre Neidhardt
Yoni Rabkin
2017-12-29 22:04:19 UTC
Permalink
Post by Pierre Neidhardt
On a similar note, why do some maps inherit from text-mode-map?
(set-keymap-parent map text-mode-map)
I tried disabling it, it does not seem to change anything.
Thoughts?
In cases like emms-playlist-mode I've always thought that it would be
cool to be able to freely annotate the buffer (I still do). Perhaps
that's what I was thinking... but who really knows since some of this
code is easily over 10 years old.

I wouldn't change it unless there is a compelling reason to do so.
--
"Cut your own wood and it will warm you twice"
Loading...