From: Drew Adams <drew.adams@oracle.com>
To: Heime <heimeborgia@protonmail.com>,
"'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'"
<help-gnu-emacs@gnu.org>
Subject: RE: [External] : Regexp for matching (defun lines
Date: Wed, 31 Jul 2024 19:59:58 +0000 [thread overview]
Message-ID: <DS7PR10MB52328F1EA22F8D05B3ECA55BF3B12@DS7PR10MB5232.namprd10.prod.outlook.com> (raw)
In-Reply-To: <qFtftvLaY7RKrJF7uMV_fzG0l0tF5vqOMyNFREQcMCiCetTIuk3X5vfaF0gK-O3zWDHXUa9H9ApEZnwQ5uEWDrYwIUjzDZVFNQihlWSR-CI=@protonmail.com>
[-- Attachment #1: Type: text/plain, Size: 1397 bytes --]
> I awm using the following regexp to match "(defun" lines
>
> ("defun" "^\\s-*(defun\\s-+\\([[:alnum:]-]+\\)") 1)
>
> I need regexp suggestions to improve upon it.
FWIW, in `imenu+.el' I use these regexps for function
and macro definitions:
imenup-lisp-fn-defn-regexp-1:
(concat
"^\\s-*("
(regexp-opt
'("defun" "cl-defun" "defun*" "defsubst" "cl-defsubst"
"define-inline" "define-advice" "defadvice" "define-skeleton"
"define-compilation-mode" "define-minor-mode"
"define-global-minor-mode" "define-globalized-minor-mode"
"define-derived-mode" "define-generic-mode" "defsetf"
"define-setf-expander" "define-method-combination"
"defgeneric" "cl-defgeneric" "defmethod" "cl-defmethod"
"ert-deftest" "icicle-define-command"
"icicle-define-file-command")
t)
"\\s-+\\(\\(\\sw\\|\\s_\\)+\\)")
imenup-lisp-fn-defn-regexp-2 (defs with a quoted name):
(concat "^\\s-*("
(regexp-opt '("defalias" "fset") t)
"\\s-+'\\s-*\\(\\(\\sw\\|\\s_\\)+\\)")
imenup-lisp-macro-defn-regexp:
"(\\s-*\\(defmacro\\|cl-defmacro\\|cl-define-compiler-macro\\|\
define-compiler-macro\\|define-modify-macro\\)\\s-+\\([^ \t()]+\\)"
You don't need all of those (e.g., Icicles defs and
old defadvice defs for older Emacs releases). But
you might want to include some other ways to define
functions and macros.
HTH.
[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 14858 bytes --]
next prev parent reply other threads:[~2024-07-31 19:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-31 19:23 Regexp for matching (defun lines Heime
2024-07-31 19:59 ` Drew Adams [this message]
2024-07-31 20:14 ` [External] : " Heime
2024-07-31 21:02 ` Drew Adams
2024-07-31 21:15 ` Heime
2024-08-01 2:11 ` Drew Adams
2024-07-31 21:29 ` Heime
2024-08-01 2:08 ` Drew Adams
2024-08-01 2:24 ` Heime
2024-08-01 3:34 ` Drew Adams
2024-08-01 4:15 ` Heime
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DS7PR10MB52328F1EA22F8D05B3ECA55BF3B12@DS7PR10MB5232.namprd10.prod.outlook.com \
--to=drew.adams@oracle.com \
--cc=heimeborgia@protonmail.com \
--cc=help-gnu-emacs@gnu.org \
/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.
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).