From: Alan Mackenzie <acm@muc.de>
Subject: Texinfo Mode: node-based movement functions.
Date: Sat, 6 Nov 2004 12:40:21 +0000 (GMT) [thread overview]
Message-ID: <Pine.LNX.3.96.1041106122151.342A-100000@acm.acm> (raw)
Hi, Emacs!
In Texinfo Mode we have functions for moving to the beginning and end of
a "page" (i.e. a @chapter) and for narrowing to a @chapter (together with
its @sections).
I think there should also be functions for moving to the beginning and
end of an individual @node, and for narrowing to it. "Obviously", a
@node in a file.texi is analogous to a defun in a file.el. So the
natural key bindings are C-M-a, C-M-e, and C-x n d.
The following code is a first shot at implementing this functionality.
It is currently not bullet proof - in particular, it doesn't take account
of @ignore commands. That would not, however, be hard to remedy.
Should I develop this into a production quality patch, complete with an
amendment to texinfo.txi, ChangeLog entry, etc.?
########################################################################
(defconst acm-texinfo-node-start "^@node .")
(defun acm-texinfo-beginning-of-node (&optional count)
"Move backward to the beginning of a node.
With COUNT, do it that many times. A negative COUNT will move forward.
A node starts at the \"@node\" command."
(interactive "p")
(if (< count 0)
(acm-texinfo-end-of-node (- count))
(unless (bolp) (end-of-line)) ; in case we're already inside "@node"
(search-backward-regexp acm-texinfo-node-start nil 'limit count)))
(defun acm-texinfo-end-of-node (&optional count)
"Move forward to the end of the current node.
With COUNT, do it that many times. A negative COUNT will move backwards.
The end of a node is the \"@node\" which begins the next node or EOF."
(interactive "p")
(if (< count 0)
(acm-texinfo-beginning-of-node (- count))
(end-of-line) ; to make sure we move.
(search-forward-regexp acm-texinfo-node-start nil 'limit count)
(beginning-of-line)))
(defun acm-texinfo-narrow-to-node ()
"Make the text outside the current node invisible.
This node is the one that contains point or follows point."
(interactive)
(widen)
(save-excursion
(let ((start
(progn
(unless (looking-at acm-texinfo-node-start)
(end-of-line)
(search-backward-regexp acm-texinfo-node-start nil 'limit))
(point))))
(end-of-line)
(search-forward-regexp acm-texinfo-node-start nil 'limit)
(beginning-of-line)
(narrow-to-region start (point)))))
(eval-after-load "texinfo"
'(progn
(define-key texinfo-mode-map "\C-\M-a" 'acm-texinfo-beginning-of-node)
(define-key texinfo-mode-map "\C-\M-e" 'acm-texinfo-end-of-node)
(define-key texinfo-mode-map "\C-xnd" 'acm-texinfo-narrow-to-node)))
#########################################################################
--
Alan Mackenzie (Munich, Germany)
next reply other threads:[~2004-11-06 12:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-06 12:40 Alan Mackenzie [this message]
2004-11-06 15:04 ` Texinfo Mode: node-based movement functions Alan Mackenzie
2004-11-06 21:52 ` Robert J. Chassell
2004-11-07 13:55 ` Alan Mackenzie
2004-11-07 23:52 ` Robert J. Chassell
2004-11-07 3:37 ` Richard Stallman
2004-11-08 14:47 ` Stefan
2004-11-08 20:09 ` Alan Mackenzie
2004-11-08 22:40 ` Stefan Monnier
2004-11-09 11:14 ` Richard Stallman
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=Pine.LNX.3.96.1041106122151.342A-100000@acm.acm \
--to=acm@muc.de \
/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).