From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.emacs.devel Subject: Re: makeinfo-info.el - use Info-mode with makeinfo-buffer Date: Sat, 30 Nov 2002 09:21:45 +1000 Sender: emacs-devel-admin@gnu.org Message-ID: <87isygq7w6.fsf@zip.com.au> References: <87adka7747.fsf@zip.com.au> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1038612112 1434 80.91.224.249 (29 Nov 2002 23:21:52 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 29 Nov 2002 23:21:52 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18HuSE-0000Mt-00 for ; Sat, 30 Nov 2002 00:21:50 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18HuZz-0003sY-00 for ; Sat, 30 Nov 2002 00:29:51 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 18HuTk-0004IB-00; Fri, 29 Nov 2002 18:23:25 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 18HuSu-0003cS-00 for emacs-devel@gnu.org; Fri, 29 Nov 2002 18:22:32 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 18HuSs-0003cC-00 for emacs-devel@gnu.org; Fri, 29 Nov 2002 18:22:31 -0500 Original-Received: from sunny.pacific.net.au ([203.25.148.40]) by monty-python.gnu.org with esmtp (Exim 4.10) id 18HuSq-0003bm-00 for emacs-devel@gnu.org; Fri, 29 Nov 2002 18:22:29 -0500 Original-Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id gATNMQp4022129 for ; Sat, 30 Nov 2002 10:22:26 +1100 (EST) Original-Received: from localhost (ppp121.dyn228.pacific.net.au [203.143.228.121]) by wisma.pacific.net.au with ESMTP id KAA23616 for ; Sat, 30 Nov 2002 10:22:23 +1100 (EST) Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 18HuSA-0001ux-00; Sat, 30 Nov 2002 09:21:46 +1000 Original-To: emacs-devel@gnu.org User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.1 (i386-debian-linux-gnu) Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:9753 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:9753 --=-=-= For those who came in late, this started on gnu-emacs-sources looking to get makeinfo-buffer use Info-mode to show its foo.info output, as opposed to the current raw buffer (which in particular is not good when using the default file splitting, since foo.info is merely a tags table in that case.) Richard Stallman writes: > > This seems to be a combination of changes to existing files > and new functions. Could you send diff -c output showing the > changes to the existing files? 2002-11-29 Kevin Ryde * textmodes/makeinfo.el (makeinfo-buffer): Display result using Info-mode. (makeinfo-compilation-sentinel-buffer, makeinfo-current-node): New functions. (makeinfo-compile): Add a sentinel parameter. (makeinfo-compilation-sentinel-region): Renamed from makeinfo-compilation-sentinel, and makeinfo-temp-file now never nil. (makeinfo-region): Use this. * info.el (Info-revert-find-node): New function. Reindenting has bloated the makeinfo-compilation-sentinel-region diff, the only change, as stated, is no need to check for makeinfo-temp-file being nil. --=-=-= Content-Disposition: attachment; filename=info.el.diff *** info.el.~1.324.~ Wed Nov 20 08:24:39 2002 --- info.el Sat Nov 30 09:09:47 2002 *************** *** 535,540 **** --- 535,574 ---- (set (make-local-variable 'Info-current-file) t) (Info-find-node-2 nil nodename)) + ;; It's perhaps a bit nasty to kill the *info* buffer to force a re-read, + ;; but at least it keeps this routine (which is only for the benefit of + ;; makeinfo-buffer) out of the way of normal operations. + ;; + (defun Info-revert-find-node (filename nodename) + "Go to an info node FILENAME and NODENAME, re-reading disk contents. + When *info* is already displaying FILENAME and NODENAME, the window position + is preserved, if possible." + (pop-to-buffer "*info*") + (let ((old-filename Info-current-file) + (old-nodename Info-current-node) + (pcolumn (current-column)) + (pline (count-lines (point-min) (line-beginning-position))) + (wline (count-lines (point-min) (window-start))) + (old-history Info-history) + (new-history (and Info-current-file + (list Info-current-file Info-current-node (point))))) + (kill-buffer (current-buffer)) + (Info-find-node filename nodename) + (setq Info-history old-history) + (if (and (equal old-filename Info-current-file) + (equal old-nodename Info-current-node)) + (progn + ;; note goto-line is no good, we want to measure from point-min + (beginning-of-buffer) + (forward-line wline) + (set-window-start (selected-window) (point)) + (beginning-of-buffer) + (forward-line pline) + (move-to-column pcolumn)) + ;; only add to the history when coming from a different file+node + (if new-history + (setq Info-history (cons new-history Info-history)))))) + (defun Info-find-in-tag-table-1 (marker regexp case-fold) "Find a node in a tag table. MARKER specifies the buffer and position to start searching at. --=-=-= Content-Disposition: attachment; filename=makeinfo.el.diff *** makeinfo.el.~1.13.~ Mon Jan 28 09:59:48 2002 --- makeinfo.el Sat Nov 30 09:14:51 2002 *************** *** 1,6 **** ;;; makeinfo.el --- run makeinfo conveniently ! ;; Copyright (C) 1991, 1993 Free Software Foundation, Inc. ;; Author: Robert J. Chassell ;; Maintainer: FSF --- 1,6 ---- ;;; makeinfo.el --- run makeinfo conveniently ! ;; Copyright (C) 1991, 1993, 2002 Free Software Foundation, Inc. ;; Author: Robert J. Chassell ;; Maintainer: FSF *************** *** 47,52 **** --- 47,53 ---- ;;; Variables used by `makeinfo' (require 'compile) + (require 'info) (defgroup makeinfo nil "Run makeinfo conveniently" *************** (defvar makeinfo-temp-file nil *** 78,83 **** --- 79,87 ---- (defvar makeinfo-output-file-name nil "Info file name used for text output by `makeinfo'.") + (defvar makeinfo-output-node-name nil + "Node name to visit in output file, for `makeinfo-buffer'.") + ;;; The `makeinfo' function definitions *************** (defun makeinfo-region (region-beginning *** 167,178 **** " " makeinfo-temp-file) "Use `makeinfo-buffer' to gain use of the `next-error' command" ! nil))))))) ;;; Actually run makeinfo. COMMAND is the command to run. ;;; ERROR-MESSAGE is what to say when next-error can't find another error. ;;; If PARSE-ERRORS is non-nil, do try to parse error messages. ! (defun makeinfo-compile (command error-message parse-errors) (let ((buffer (compile-internal command error-message nil (and (not parse-errors) --- 171,183 ---- " " makeinfo-temp-file) "Use `makeinfo-buffer' to gain use of the `next-error' command" ! nil ! 'makeinfo-compilation-sentinel-region))))))) ;;; Actually run makeinfo. COMMAND is the command to run. ;;; ERROR-MESSAGE is what to say when next-error can't find another error. ;;; If PARSE-ERRORS is non-nil, do try to parse error messages. ! (defun makeinfo-compile (command error-message parse-errors sentinel) (let ((buffer (compile-internal command error-message nil (and (not parse-errors) *************** (defun makeinfo-compile (command error-m *** 181,207 **** ;; ever find any errors. (lambda (&rest ignore) (setq compilation-error-list nil)))))) ! (set-process-sentinel (get-buffer-process buffer) ! 'makeinfo-compilation-sentinel))) ;; Delete makeinfo-temp-file after processing is finished, ;; and visit Info file. ;; This function is called when the compilation process changes state. ;; Based on `compilation-sentinel' in compile.el ! (defun makeinfo-compilation-sentinel (proc msg) (compilation-sentinel proc msg) ! (if (and makeinfo-temp-file (file-exists-p makeinfo-temp-file)) ! (delete-file makeinfo-temp-file)) ! ;; Always use the version on disk. ! (let ((buffer (get-file-buffer makeinfo-output-file-name))) ! (if buffer ! (with-current-buffer buffer ! (revert-buffer t t)) ! (setq buffer (find-file-noselect makeinfo-output-file-name))) ! (if (window-dedicated-p (selected-window)) ! (switch-to-buffer-other-window buffer) ! (switch-to-buffer buffer))) ! (goto-char (point-min))) (defun makeinfo-buffer () "Make Info file from current buffer. --- 186,221 ---- ;; ever find any errors. (lambda (&rest ignore) (setq compilation-error-list nil)))))) ! (set-process-sentinel (get-buffer-process buffer) sentinel))) ;; Delete makeinfo-temp-file after processing is finished, ;; and visit Info file. ;; This function is called when the compilation process changes state. ;; Based on `compilation-sentinel' in compile.el ! (defun makeinfo-compilation-sentinel-region (proc msg) ! "Sentinel for `makeinfo-compile' run from `makeinfo-region'." (compilation-sentinel proc msg) ! (when (memq (process-status proc) '(signal exit)) ! (if (file-exists-p makeinfo-temp-file) ! (delete-file makeinfo-temp-file)) ! ;; Always use the version on disk. ! (let ((buffer (get-file-buffer makeinfo-output-file-name))) ! (if buffer ! (with-current-buffer buffer ! (revert-buffer t t)) ! (setq buffer (find-file-noselect makeinfo-output-file-name))) ! (if (window-dedicated-p (selected-window)) ! (switch-to-buffer-other-window buffer) ! (switch-to-buffer buffer))) ! (goto-char (point-min)))) ! ! (defun makeinfo-current-node () ! "Return the name of the node containing point, in a texinfo file." ! (save-excursion ! (end-of-line) ; in case point is at the start of an @node line ! (if (re-search-backward "^@node\\s-+\\([^,\n]+\\)" (point-min) t) ! (match-string 1) ! "Top"))) (defun makeinfo-buffer () "Make Info file from current buffer. *************** (defun makeinfo-buffer () *** 225,240 **** "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" search-end t) (setq makeinfo-output-file-name ! (buffer-substring (match-beginning 1) (match-end 1))) (error "The texinfo file needs a line saying: @setfilename ")))) (save-excursion (makeinfo-compile (concat makeinfo-run-command " " makeinfo-options " " buffer-file-name) "No more errors." ! t))) (defun makeinfo-recenter-compilation-buffer (linenum) "Redisplay `*compilation*' buffer so most recent output can be seen. --- 239,265 ---- "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" search-end t) (setq makeinfo-output-file-name ! (expand-file-name ! (buffer-substring (match-beginning 1) (match-end 1)))) (error "The texinfo file needs a line saying: @setfilename ")))) + (setq makeinfo-output-node-name (makeinfo-current-node)) (save-excursion (makeinfo-compile (concat makeinfo-run-command " " makeinfo-options " " buffer-file-name) "No more errors." ! t ! 'makeinfo-compilation-sentinel-buffer))) ! ! (defun makeinfo-compilation-sentinel-buffer (proc msg) ! "Sentinel for `makeinfo-compile' run from `makeinfo-buffer'." ! (compilation-sentinel proc msg) ! (when (memq (process-status proc) '(signal exit)) ! (when (file-exists-p makeinfo-output-file-name) ! (Info-revert-find-node ! makeinfo-output-file-name makeinfo-output-node-name)))) (defun makeinfo-recenter-compilation-buffer (linenum) "Redisplay `*compilation*' buffer so most recent output can be seen. --=-=-=--