Giter Site home page Giter Site logo

Comments (8)

fgeller avatar fgeller commented on June 14, 2024

Thanks for your feedback!
Let me know if 75596dd isn't what you were looking for :)

from highlight-thing.el.

Fuco1 avatar Fuco1 commented on June 14, 2024

I added some notes to the commit. Thanks for a quick response!

from highlight-thing.el.

fgeller avatar fgeller commented on June 14, 2024

Thanks again :)

Let me know what you think of the changes!

from highlight-thing.el.

Fuco1 avatar Fuco1 commented on June 14, 2024

Awesome.

One more thing. You can (and should) also specify the type of the customize option. This enables emacs to

a) do verification on the type (if user sets some nonsensical value it will bug them about it rather than silently fail somewhere)
b) draw the proper UI widget in the customize interface

You can read about that here: https://www.gnu.org/software/emacs/manual/html_node/elisp/Customization-Types.html

Also notice it specifies the :group option, that's used to group the options related to one package under the same menu.

from highlight-thing.el.

Fuco1 avatar Fuco1 commented on June 14, 2024

Hm, actually, I tried the new version now and it doesn't seem to limit the highlight to defun. Does it work for you? (I still use emacs 24.3)

from highlight-thing.el.

Fuco1 avatar Fuco1 commented on June 14, 2024

Ok, figured it out. It uses font-lock to do the highlight, and that simply works on the entire buffer. If we disable font-lock-mode then it uses overlays and the logic for placing those respects the bounds.

Another weirdity of emacs :D So I changed the defun to

(defun highlight-thing-do ()
  (interactive)
  (let* ((thing (thing-at-point highlight-thing-what-thing))
         (font-lock-mode nil))
    (highlight-thing-remove-last)
    (when (and (highlight-thing-should-highlight) thing)
      (save-excursion
        (save-restriction
          (widen)
          (when highlight-thing-limit-to-defun (narrow-to-defun))
          (highlight-regexp (highlight-thing-regexp thing) 'highlight-thing)))
      (setq highlight-thing-last-buffer (current-buffer))
      (setq highlight-thing-last-thing thing))))

In case no narrowing happens, using font lock is probably much better idea as it is way faster than overlays (especially on large buffers).

from highlight-thing.el.

fgeller avatar fgeller commented on June 14, 2024

Took a bit longer this time, but added type and group information to defcustoms in e2f27a6 -- let me know what you think!
Re font-lock-mode: One of my assumptions for this mode is that font-lock-mode is turned off, so added that part as well to make it explicit. Thanks for looking into it :)

from highlight-thing.el.

Fuco1 avatar Fuco1 commented on June 14, 2024

Sweet, I'll check it out tomorrow, just heading to bed.

from highlight-thing.el.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.