Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

symbol-overlay-mode #2

Closed
dakra opened this issue Apr 12, 2017 · 11 comments
Closed

symbol-overlay-mode #2

dakra opened this issue Apr 12, 2017 · 11 comments

Comments

@dakra
Copy link
Contributor

dakra commented Apr 12, 2017

Hi, I like the package, especially since highlight-symbol doesn't seem to be maintained anymore.

I always use highlight-symbol-mode which is a minor mode that always
highlights automatically the symbol under the cursor.

Would be a nice feature for symbol-overlay as well.

Also how comes o and u are default bindings for next and prev?
Would have expected either n/p or maybe f/b.

Thanks :)

@wolray
Copy link
Owner

wolray commented Apr 14, 2017

I use "o/u" as the common next-and-prev-like bindings when searching or moving over texts because they are at the most natural positions on the keyboard. It's comfortable for my fingers: "u/o" to move around while "i" for confirming/toggling and "k" for killing/deleting.

However, It's just a matter of personal taste. You can customize the keymap as you like.

highlight-symbol-mode is indeed a nice feature though I had hardly used it. Maybe it will be added to symbol-overlay in the future versions.

Thanks.

@ruibinx
Copy link

ruibinx commented Apr 22, 2017

please add this feature :)

@dakra
Copy link
Contributor Author

dakra commented Apr 22, 2017

@borgnix jFYI, until this get's implemented here I have the following in my config:

;; Make highlight symbol use overlay-put instead of font-lock
;; https://github.com/nschum/highlight-symbol.el/issues/26#issuecomment-233168193
(defun highlight-symbol-add-symbol-with-face (symbol face)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward symbol nil t)
      (let ((ov (make-overlay (match-beginning 0)
                              (match-end 0))))
        (overlay-put ov 'highlight-symbol t)
        (overlay-put ov 'face face)))))

(defun highlight-symbol-remove-symbol (_symbol)
  (dolist (ov (overlays-in (point-min) (point-max)))
    (when (overlay-get ov 'highlight-symbol)
      (delete-overlay ov))))

@ruibinx
Copy link

ruibinx commented Apr 26, 2017

@dakra Thank you!

@wolray
Copy link
Owner

wolray commented Apr 26, 2017

Good news! We have symbol-overlay-mode now.

Check the new feature after Melpa finish this build. Wish you enjoy it.

@borgnix @dakra

@dakra
Copy link
Contributor Author

dakra commented Apr 27, 2017

Very nice :)

I see the mode does not have a keymap and if I call
symbol-overlay-jump-next it says 'Symbol is not highlighted'.

I would like to bind M-n and M-p in a symbol-overlay-mode-map so
I can easily jump between the highlighted symbols.

Also is there a setting for the toggle-scope? I would like to
only show current scope by default.

Thanks :)

@wolray
Copy link
Owner

wolray commented Apr 27, 2017

You can easily define a symbol-overlay-mode-map in your own init.el. And it will automatically linked to the minor-mode. Or why not just simply global-set the key?

The user-error of 'Symbol is not highlighted' is deleted, now you can start a jump from any position even inside a not-highlighted symbol. Same to all the other symbol-overlay commands.

For some reasons, scope is not supported in symbol-overlay-mode. If you wanna toggle the scope, use symbol-overlay-put to highlight it first.

@wolray wolray closed this as completed Apr 27, 2017
@wolray wolray reopened this Apr 27, 2017
@wolray
Copy link
Owner

wolray commented Apr 27, 2017

Alright, you can set symbol-overlay-temp-in-scope to be non-nil to make symbol-overlay-mode highlighting in scope by default, and toggle its value anywhere outside the package.

@dakra
Copy link
Contributor Author

dakra commented Apr 27, 2017

Awesome.

I tried to set the minor-mode-map in use-package but that
didn't really work.
Anyway, using a global key is probably a good idea anyway.

One more thing, I saw you added symbol-overlay-switch-forward/backward
which I like very much and would rather use those
than symbol-overlay-jump-next.. but those functions
are not yet supported in the minor-mode ("No more forward symbols").

Good job 👍

@wolray
Copy link
Owner

wolray commented Apr 27, 2017

switch-forward/backward is for jumping from one symbol to another one. It doesn't make sense to support it in the minor mode, since the symbol at point is already highlighted.

The best philosophy about symbol-overlay is to use jump for jumping between occurrences of a specific symbol, and switch for finding and switching to a new one. As for the minor-mode, just treat it as a sort of quick preview.

:)

@dakra
Copy link
Contributor Author

dakra commented Apr 28, 2017

The thing is that I want one single keybinding.
So I guess I want a symbol-overlay-jump-next-dwim then,
that, if symbol-overlay-minor-mode is active AND a symbol is
under (point) I want to call jump-next else do switch-forward.

Does this make sense?

Anyway, this is obviously only a very minor thing.
Closing the issue already since it works pretty much like I want now :)

@dakra dakra closed this as completed Apr 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants