From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jos=C3=A9_?= =?UTF-8?Q?J=C3=BAnior?= Newsgroups: gmane.emacs.bugs Subject: bug#64632: Feature request: downcase-char, downcase-initials Date: Sat, 15 Jul 2023 11:13:40 -0300 Message-ID: References: <83fs5pemin.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000003e34ae0600872e24" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7032"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64632@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 15 16:15:13 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qKg3F-0001e7-1o for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 15 Jul 2023 16:15:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKg35-0005q7-Gu; Sat, 15 Jul 2023 10:15:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKg34-0005ll-3X for bug-gnu-emacs@gnu.org; Sat, 15 Jul 2023 10:15:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qKg33-0001EH-QZ for bug-gnu-emacs@gnu.org; Sat, 15 Jul 2023 10:15:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qKg33-00079C-Ko for bug-gnu-emacs@gnu.org; Sat, 15 Jul 2023 10:15:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jos=C3=A9_?= =?UTF-8?Q?J=C3=BAnior?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Jul 2023 14:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64632 X-GNU-PR-Package: emacs Original-Received: via spool by 64632-submit@debbugs.gnu.org id=B64632.168943046727418 (code B ref 64632); Sat, 15 Jul 2023 14:15:01 +0000 Original-Received: (at 64632) by debbugs.gnu.org; 15 Jul 2023 14:14:27 +0000 Original-Received: from localhost ([127.0.0.1]:45684 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qKg2U-000789-Nc for submit@debbugs.gnu.org; Sat, 15 Jul 2023 10:14:27 -0400 Original-Received: from mail-vs1-xe2d.google.com ([2607:f8b0:4864:20::e2d]:56535) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qKg2Q-00077r-BH for 64632@debbugs.gnu.org; Sat, 15 Jul 2023 10:14:25 -0400 Original-Received: by mail-vs1-xe2d.google.com with SMTP id ada2fe7eead31-440b54708f2so1035125137.0 for <64632@debbugs.gnu.org>; Sat, 15 Jul 2023 07:14:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689430457; x=1692022457; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=S3iu4Y5MEmJ4Ekt4jdKKGd3OrPZBQm22vqKVf43G8kE=; b=VNzWHoxRecFClwR+pq+Lw7pbMQSmHzfo+j0oPdn2kvcGvwalrfL6gH560qyPArQ06R d4IMdDCZE0hWlrlreADZA1jL+nw9nmfxl0ODiurfCZkBia02FL7T8CO1bJyBGpsToWNu nh5qzDSeomWBLCuVXPlenUemWvUVGXDA5zM/tkBwKZBvmo11wj1hQDN3E91VNGtQ3nne 9Zgm6Mt4iMBRize2RFhp0+wzyHrqgb+G9wja/nk/7b9RGo17q6gklL7sVt4XuXaOARJ7 RoZfrYN7oG0ixlkBO/J+dDNGYRwMK3ZUi+0waqDiaL9pchMXjJ9o4rZSld30u0ymdi7o vTUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689430457; x=1692022457; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S3iu4Y5MEmJ4Ekt4jdKKGd3OrPZBQm22vqKVf43G8kE=; b=JoSX46znGfoIL/0YuhDQS3sU9aTWwQDgG6DnMmhsyEQBYF1I7V2syz4aGQ6SKK/0I2 OshZxEENkIPjxtsRiSnZl2vhO9GGMTtlD1HQWHEoPMFUZsoI8awAjVoEVnUc4q0b6Zem kTIrZ1Fg5assAQSjqAUiKHkJg2t/oAcfJ/qwbjKe+9RQ6MbI7/FjWuGy9/COG+f82NiJ +i2QsNjNQrRBfelCYDlCowfh7Qt2vXxDPb0DkSZuoJhz5swNkzgj6DxtMsXQjWTgjdhl vRwoRs0Ojf/gx/ZPAObKvPsnipRokO7M4yPp/ohEG7nIVNR4PmR9z+WbMyTyyt03L1m3 7Etg== X-Gm-Message-State: ABy/qLYIwUfH2q7ZHdVc0S8DcidPrVdi3+MpoQzxSwH36qKl0bnxSTXI G8HFW7jJUW4YDR7aIFnCHZOUsI/lfvywAsjvLbg= X-Google-Smtp-Source: APBJJlHRncXfgIIYWlKgONlLB1ZMWgzrNCEy/EtIgKCqi4AihvXDNDslNM+8w1CAS3Rfmm2I0dae3V+V57Wfdjczufw= X-Received: by 2002:a67:f842:0:b0:443:8034:be54 with SMTP id b2-20020a67f842000000b004438034be54mr3943053vsp.32.1689430456676; Sat, 15 Jul 2023 07:14:16 -0700 (PDT) In-Reply-To: <83fs5pemin.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:265207 Archived-At: --0000000000003e34ae0600872e24 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=E2=80=AFAM Eli Zaretskii wrote: > > From: Jos=C3=A9 J=C3=BAnior > > 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. > --0000000000003e34ae0600872e24 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
In my case, it would be helpful for writing snippets.= I missed these functions when I was writing some snippets for some boilerp= late code, where in some situations `upcase-initials` was helpful, and so w= ould be `downcase-initials`. I'd guess a `downcase-initials-region` (li= ke `upcase-initials-region`) could be useful in certain cases, like fixing = function names in code, or even writing in general, but probably very situa= tional.

I understand equivalence alone wouldn&= #39;t be enough to introduce new commands, but it _feels_ that is missing s= omething having one way but not the other, especially when there's a `u= pcase-char` but not a `downcase-char`.

And abo= ut `downcase-region` I don't think it would help in my case because I n= eeded to down case only the initial character of the word, and it's int= eractive 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 kn= ow Emacs Lisp well, but worked for me)

```
(defun downcase-char (arg)
=C2=A0 "Downcasify ARG chars starting= from point. Point doesn't move."
=C2=A0 (interactive "p&q= uot;)
=C2=A0 (save-excursion
=C2=A0 =C2=A0 (downcase-region (point) (= progn (forward-char arg) (point)))))

(defun downcase-initial (string= )
=C2=A0 "Downcase initial character of the string."
=C2=A0= (concat (downcase (substring string 0 1)) (substring string 1)))

(d= efun downcase-initials (string)
=C2=A0 "Upcase the initial of each = word in the string."
=C2=A0 (mapcar #'downcase-initial (split-s= tring string "[^[:alpha:]]")))

(defun downcase-initials-re= gion (beg end)
=C2=A0 "Upcase the initial of each word in the regio= n."
=C2=A0 (interactive "r")
=C2=A0 (let ((region (buf= fer-substring-no-properties beg end)))
=C2=A0 =C2=A0 (delete-region beg = end)
=C2=A0 =C2=A0 (insert (downcase region))))
```

On Sa= t, Jul 15, 2023 at 3:06=E2=80=AFAM Eli Zaretskii <eliz@gnu.org> wrote:
> From: Jos=C3=A9 J=C3=BAnior &l= t;jjnilton@gmail.co= m>
> 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?=C2=A0 We don't intro= duce
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.
--0000000000003e34ae0600872e24--