From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime Newsgroups: gmane.emacs.help Subject: RE: [External] : Regexp for matching (defun lines Date: Wed, 31 Jul 2024 20:14:47 +0000 Message-ID: <5kzhsBHCj8GW4rjzi0sutBSutYlMHmDBIV7PD1V_v0CGB-KH5pSJPw0jrwHErO5ivHjsPTAcmmaAHXNJH4u6VON3xL6q7Hdwnf2SNxOw_G8=@protonmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23485"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'" To: Drew Adams Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 31 22:15:29 2024 Return-path: Envelope-to: geh-help-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 1sZFjN-0005uF-7E for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 31 Jul 2024 22:15:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZFiq-0008NH-CT; Wed, 31 Jul 2024 16:14:56 -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 1sZFio-0008Mt-1g for help-gnu-emacs@gnu.org; Wed, 31 Jul 2024 16:14:54 -0400 Original-Received: from mail-4027.protonmail.ch ([185.70.40.27]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZFim-0006qv-6J for help-gnu-emacs@gnu.org; Wed, 31 Jul 2024 16:14:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1722456890; x=1722716090; bh=31uXuSzZJUED8ZN4abJJqd4mSEgAP1dYKb9GNYnnyZs=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Lw9YAWCSwP4gPrGnwVOpBDFGH39L7VRveqxardokA/txLJ2sBWf/TDsX6iPIu4abx Tn7mxbiaxhQsawYTvL3sfuDZyz2addyuwY67WZh6L0UiKLvXYVn7P2/e0L4geVJc5y HAcPLqabJtKeHcDGtb0z6Z8SGKkzdPxsQreYHibtAvv0GrNxLy830UlBu+E1gLig8D bF3KvcV6TeKcDmrOyWRz0cSym7IRIrkpNVXlE/+DVlufE9M+WGyfaSIlouLLHMdFjy c2og5WriWh1/V3QDEcqMaoQwu78EsHmK4u72iGzjS0S4GBhmZgUfA8eg5VQSTQFRGJ y7h6pmITLo60g== In-Reply-To: Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 8c23b652c574bf491189e4c300bd939a10e044ed Received-SPF: pass client-ip=185.70.40.27; envelope-from=heimeborgia@protonmail.com; helo=mail-4027.protonmail.ch X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:147467 Archived-At: On Thursday, August 1st, 2024 at 7:59 AM, Drew Adams wrote: > > I awm using the following regexp to match "(defun" lines > >=20 > > ("defun" "^\\s-*(defun\\s-+\\([[:alnum:]-]+\\)") 1) > >=20 > > I need regexp suggestions to improve upon it. >=20 >=20 > FWIW, in `imenu+.el' I use these regexps for function > and macro definitions: >=20 > imenup-lisp-fn-defn-regexp-1: >=20 > (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_\\)+\\)") I see that you use "\\sw". What is the advantage verses "[[:alnum:]-_]" Why do you use the OR "\\|" with "\\s_" ? =20 > imenup-lisp-fn-defn-regexp-2 (defs with a quoted name): >=20 > (concat "^\\s-(" > (regexp-opt '("defalias" "fset") t) > "\\s-+'\\s-\\(\\(\\sw\\|\\s_\\)+\\)") >=20 >=20 > imenup-lisp-macro-defn-regexp: >=20 > "(\\s-*\\(defmacro\\|cl-defmacro\\|cl-define-compiler-macro\\|\ > define-compiler-macro\\|define-modify-macro\\)\\s-+\\([^ \t()]+\\)" >=20 >=20 > 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. >=20 > HTH.