[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Colourising a label prints it twice
From: |
Heime |
Subject: |
Re: Colourising a label prints it twice |
Date: |
Fri, 12 Jul 2024 23:55:49 +0000 |
On Saturday, July 13th, 2024 at 11:26 AM, Stephen Berman
<stephen.berman@gmx.net> wrote:
> 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
Regarding grouping, I want to replicate the original string with respect
to any whitespaces. Does the grouping outline respect the original whitespace
?