Skip to main content

Timeline for Colored string in mode line

Current License: CC BY-SA 4.0

6 events
when toggle format what by license comment
Jul 25, 2020 at 18:15 comment added Drew @Fólkvangr: Yes, I know. And? If you can modify something then it's mutable. But all of this is extraneous. If you prefer, read "Suppose that the value of ss is a string", instead of the setq. The point of the answer is that you can use add-face-text-property to add color to a string.
Jul 25, 2020 at 17:19 comment added user19761 @Drew: copy-sequence allows to create a mutable string (c.f. Elisp manual version 27, section 2.9 Mutability). In your sample code, add-face-text-property modifies a literal string.
Jul 25, 2020 at 16:15 comment added Drew @Fólkvangr: Depends on what behavior you want. Do you want to modify a copy of the original string or the original string? The example of using a literal string here is also for brevity - who knows where the actual original string comes from? But if the intention is to modify the original string, then you don't want to use copy-sequence.
Jul 25, 2020 at 11:42 comment added user19761 You should not try to modify a literal string: (setq ss (copy-sequence "abcde")).
Jul 23, 2020 at 21:08 comment added Gabriele That's good to know. Thanks.
Jul 23, 2020 at 16:17 history answered Drew CC BY-SA 4.0