0

I provide web-mode-column-show in web-mode.el to display a column that "connects" the start tag and the end tag.

This column may cross empty lines. In that case I use (move-to-column COL t) (see the t arg) to put the overlay at the right column. The problem is that, doing so, I modify the buffer content (I add spaces).

Is there a way to display an overlay at a specific line/column where no "content" exists ?

2
  • You want to look at vline.el and fill-column-indicator.el. It is called an after-string overlay, and it is combined with a filler (spacer). fill-column-indicator is a better example (in my opinion): github.com/alpaker/Fill-Column-Indicator There is also an alignment with a particular column in the fill-column-indicator source code. I based my minor mode on that concept, which is a vertical line that tracks the cursor position. – lawlist Jan 15 '15 at 7:23
  • Here is a link to a quick simple example that does what you want -- it was written at the beginning of my quest: stackoverflow.com/q/23707953/2112489 – lawlist Jan 15 '15 at 7:34
2

Here is a reprint of the example referred to in the comment above:

(save-excursion
  (end-of-line)
  (let ((eol-floating-column (+ (current-column) 10)))
    (overlay-put (make-overlay (point) (point))
                 'after-string
                 (concat
                  (propertize (char-to-string ?\uE001)
                              'display
                              `((space :align-to ,eol-floating-column)
                                (space :width 0)))
                  (propertize (char-to-string ?\u00B6)
                              'face '(:background "gray50" :foreground "black")
                              'cursor t) ))))
2
  • I've implemented my need this way: when the indicator is before eol I use a standard overlay and when the indicator should go beyond eol I put the overlay at the end of the line and attach the 'after-string property – fxbois Jan 16 '15 at 8:20
  • You are correct. There is even a before-string for something to the left of the margin, like linum-mode uses. I'm glad it worked out for your needs. – lawlist Jan 16 '15 at 8:24

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.