[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Colourising a label prints it twice
From: |
Stephen Berman |
Subject: |
Re: Colourising a label prints it twice |
Date: |
Sat, 13 Jul 2024 01:26:27 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
On Fri, 12 Jul 2024 23:09:28 +0000 Heime <heimeborgia@protonmail.com> wrote:
> I have the following function to colourise the label, but I get OFF printed
> twice.
>
> (defun label-select (label)
> "Color the part of LABEL after [-]."
>
> (if (string-match "\\[\\-\\] \\(.*\\)" label)
>
> (let ( (bt (match-string 0 label))
> (lb (match-string 1 label)) )
> (concat bt (propertize lb 'face '(:foreground "red"))))
>
> label))
>
> (insert (format " %s \n" (label-select "[-] OFF ")))
> (insert (format " %s \n" (label-select "[-] OFF ")))
> (insert (format " %s \n" (label-select " [-] OFF ")))
`bt' is the entire string passed by LABEL, but IIUC it should just be
the string "[-] ", so put that in a group:
(defun label-select (label)
"Color the part of LABEL after [-]."
(if (string-match "\\(\\[\\-\\] \\)\\(.*\\)" label)
(let ( (bt (match-string 1 label))
(lb (match-string 2 label)) )
(concat bt (propertize lb 'face '(:foreground "red"))))
label))
Steve Berman