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?

  • 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 May 22 '17 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 May 22 '17 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 Nov 3 '17 at 0:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.