From: Lars Ingebrigtsen <larsi@gnus.org>
To: Stefan Kangas <stefan@marxist.se>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: master 388a874 2/4: Do interactive mode tagging for man.el
Date: Mon, 22 Feb 2021 23:34:21 +0100 [thread overview]
Message-ID: <875z2jenpu.fsf@gnus.org> (raw)
In-Reply-To: <CADwFkmmRRvhbL1yFFx-tEcZ808sbpVJFqmDjEoDmbfrhVcHPrg@mail.gmail.com> (Stefan Kangas's message of "Sun, 21 Feb 2021 04:37:45 -0600")
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
prev parent reply other threads:[~2021-02-22 22:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-19 15:56 master 388a874 2/4: Do interactive mode tagging for man.el Eli Zaretskii
2021-02-20 2:24 ` Stefan Kangas
2021-02-20 7:39 ` Eli Zaretskii
2021-02-20 12:26 ` Lars Ingebrigtsen
2021-02-20 12:56 ` Eli Zaretskii
2021-02-20 12:23 ` Lars Ingebrigtsen
2021-02-21 10:37 ` Stefan Kangas
2021-02-21 15:48 ` Lars Ingebrigtsen
2021-02-21 19:18 ` Stefan Kangas
2021-02-21 17:43 ` Eli Zaretskii
2021-02-21 19:03 ` Stefan Kangas
2021-02-22 22:34 ` Lars Ingebrigtsen [this message]
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=875z2jenpu.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=stefan@marxist.se \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).