unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kevin Ryde <user42@zip.com.au>
Subject: Re: makeinfo-info.el - use Info-mode with makeinfo-buffer
Date: Sat, 30 Nov 2002 09:21:45 +1000	[thread overview]
Message-ID: <87isygq7w6.fsf@zip.com.au> (raw)
In-Reply-To: E18Ddmd-0007x2-00@fencepost.gnu.org

[-- Attachment #1: Type: text/plain, Size: 1108 bytes --]

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 <rms@gnu.org> 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  <user42@zip.com.au>

	* 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.


[-- Attachment #2: info.el.diff --]
[-- Type: text/plain, Size: 1881 bytes --]

*** 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.

[-- Attachment #3: makeinfo.el.diff --]
[-- Type: text/plain, Size: 6694 bytes --]

*** 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'.")
+ 
  \f
  ;;; 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 <name>"))))
    
    (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 <name>"))))
+   (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.

       reply	other threads:[~2002-11-29 23:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87adka7747.fsf@zip.com.au>
     [not found] ` <E18Ddmd-0007x2-00@fencepost.gnu.org>
2002-11-29 23:21   ` Kevin Ryde [this message]
2002-11-30  6:35     ` makeinfo-info.el - use Info-mode with makeinfo-buffer Thien-Thi Nguyen
2002-12-02  5:56       ` Eli Zaretskii
2002-12-02  6:08         ` Miles Bader
2002-12-02  6:25           ` Eli Zaretskii
2002-12-02 20:54           ` Kevin Ryde
2002-12-03 14:58           ` Richard Stallman
2002-12-04  1:37             ` Miles Bader
2002-12-04  6:07               ` Eli Zaretskii
2002-12-04  6:35                 ` Miles Bader
2002-12-04 14:23                   ` Eli Zaretskii
2002-12-04 19:19               ` David Masterson
2002-12-04 20:00                 ` Miles Bader
2002-12-02 16:02         ` Stefan Monnier
2002-12-02 17:21           ` Eli Zaretskii

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=87isygq7w6.fsf@zip.com.au \
    --to=user42@zip.com.au \
    /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).