From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Texinfo Mode: node-based movement functions. Date: Sat, 6 Nov 2004 12:40:21 +0000 (GMT) Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: sea.gmane.org 1099744710 24427 80.91.229.6 (6 Nov 2004 12:38:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 6 Nov 2004 12:38:30 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 06 13:38:17 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CQPpg-0005fn-00 for ; Sat, 06 Nov 2004 13:38:17 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CQPxv-0007re-QU for ged-emacs-devel@m.gmane.org; Sat, 06 Nov 2004 07:46:47 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CQPxd-0007q3-AB for emacs-devel@gnu.org; Sat, 06 Nov 2004 07:46:29 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CQPxb-0007oq-Iz for emacs-devel@gnu.org; Sat, 06 Nov 2004 07:46:27 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CQPxb-0007ol-GC for emacs-devel@gnu.org; Sat, 06 Nov 2004 07:46:27 -0500 Original-Received: from [193.149.49.134] (helo=acm.acm) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CQPpE-0007OR-OO for emacs-devel@gnu.org; Sat, 06 Nov 2004 07:37:49 -0500 Original-Received: from localhost (root@localhost) by acm.acm (8.8.8/8.8.8) with SMTP id MAA00349 for ; Sat, 6 Nov 2004 12:40:23 GMT X-Sender: root@acm.acm Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:29476 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:29476 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)