help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Colour Capital Letters


From: Marcin Borkowski
Subject: Re: Colour Capital Letters
Date: Wed, 25 Oct 2023 20:30:09 +0200
User-agent: mu4e 1.1.0; emacs 30.0.50

On 2023-10-18, at 21:40, Heime <heimeborgia@protonmail.com> wrote:

> Sent with Proton Mail secure email.
>
> ------- Original Message -------
> On Thursday, October 19th, 2023 at 6:58 AM, Marcin Borkowski <mbork@mbork.pl> 
> wrote:
>
>
>> On 2023-10-02, at 03:58, Heime heimeborgia@protonmail.com wrote:
>> 
>> > I want to make a stand alone function that uses a different colour for 
>> > capital letters
>> > in CamelCase names. Possibly taking code from glasses.el.
>> > 
>> > (defun color-camelcase-capital-letters ()
>> > "Color capital letters in CamelCase variables."
>> > (interactive)
>> > (highlight-regexp "\\(?:^\\|\\b\\)[[:upper:]][[:lower:]]*" 'hi-yellow))
>> 
>> 
>> Just saw this while looking through my email backlog. This is a great
>> idea, but I think it can be made even better. How about using two
>> colors so that subsequent /words/ in CamelCase identifiers are colored
>> differently? I suspect this could be great for readibility!
>> 
>> > What can I do ?
>> 
>> 
>> Do you have any working code? I might be tempted to try to write
>> something like this...
>  
> Do not have a working one yet.  I wanted to start with something quite 
> simple first.  But I was planning to get subsequent words colored differently.
>
> The purpose was about readability, particularly for Latex where one cannot 
> use 
> underscore '_'.

I looked at glasses.el, and it *already has* that feature!  Set
`glasses-separator' to an empty string and `glasses-face' to e.g. 'bold
(the symbol - name of te face).  Note: use customize-option.

If you really want to highlight every other subword, not just the
initial letters, check out this proof-of-concept implementation:
https://gitlab.com/-/snippets/3614958 .  I plan to blog about it on Nov
11.

Hth,

-- 
Marcin Borkowski
http://mbork.pl



reply via email to

[Prev in Thread] Current Thread [Next in Thread]