In a GUI Emacs without fringes, I would like to get rid of the '$' at the end of truncated lines such that lines can use the fill width of the window. I've tried:

  1. (set-display-table-slot standard-display-table 'truncation 0) : this replaced $ with a space (or an empty slot).
  2. (set-display-table-slot standard-display-table 'truncation nil) : this fall back to $

My question is thus how to display truncated lines without any truncation symbol on the right?

Here is a small mockup:

a) |Truncated lin$| -> Normal behavior
b) |Truncated lin…| -> Truncation symbol set to ?\…
c) |Truncated lin | -> Truncation symbol set to 0
d) |Truncated line| -> What I would like to obtain
  • 1
    Emacs really wants to show you that the line is truncated. When you turn off the fringes, that overrides any ellipsis setting such as truncate-string-ellipsis. You'd have to take this up with the Emacs developers to get it changed.
    – rpluim
    Aug 10 '20 at 10:47
  • Are there any hack around it ? Like pretending the window is actually wider than physical size? Aug 10 '20 at 12:40
  • If you want to go down that route, you might as well hack xdisp.c:init_iterator to not display the '$'. Look for the handling of no_special_glyphs
    – rpluim
    Aug 10 '20 at 12:47
  • I was thinking of taking advantage of bidirectional display and pretending my line must be displayed right to left. Such are lines are aligned ti the right edge. Aug 10 '20 at 13:07
  • See the line SET_GLYPH_FROM_CHAR (glyph, '$'); within xdisp.c.
    – lawlist
    Aug 10 '20 at 17:59

I found a solution by "abusing" the display table. In the below solution, msg is a string whose length is window width +1 (such as to display the truncation character). I then set the truncation character to the last character of the string.

      (window-display-table (minibuffer-window))
      'truncation  (make-glyph-code (string-to-char (substring msg -1))))
 (message msg) 

Your Answer

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

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