wolray / symbol-overlay

Highlight symbols with keymap-enabled overlays
346 stars 42 forks source link

Avoid positional arguments to define-minor-mode #73

Closed tarsius closed 3 years ago

tarsius commented 3 years ago

Back in Emacs-21.1, define-minor-mode grew keyword arguments to replace its old positional arguments. Starting with Emacs-28.1 warning will be omitted if positional arguments are still used.

purcell commented 3 years ago

Generally in favour, but doesn't this cause symbol-overlay-mode-map to no longer be defined?

purcell commented 3 years ago

(Not that it's used in the code or examples, but I - for one - use it instead of binding keys globally, see here

tarsius commented 3 years ago

If the keymap is left unspecified, then a sparse keymap is created and bound to MODE-map.

:keymap MAP Keymap bound to the mode keymap.  Defaults to `MODE-map'.
        If non-nil, it should be a variable name (whose value is
        a keymap), or an expression that returns either a keymap or
        a list of (KEY . BINDING) pairs where KEY and BINDING are
        suitable for `define-key'.  If you supply a KEYMAP argument
        that is not a symbol, this macro defines the variable MODE-map
        and gives it the value that KEYMAP specifies.
purcell commented 3 years ago

I think that's a misunderstanding of the docstring, given what I see when I macroexpand it:

(define-minor-mode foo-mode "")

=>

                (add-minor-mode 'foo-mode 'nil
                    (if
                        (boundp 'foo-mode-map)
                        foo-mode-map)
                    nil nil)
tarsius commented 3 years ago

You're right. I've fixed the pr. Instead of doing it exactly like this you could also or instead add:

(defvar symbol-overlay-mode-map (make-sparse-keymap)
  "Keymap for `symbol-overlay-mode'.")

in order to be more explicit. Would you prefer that?

purcell commented 3 years ago

Yeah, that'd be ideal, probably. But a defcustom I guess.

tarsius commented 3 years ago

But a defcustom I guess.

Whaaaaa?!

tarsius commented 3 years ago

I've added the defvar, so now it is doppelt gemoppelt.

purcell commented 3 years ago

But a defcustom I guess.

Whaaaaa?!

There's a :type 'keymap, no? But whatever, I'll go ahead and merge this. Thanks!