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: David Hedlund
Subject: Re: [emacs-humanities] How can I `upcase-word` for ALL words in the buffer without typing the word twice?
Date: Mon, 10 Apr 2023 07:00:57 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1


On 2023-04-04 22:26, Joost wrote:
On Tue, 4 Apr 2023, at 21:50, David Hedlund wrote:
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),
The doc string for `replace-regexp` has this:

```
In interactive calls, the replacement text may contain ‘\,’
followed by a Lisp expression used as part of the replacement
text.  Inside of that expression, ‘\&’ is a string denoting the
whole match, ‘\N’ a partial match, ‘\#&’ and ‘\#N’ the respective
numeric values from ‘string-to-number’, and ‘\#’ itself for
‘replace-count’, the number of replacements occurred so far, starting
from zero.
```

So what you can do is:

M-x replace-regexp RET
parser RET
\,(upcase \&) RET

Place point at the start of the buffer (or wherever you want to start the 
replacement), since the command works from point.

HTH


I had to upgrade my distro. Interestingly, this didn't work in Emacs 26 that I used before the upgrade, but it works fine in Emacs 27 that I'm currently using.

Thank you very much for your help.


reply via email to

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