5

Q: how do I change the face of the outline ellipsis?

When working with outlines, the (customizable) ellipsis indicates when a section is folded and there is hidden text, eg:

* A heading...
** A subheading...
*** A subsubheading...

The ellipsis is customizable via the selective-display slot of the display-table, eg:

(set-display-table-slot standard-display-table 
                        'selective-display 
                        (string-to-vector "!!!")) 

Which gets us to:

* A heading!!!
** A subheading!!!
*** A subsubheading!!!

(No, I'm not actually using exclamation points, it's just an example.)

However, what I'd like to do is customize the ellipsis so that it takes the same face as the outline header it is on. How would one do that?

PS: Note that the EmacsWiki outline-mode node has a couple of suggestions for setting the face, but neither seem to work (at least for me).

PPS: A related thread on the org-ellipsis does not explicitly handle the faces issue.

5

Q:   "However, what I'd like to do is customize the ellipsis so that it takes the same face as the outline header it is on. How would one do that?"

A:   This cannot be done using the buffer-display-table. It's an all or nothing type of deal -- i.e., a change to the buffer-display-table affects everything in the buffer, not merely a particular heading. It is possible to create a different custom overlay for each heading, but it may not be very efficient -- in that case, the display slot 4 would not be used.


Here is an example of what is going on behind the scenes when setting the face for the ellipsis in either outline-mode or org-mode. The display engine of Emacs has built-in support for text with invisible property at the end of the line, which can be visualized via the buffer-display-table. For more information about this special slot, type: M-x describe-variable RET buffer-display-table RET

(let ((display-table
        (if buffer-display-table
          buffer-display-table
          (make-display-table))))
  (unless buffer-display-table
    (setq buffer-display-table display-table))
  (set-display-table-slot display-table 4
    (vconcat (mapcar (lambda (c)
      (make-glyph-code c 'font-lock-keyword-face)) "..."))))
1

Since you mentioned in your PPS, you can set org-ellipsis to a face. Looking at org-ellipsis docstring in org.el, it says org-ellipsis can be set to a face:

(defcustom org-ellipsis nil
  "The ellipsis to use in the Org-mode outline.
When nil, just use the standard three dots.
When a string, use that string instead.
When a face, use the standard 3 dots, but with the specified face.
The change affects only Org-mode (which will then use its own display table).
Changing this requires executing \\[org-mode] in a buffer to become
effective."
  :group 'org-startup
  :type '(choice (const :tag "Default" nil)
         (face :tag "Face" :value org-warning)
         (string :tag "String" :value "...#")))
  • Thanks, but I'm asking about outline-mode in general rather than only org-mode. I'm also asking about a variable face (ie, setting the ellipsis to use a different face depending on which depth of the outline it's in.) – Dan Nov 2 '15 at 15:21
  • Ok, I'll edit my answer specifying it is only org-mode related. – Manuel Uberti Nov 2 '15 at 15:22
  • 1
    I had tried changing the org-ellipsis face but it didn't seem to do anything - I didn't realize you had to set an org-ellipsis variable also! – Brian Burns Nov 2 '17 at 10:53

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.