[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 388a874 2/4: Do interactive mode tagging for man.el
From: |
Lars Ingebrigtsen |
Subject: |
Re: master 388a874 2/4: Do interactive mode tagging for man.el |
Date: |
Mon, 22 Feb 2021 23:34:21 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
I've further tweaked my interactive tagging helper command to do
grepping to give a bit of information about whether the command in
question is used in other places in Emacs (like in the wo/man case) and
tested it in a couple of small files. Seems to work OK, but can
probably do with some tweaking to reduce false positives.
(global-set-key [(hyper l)] 'my-fix-command)
(defvar my-prev-mode nil)
(defun my-fix-command ()
(interactive)
(let ((mode nil)
(regexp "(define-derived-mode \\([^ \t\n]+\\)\\|(defun \\([^
\t\n]+-mode\\) ")
change bindings)
(if (not (re-search-forward "^ *\\((interactive\\)" nil t))
(message "No more interactive in this file")
(recenter nil t)
(save-match-data
(save-excursion
(beginning-of-defun)
(let ((form (read (current-buffer))))
(when (and (listp form)
(eq (car form) 'defun))
(setq bindings
(shell-command-to-string
(format
"cd %s../lisp; grep -r --include '*.el'
\"define-key.*'%s\""
data-directory (cadr form)))))))
(save-excursion
(when (or (re-search-backward regexp nil t)
(re-search-forward regexp nil t))
(setq mode (or (match-string 1) (match-string 2)))))
(setq change (read-string (format "%sChange to: "
(or bindings ""))
(or mode my-prev-mode))))
(when (plusp (length change))
(setq mode change)
(goto-char (match-beginning 1))
(let ((form (read (current-buffer))))
(goto-char (match-beginning 1))
(forward-char 1)
(if (> (length form) 1)
(progn
(forward-sexp 2)
(insert " " mode))
(forward-sexp 1)
(insert " nil " mode))
(forward-sexp -1))
(setq my-prev-mode mode)))))
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- Re: master 388a874 2/4: Do interactive mode tagging for man.el, (continued)
- Re: master 388a874 2/4: Do interactive mode tagging for man.el,
Lars Ingebrigtsen <=