[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [External] : Get boundaries of the string at point matching a regula
RE: [External] : Get boundaries of the string at point matching a regular expression
Thu, 18 Nov 2021 20:15:47 +0000
> 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
> (insert "fooooooooo bar")
> (goto-char 1)
> (org-in-regexp "fo+"))
> (1 . 11)
> 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.