unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#64632: Feature request: downcase-char, downcase-initials
@ 2023-07-14 23:31 José Júnior
  2023-07-15  6:06 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: José Júnior @ 2023-07-14 23:31 UTC (permalink / raw)
  To: 64632

[-- Attachment #1: Type: text/plain, Size: 240 bytes --]

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.

[-- Attachment #2: Type: text/html, Size: 266 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#64632: Feature request: downcase-char, downcase-initials
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2023-07-15  6:06 UTC (permalink / raw)
  To: José Júnior; +Cc: 64632

> 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.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#64632: Feature request: downcase-char, downcase-initials
  2023-07-15  6:06 ` Eli Zaretskii
@ 2023-07-15 14:13   ` José Júnior
  0 siblings, 0 replies; 3+ messages in thread
From: José Júnior @ 2023-07-15 14:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 64632

[-- 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 --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-15 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).