wolray / symbol-overlay

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

Add a hook for when overlays are created #47

Closed langston-barrett closed 5 years ago

langston-barrett commented 5 years ago

I'm going to use this to enter what Spacemacs calls a "transient state", rather than using the keymap (which is confusing when combined with Spacemacs/Evil modal keybindings).

I don't think we actually need to require cursor-sensor for this to work? Can we just add the property anyway?

langston-barrett commented 5 years ago

Thanks for the quick review! I implemented your more general overlay-creation hook, and was able to recover my special case:

    (defun my/cursor-function (window oldpos entered-or-left)
      (when (equal entered-or-left 'entered)
        (message "entered")))
    (defun my/symbol-overlay-overlay-created-function (ov)
      (overlay-put ov 'cursor-sensor-functions '(my/cursor-function)))

    (add-to-list 'symbol-overlay-overlay-created-functions
                 'my/symbol-overlay-overlay-created-function)

Your detailed feedback was educational, I'm obviously a novice elisp programmer!

NB: The list is called "functions" because that's what the emacs manual section on hooks describes as the proper terminology for hooks that take arguments.

langston-barrett commented 5 years ago

@purcell This is ready for a second round of review