[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/etags-regen 46c1f2f 10/11: Solve (hopefully?) the local-variable
From: |
Dmitry Gutov |
Subject: |
scratch/etags-regen 46c1f2f 10/11: Solve (hopefully?) the local-variable-satefy issue |
Date: |
Sun, 3 Jan 2021 19:06:32 -0500 (EST) |
branch: scratch/etags-regen
commit 46c1f2f44738d7e56e1d8141747b7fbbd611f75d
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Solve (hopefully?) the local-variable-satefy issue
---
.dir-locals.el | 10 ++++-----
lisp/progmodes/etags-regen.el | 49 ++++++++++++++++++++++++++++++++++++++++---
2 files changed, 50 insertions(+), 9 deletions(-)
diff --git a/.dir-locals.el b/.dir-locals.el
index 785f6c3..4ce1f44 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -5,13 +5,11 @@
(sentence-end-double-space . t)
(fill-column . 70)
(bug-reference-url-format . "https://debbugs.gnu.org/%s")
- (etags-regen-program-options
+ (etags-regen-lang-regexp-alist
.
- ("--regex='{c}/[ ]*DEFVAR_[A-Z_ (]+\"\\([^\"]+\\)\"/\\1/'"
- "--regex='{c}/[ ]*DEFVAR_[A-Z_ (]+\"[^\"]+\",[
]\\([A-Za-z0-9_]+\\)/\\1/'"
- "--regex='{objc}/[ ]*DEFVAR_[A-Z_ (]+\"\\([^\"]+\\)\"/\\1/'"
- "--regex='{objc}/[ ]*DEFVAR_[A-Z_ (]+\"[^\"]+\",[
]\\([A-Za-z0-9_]+\\)/\\1/'")
- )))
+ ((("c" "objc") .
+ ("/[ \t]*DEFVAR_[A-Z_ \t(]+\"\\([^\"]+\\)\"/\\1/"
+ "/[ \t]*DEFVAR_[A-Z_ \t(]+\"[^\"]+\",[
\t]\\([A-Za-z0-9_]+\\)/\\1/"))))))
(c-mode . ((c-file-style . "GNU")
(c-noise-macro-names . ("INLINE" "ATTRIBUTE_NO_SANITIZE_UNDEFINED"
"UNINIT" "CALLBACK" "ALIGN_STACK"))
(electric-quote-comment . nil)
diff --git a/lisp/progmodes/etags-regen.el b/lisp/progmodes/etags-regen.el
index 9c0cb3c..fe183bf 100644
--- a/lisp/progmodes/etags-regen.el
+++ b/lisp/progmodes/etags-regen.el
@@ -45,9 +45,37 @@
(defcustom etags-regen-program-options nil
"List of additional options to pass to the etags program."
- ;; FIXME: How to implement the safety predicate?
:type '(repeat string))
+(defcustom etags-regen-lang-regexp-alist nil
+ "Mapping of languages to additional regexps for tags.
+
+Each language should be one of the recognized by etags, see
+'etags --help'. Each tag regexp should be a string in the format
+as documented for the '--regex' arguments, except for
+the (optional) language prefix."
+ :type '(repeat
+ (cons
+ :tag "Languages group"
+ (repeat (string :tag "Language name"))
+ (repeat (string :tag "Tag Regexp"))))
+ :safe 'etags-regen--safe-regexp-alist-p)
+
+(defun etags-regen--safe-regexp-alist-p (value)
+ (and (listp value)
+ (seq-every-p
+ (lambda (group)
+ (and (consp group)
+ (listp (car group))
+ (listp (cdr group))
+ (seq-every-p
+ (lambda (lang)
+ (and (stringp lang)
+ (string-match-p "\\`[a-z*+]+\\'" lang)))
+ (car group))
+ (seq-every-p #'stringp (cdr group))))
+ value)))
+
(defvar etags-regen--errors-buffer-name "*etags-regen-tags-errors*")
(defun etags-regen--maybe-generate ()
@@ -84,7 +112,7 @@
;; but better-maintained versions of it exist (like universal-ctags).
(command (format "%s %s -L - -o %s"
etags-regen-program
- (mapconcat #'identity etags-regen-program-options "
")
+ (mapconcat #'identity
(etags-regen--build-program-options) " ")
tags-file)))
(setq etags-regen--tags-file tags-file
etags-regen--tags-root root)
@@ -96,10 +124,25 @@
(shell-command-on-region (point-min) (point-max) command
nil nil etags-regen--errors-buffer-name t))))
+(defun etags-regen--build-program-options ()
+ (nconc
+ (mapcan
+ (lambda (group)
+ (mapcan
+ (lambda (lang)
+ (mapcar (lambda (regexp)
+ (concat "--regex="
+ (shell-quote-argument
+ (format "{%s}%s" lang regexp))))
+ (cdr group)))
+ (car group)))
+ etags-regen-lang-regexp-alist)
+ etags-regen-program-options))
+
(defun etags-regen--update-file ()
;; TODO: Maybe only do this when Emacs is idle for a bit.
(let ((file-name buffer-file-name)
- (options etags-regen-program-options)
+ (options (etags-regen--build-program-options))
(tags-file-buf (get-file-buffer etags-regen--tags-file))
pr should-scan)
(save-excursion
- scratch/etags-regen updated (94437f9 -> 5270872), Dmitry Gutov, 2021/01/03
- scratch/etags-regen 4d0886e 02/11: Move to a separate file and minor mode, Dmitry Gutov, 2021/01/03
- scratch/etags-regen d6285de 05/11: New defcustom: etags-regen-program-options, Dmitry Gutov, 2021/01/03
- scratch/etags-regen d9e3afe 04/11: Make etags-regen-program a user option, Dmitry Gutov, 2021/01/03
- scratch/etags-regen 798c90b 07/11: Support etags-regen-program-options in --update-file, Dmitry Gutov, 2021/01/03
- scratch/etags-regen 5270872 11/11: Undo the etags.el changes, Dmitry Gutov, 2021/01/03
- scratch/etags-regen aa4eddb 09/11: Ensure errors buffer name is more consistent, Dmitry Gutov, 2021/01/03
- scratch/etags-regen 8ce70eb 06/11: Use `silent' for appending, too, Dmitry Gutov, 2021/01/03
- scratch/etags-regen 46c1f2f 10/11: Solve (hopefully?) the local-variable-satefy issue,
Dmitry Gutov <=
- scratch/etags-regen ab5bf3c 01/11: Merge branch 'master' into scratch/etags-regen, Dmitry Gutov, 2021/01/03
- scratch/etags-regen 6f26f60 08/11: Bookkeeping, Dmitry Gutov, 2021/01/03
- scratch/etags-regen 570f132 03/11: etags.c: Implement the -L flag, Dmitry Gutov, 2021/01/03