DarthFennec / highlight-indent-guides

Emacs minor mode to highlight indentation
573 stars 27 forks source link

bitmap method for highlight-indent-guides is not working #81

Open CSRaghunandan opened 4 years ago

CSRaghunandan commented 4 years ago

When I enable bitmap method, and restart highlight-indent-gudies, I don't see the indent guides anymore. I'm not sure what is going on. I tried using different themes just to make sure my theme configuration was not messing it up, but still the issue persisted.

I can even reproduce the issue in emacs -Q: (package-initialize) (setq highlight-indent-guides-method 'bitmap) open any file and enable highlight-indent-guides-mode

DarthFennec commented 4 years ago

I noticed this as well, which is why I haven't closed the issue for this feature yet. On my linux it works fine, but on my macos I either see no guides or uncolored guides depending on which distribution of emacs I test it on.

My intuition is that it has to do with the way XPM images are handled, as emacs needs an external library to use that format, and it might not treat the format properly depending on how the system deals with that requirement (this is vague and might be wrong, I don't know much about how it works in detail). To test this I changed it to use PBM images instead, which seems to work fine everywhere, but currently the implementation is optimized for XPM and is therefore very slow for PBM (especially when using tabs rather than spaces). I've been meaning to find the time to reoptimize the new code so I can release it, and hopefully once that's done it'll work better for you.

andreas-roehler commented 4 years ago

There might be a conflict between setting highlight-indent-guides-method via M-x customize-... or via setq. Suggest to rely on customizing, which would require updating the docs.

DarthFennec commented 4 years ago

@andreas-roehler I'm getting the same results with customize as I do with setq, I didn't realize there was much of a difference. Is yours working better with customize, then?

andreas-roehler commented 4 years ago

This was a rather abstract reasoning, powered by the fact that also the README suggests the use of setq. Problem arises as both setting might provide different values (race condition). Will open a separate issue for it relating to README and discouraging the use of setq.

dlealmt commented 4 years ago

@DarthFennec not sure if it matters, but I'm experiencing this issue on Linux (no bitmap image) on Ubuntu 20.04. Which distribution are you using?

DarthFennec commented 4 years ago

@dleal-mojotech I'm using Arch. Perhaps there's some difference in our environments: emacs uses a library for XPM support, so maybe you don't have that library or have a different build of it that's not entirely compatible or something. Once I get PBM support in everyone should be able to use it, but I still haven't found time to finish the implementation, I'll let you know when I do though.

DarthFennec commented 4 years ago

Okay, I finally had time to fix it to use PBM. Let me know what you guys think.

dlealmt commented 4 years ago

This is working now, thanks! The only wrinkle I see is that customizing highlight-indent-guides-bitmap-function to highlight-indent-guides--bitmap-line, still shows the dots instead of a line. Here's how it looks:

image

and here's my configuration:

(use-package highlight-indent-guides
  :ensure t
  :hook ((prog-mode . highlight-indent-guides-mode)
         (yaml-mode . highlight-indent-guides-mode))
  :custom
  (highlight-indent-guides-method 'bitmap)
  (highlight-indent-guides-responsive 'top)
  (highlight-indent-guides-bitmap-function 'highlight-indent-guides--bitmap-line))
dlealmt commented 4 years ago

Sorry, another difference I noticed is that using character is still significantly faster than using bitmap.

DarthFennec commented 4 years ago

The former might be a caching issue, I'll look into it. Does it still use dots after you restart emacs completely? Or is it just after changing and reloading your config?

I optimized it as much as I could, but yeah, it's definitely slower than character (especially in files with tab indents). I'll see if I can find any other optimizations I can make, but I think it's just going to be the slowest of the bunch regardless, and I don't think there's much we can do about it.

dlealmt commented 4 years ago

@DarthFennec my apologies for taking so long to reply, but given the performance difference, I reverted the method to character and forgot about it. I tried restarting Emacs, and it does work if I set the bitmap function to highlight-indent-guides--bitmap-line.