* Get boundaries of the string at point matching a regular expression
@ 2021-11-18 19:58 Rodrigo Morales
2021-11-18 20:15 ` [External] : " Drew Adams
0 siblings, 1 reply; 2+ messages in thread
From: Rodrigo Morales @ 2021-11-18 19:58 UTC (permalink / raw)
To: help-gnu-emacs
I know that org-in-regexp can be used to check that the point is inside
a given regular expression (see minimal working example below). However,
this has the huge dependency of Org Mode.
#+BEGIN_SRC elisp
(with-temp-buffer
(insert "fooooooooo bar")
(goto-char 1)
(org-in-regexp "fo+"))
#+END_SRC
#+RESULTS:
#+begin_example
(1 . 11)
#+end_example
I'm now wondering whether there's a function bundled with Emacs that
doesn't depend in Org Mode that would do the same of org-in-regexp. I
was thinking in copying the definition of org-in-regexp, but I would
like to first ask for other approaches.
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [External] : Get boundaries of the string at point matching a regular expression
2021-11-18 19:58 Get boundaries of the string at point matching a regular expression Rodrigo Morales
@ 2021-11-18 20:15 ` Drew Adams
0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2021-11-18 20:15 UTC (permalink / raw)
To: Rodrigo Morales, help-gnu-emacs@gnu.org
> I know that org-in-regexp can be used to check that the point is inside
> a given regular expression (see minimal working example below). However,
> this has the huge dependency of Org Mode.
>
> #+BEGIN_SRC elisp
> (with-temp-buffer
> (insert "fooooooooo bar")
> (goto-char 1)
> (org-in-regexp "fo+"))
> #+END_SRC
>
> #+RESULTS:
> #+begin_example
> (1 . 11)
> #+end_example
>
> I'm now wondering whether there's a function bundled with Emacs that
> doesn't depend in Org Mode that would do the same of org-in-regexp. I
> was thinking in copying the definition of org-in-regexp, but I would
> like to first ask for other approaches.
Wait for other answers, but my answer is this:
1. I don't think there's any other predefined function
that gives you this.
2. Looking at the definition, `org-in-regexp' is not
about point being inside or at or on a regexp. It's
about point being in a line where some text in the
line matches a given regexp.
3. It looks to me like the def of `org-in-regexp' is
as succinct as it gets for that.
4. Based on #3, I'd say just copy that defun. You can
rename your copy, if you like.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-18 20:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-18 19:58 Get boundaries of the string at point matching a regular expression Rodrigo Morales
2021-11-18 20:15 ` [External] : " Drew Adams
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.