emacs-humanities
[Top][All Lists]
Advanced

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

Re: [emacs-humanities] How can I `upcase-word` for ALL words in the buff


From: Marcin Borkowski
Subject: Re: [emacs-humanities] How can I `upcase-word` for ALL words in the buffer without typing the word twice?
Date: Wed, 05 Apr 2023 06:47:17 +0200
User-agent: mu4e 1.1.0; emacs 30.0.50

On 2023-04-04, at 21:50, David Hedlund <public@beloved.name> wrote:

> I'm constantly running into this situation because when I'm copying
> code, pylint is giving me the message: Constant name "parser" doesn't
> conform to UPPER_CASE naming style (python-pylint)
>
> In the sample code section below, I'm trying to replace "parser", and
> "args", with "PARSER", and "ARGS", respectively.
>
> Normally I'd use.
>
> M-x RET replace-string RET parser RET PARSER
>
> M-x RET replace-string RET args RET ARGS
>
> However, I don't like the idea of typing the word twice (lowercase,
> then uppercase), because
>
> * it's time-consuming
>
> * here's a risk that I make a typo.
>
>
> This is only useful for the selected word:
>
> M-x RET upcase-word RET
>
>
> To illustrate, I'd like to run something like this to replace "parser"
> with "PARSER" in the whole buffer:
>
> M-x RET replace-string-TO-upcase-word RET parser

You already got two excellent answers, but let me mention that writing
a simple Elisp function to find one of a set of specific words and
upcase it (or prompt for a word and upcase that word in the whole buffer
or region) should be pretty simple.  (I might even show you how to write
it if you want -- but first a question: is the set of words you need to
upcase predetermined or do you want to provide a word every time?)

Best,

-- 
Marcin Borkowski
http://mbork.pl



reply via email to

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