6

I would like to make tab characters ("\t") display as arrows of varying length, just like in editors such as Notepad++, gedit, Geany, etc. Here is an example with tab width set to 4 and space characters displayed as dots:

tab character displayed as arrow of varying length

Is there a way to achieve the same functionality in GNU Emacs? Maybe by configuring the whitespace-mode?

3
  • The display-table elements take one ore more characters, which are used to represent a tab. Thus, a stretch-glyph is not a built-in feature in so far as the display-table is concerned. It is possible to create a visual effect with overlays, but that would need to be redrawn. If we are talking the whole buffer, then it will not be efficient. If we are talking about just the visible window, then we need a new feature that the Emacs team has toyed with and which I have implemented myself in a custom version using a new window-start-end-hook. Existing mechanisms are insufficient.
    – lawlist
    Commented May 22, 2017 at 14:17
  • To read more about this idea of knowing the bounds and targeting just the visible window (and the limitations of the existing functions window-start and window-end), there is an Emacs developer mail thread that talks about a potential new post-redisplay-hook. I'm not sure if anything has happened in the past few months since I last checked. There are a couple of bug report threads that also discuss the limitations of knowing with 100% accuracy window-start and window-end -- e.g., when scrolling, point partially visible, etc.
    – lawlist
    Commented May 22, 2017 at 14:45
  • Another idea would be to assign a background color to the tab character itself in the buffer-display-table (using make-glyph-code) to create a stretch rectangle shade spanning the width of the tab. It's not a visual character like an arrow, but it may be a little closer to a visual representation (beyond a plain old blank space that is).
    – lawlist
    Commented Nov 3, 2017 at 0:32

1 Answer 1

1

Maybe you should try this:

https://github.com/twlz0ne/whitespace4r.el

Change the display mappings:

- (tab-mark        . [?\s ?»])
+ (tab-mark        . [?— ?⟶])

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.