all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: goncholden <goncholden@protonmail.com>, Robert Pluim <rpluim@gmail.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: RE: [External] : Re: Making a regex string that matches (
Date: Thu, 10 Mar 2022 17:57:12 +0000	[thread overview]
Message-ID: <SJ0PR10MB5488829A4ABD8B32311BEC3CF30B9@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <JO60EMe2_V2IFCKjFg585c3Va1An0uIOVKfYq8A11t2UOLdmjcfIRZRDySFRxT_s4LavmoZbqEddi7RlFL4qVpLTOEUhRQUJpjGT3WzZyHA=@protonmail.com>

> Have come up with the following function.  Would this be enough to
> count the number oy opening parantheses in a region ?
> 
> (defun bracketing-count (region-start region-end)
>   "Counts opening and closing bracketing marks.
> Interactive functions enable them to be called using `M-x`"
>   (interactive "r")  ; gets region start and end
>   (message "Counting bracketing marks ...")
>   (save-excursion
>     (let (count)
>       (setq count 0)
>       (goto-char region-start)
>       (while (and (< (point) region-end)
> 		        (search-forward "\(" region-end t))
>         (setq count (1+ count))) ))))

1. You can just use function `count-matches', with "("
   as the regexp.

https://emacs.stackexchange.com/q/70870/105

2. (let (count) (setq count 0)...)
->
   (let ((count  0)...)

3. (search-forward "(" ...)  ; You don't need "\(".

4. If your user uses your command, s?he sees only the
   message "Counting bracketing marks...".  She likely
   would like to see the count at the end, no?

  parent reply	other threads:[~2022-03-10 17:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10 13:36 Making a regex string that matches ( angelomolina--- via Users list for the GNU Emacs text editor
2022-03-10 14:39 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-10 15:51   ` Robert Pluim
2022-03-10 17:14     ` goncholden
2022-03-10 17:48       ` Eric Abrahamsen
2022-03-10 17:57       ` Drew Adams [this message]
2022-03-10 18:54         ` [External] : " Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-10 18:03       ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-11 12:24       ` Leo Butler
2022-03-11 19:53         ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-10 15:13 ` Leo Butler
2022-03-11 23:43 ` Eduardo Ochs

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=SJ0PR10MB5488829A4ABD8B32311BEC3CF30B9@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=goncholden@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=rpluim@gmail.com \
    /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.