dbordak / telephone-line

A new implementation of Powerline for Emacs
GNU General Public License v3.0
550 stars 51 forks source link

Can't color text unless segment has nil style #94

Open sebasmonia opened 5 years ago

sebasmonia commented 5 years ago

After some experimenting and reading the existing code I re-defined the buffer modified segment as:

(telephone-line-defsegment* telephone-line-buffer-mod-segment ()
    (if (buffer-modified-p)
        (propertize "!" 'face '(:foreground "red" :weight bold))
      "-"))

I tried a lot of things (initially I had a named face, for example) but it seems the only reason I wasn't getting a red "!" was that the segment had accent face. I noticed the compilation output was colored, it happened to be a "nil-faced" segment.

Is this a bug? expected behavior? At some point I got the ! with a different background than the accent color but the text was still white, no matter what I did.

dbordak commented 5 years ago

Yeah, this isn't supported yet, see #67

Unsure if I can fix it

sebasmonia commented 5 years ago

Maybe there's a way to enumerate the existing text properties and then merge the accent face with whatever the text has?

david-wakeo commented 5 years ago

Hello,

I have also encountered the issue and I believe it is fixable with add-face-text-property. Here is a working proof of concept by replacing telephone-line-propertize-segment implementation by:

(defun telephone-line-propertize-segment (pred face segment)
  (unless (seq-empty-p (string-trim (format-mode-line segment)))
    (if (or pred (not (telephone-line-selected-window-active)))
        (if (not (stringp (car segment)))
            `(:propertize (" " ,segment " ") face ,face)
          (let ((segment-string (format " %s " (car segment))))
            (add-face-text-property 0 (length segment-string) face 'append segment-string)
            segment-string))
      `(" " ,segment " "))))

That's what I currently use in my configuration and inner properties are correctly rendered along with the segment face (either with accent or nil)

panurg commented 3 years ago

I have experienced both #94 and #67 issues in my custom segments. I spent couple of hours poking around my configuration and trying to find out where is the problem. It seems like that proposal solves color issue, but not the all-the-icons one. It also breaks hud segment. Any ideas how it could be improved?