[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/faster-loaddefs cae1261f88: Use a shared regexp for autoload coo
From: |
Lars Ingebrigtsen |
Subject: |
scratch/faster-loaddefs cae1261f88: Use a shared regexp for autoload cookies |
Date: |
Sun, 29 May 2022 08:57:25 -0400 (EDT) |
branch: scratch/faster-loaddefs
commit cae1261f884a812e7e7224b328150f743bf6bc23
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Use a shared regexp for autoload cookies
---
lisp/emacs-lisp/lisp-mode.el | 16 +++++++++++++---
lisp/emacs-lisp/loaddefs-gen.el | 10 ++++------
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 5b93f145e8..0492f25dc9 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -165,6 +165,12 @@
"Imenu generic expression for Lisp mode. See `imenu-generic-expression'.")
+(defconst lisp-mode-autoload-regexp
+ "^;;;###\\(\\([-[:alnum:]]+?\\)-\\)?\\(autoload\\)"
+ "Regexp to match autoload cookies.
+The second group matches package names used to redirect autoloads
+to a package-local <package>-loaddefs.el file.")
+
;; This was originally in autoload.el and is still used there.
(put 'autoload 'doc-string-elt 3)
(put 'defmethod 'doc-string-elt 3)
@@ -430,7 +436,8 @@ This will generate compile-time constants from BINDINGS."
nil t))
;; Emacs Lisp autoload cookies. Supports the slightly different
;; forms used by mh-e, calendar, etc.
- ("^;;;###\\([-a-z]*autoload\\)" 1 font-lock-warning-face prepend))
+ (,lisp-mode-autoload-regexp (3 font-lock-warning-face prepend)
+ (2 font-lock-function-name-face prepend)))
"Subdued level highlighting for Emacs Lisp mode.")
(defconst lisp-cl-font-lock-keywords-1
@@ -660,7 +667,9 @@ font-lock keywords will not be case sensitive."
(setq-local indent-line-function 'lisp-indent-line)
(setq-local indent-region-function 'lisp-indent-region)
(setq-local comment-indent-function #'lisp-comment-indent)
- (setq-local outline-regexp ";;;\\(;* [^ \t\n]\\|###autoload\\)\\|(")
+ (setq-local outline-regexp (concat ";;;;* [^ \t\n]\\|(\\|\\("
+ lisp-mode-autoload-regexp
+ "\\)"))
(setq-local outline-level 'lisp-outline-level)
(setq-local add-log-current-defun-function #'lisp-current-defun-name)
(setq-local comment-start ";")
@@ -700,7 +709,8 @@ font-lock keywords will not be case sensitive."
;; Expects outline-regexp is ";;;\\(;* [^ \t\n]\\|###autoload\\)\\|("
;; and point is at the beginning of a matching line.
(let ((len (- (match-end 0) (match-beginning 0))))
- (cond ((looking-at "(\\|;;;###autoload")
+ (cond ((or (looking-at-p "(")
+ (looking-at-p lisp-mode-autoload-regexp))
1000)
((looking-at ";;\\(;+\\) ")
(- (match-end 1) (match-beginning 1)))
diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el
index 3bbf793e1c..bbf5b8c431 100644
--- a/lisp/emacs-lisp/loaddefs-gen.el
+++ b/lisp/emacs-lisp/loaddefs-gen.el
@@ -44,9 +44,6 @@
(require 'autoload)
-(defconst loaddefs-gen--autoload-regexp
- "^;;;###\\([-a-z0-9A-Z]+\\)?autoload")
-
(defun loaddefs-gen--parse-file (file main-outfile &optional package-only)
"Examing FILE for ;;;###autoload statements.
MAIN-OUTFILE is the main loaddefs file these statements are
@@ -98,9 +95,9 @@ If PACKAGE-ONLY, only return the package info."
(not package-only))
(goto-char (point-min))
;; The cookie might be like ;;;###tramp-autoload...
- (while (re-search-forward loaddefs-gen--autoload-regexp nil t)
+ (while (re-search-forward lisp-mode-autoload-regexp nil t)
;; ... and if we have one of these names, then alter outfile.
- (let* ((aname (match-string 1))
+ (let* ((aname (match-string 2))
(to-file (if aname
(expand-file-name
(concat aname "loaddefs.el")
@@ -189,7 +186,8 @@ If PACKAGE-ONLY, only return the package info."
(goto-char (point-min))
(when (memq (car autoload)
'( defun autoload defvar defconst
- defvar-local defsubst defcustom defmacro))
+ defvar-local defsubst defcustom defmacro
+ cl-defsubst))
(forward-char 1)
(ignore-errors
(forward-sexp 3)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- scratch/faster-loaddefs cae1261f88: Use a shared regexp for autoload cookies,
Lars Ingebrigtsen <=