From: "José Júnior" <jjnilton@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 64632@debbugs.gnu.org
Subject: bug#64632: Feature request: downcase-char, downcase-initials
Date: Sat, 15 Jul 2023 11:13:40 -0300 [thread overview]
Message-ID: <CAGD2S5UYuyzG=2Z8asiG3nD5Lzcu79CZ4qLiE7U_urDzb02Rmg@mail.gmail.com> (raw)
In-Reply-To: <83fs5pemin.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 2554 bytes --]
In my case, it would be helpful for writing snippets. I missed these
functions when I was writing some snippets for some boilerplate code, where
in some situations `upcase-initials` was helpful, and so would be
`downcase-initials`. I'd guess a `downcase-initials-region` (like
`upcase-initials-region`) could be useful in certain cases, like fixing
function names in code, or even writing in general, but probably very
situational.
I understand equivalence alone wouldn't be enough to introduce new
commands, but it _feels_ that is missing something having one way but not
the other, especially when there's a `upcase-char` but not a
`downcase-char`.
And about `downcase-region` I don't think it would help in my case because
I needed to down case only the initial character of the word, and it's
interactive and requires an extra step (marking the region).
Anyway, I wrote these functions to fix my issue, maybe it can help someone
else:
(they probably could be better since I don't know Emacs Lisp well, but
worked for me)
```
(defun downcase-char (arg)
"Downcasify ARG chars starting from point. Point doesn't move."
(interactive "p")
(save-excursion
(downcase-region (point) (progn (forward-char arg) (point)))))
(defun downcase-initial (string)
"Downcase initial character of the string."
(concat (downcase (substring string 0 1)) (substring string 1)))
(defun downcase-initials (string)
"Upcase the initial of each word in the string."
(mapcar #'downcase-initial (split-string string "[^[:alpha:]]")))
(defun downcase-initials-region (beg end)
"Upcase the initial of each word in the region."
(interactive "r")
(let ((region (buffer-substring-no-properties beg end)))
(delete-region beg end)
(insert (downcase region))))
```
On Sat, Jul 15, 2023 at 3:06 AM Eli Zaretskii <eliz@gnu.org> wrote:
> > From: José Júnior <jjnilton@gmail.com>
> > Date: Fri, 14 Jul 2023 20:31:42 -0300
> >
> > Hi, my suggestion is to add equivalent functions for `upcase-char` and
> `upcase-initials` but for
> > downcase (`downcase-char` and `downcase-initials`). When I first these
> functions, I expected to have
> > the downcase equivalent for each of them.
>
> Thanks.
>
> In which situations would such commands be useful? We don't introduce
> commands just because they are equivalents of others.
>
> Anyway, we already have downcase-region, which you could use to
> downcase any range of characters, including a single character
> anywhere in a word.
>
[-- Attachment #2: Type: text/html, Size: 3225 bytes --]
prev parent reply other threads:[~2023-07-15 14:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 23:31 bug#64632: Feature request: downcase-char, downcase-initials José Júnior
2023-07-15 6:06 ` Eli Zaretskii
2023-07-15 14:13 ` José Júnior [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGD2S5UYuyzG=2Z8asiG3nD5Lzcu79CZ4qLiE7U_urDzb02Rmg@mail.gmail.com' \
--to=jjnilton@gmail.com \
--cc=64632@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.