Newsgroups: fj.sources,fj.editor.emacs
Path: galaxy.trc.rwcp.or.jp!jaist-news!nao
From: nao@jaist-east.ac.jp (HAMADA Naoki)
Subject: [fixed] unofficial patch for cmutex (CMU process modes 2.03)
In-Reply-To: nao@jaist-east.ac.jp's message of Mon, 15 Feb 1993 06:37:23 GMT
Message-ID: <NAO.93Feb16153025@mimo.jaist-east.ac.jp>
Followup-To: fj.editor.emacs
Lines: 178
Sender: news@jaist-east.ac.jp (News System Administrator)
Supersedes: <NAO.93Feb15153828@mimo.jaist-east.ac.jp>
Reply-To: nao@jaist-east.ac.jp
Organization: ME
Date: Tue, 16 Feb 1993 06:29:14 GMT
Xref: galaxy.trc.rwcp.or.jp fj.sources:2899 fj.editor.emacs:3496
X-originally-archived-at: http://galaxy.rwcp.or.jp/text/cgi-bin/newsarticle2?ng=fj.editor.emacs&nb=3496&hd=a
X-reformat-date: Mon, 18 Oct 2004 15:18:22 +0900
X-reformat-comment: Tabs were expanded into 4 column tabstops by the Galaxy's archiver. See http://katsu.watanabe.name/ancientfj/galaxy-format.html for more info.

cmutex $B$K(B next-error $B$HF1MM$N5!G=$rDI2C$9$k%Q%C%A$G$9!#:rF|$NEj9F$O!"(B
$B8m$C$F4V0c$C$?%P!<%8%g%s$rN.$7$F$7$^$$$^$7$?$N$G!"D{@5$7$F$"$j$^$9!#Bg(B
$BJQ<:Ni$$$?$7$^$7$?!#$4;XE&$r$/$@$5$C$?$+$?$,$?$K46<U$7$^$9!#(B

  C-c C-n $B$K%P%$%s%I$5$l$?(B tex-next-error $B$r<B9T$9$k$H!"(Bcmutex $B$K$h$k(B 
TeX $B$N<B9T7k2L$r2r@O$7$F%(%i!<$NH/@8$7$?%U%!%$%k!&9T$r<!!9$KC5$7!"%+!<(B
$B%=%k$r0\F0$7$^$9!#!J(BTeX $B$NJs9p$9$k%(%i!<9T$O$+$J$i$:$7$b%(%i!<$N860x$N(B
$B$"$k9T$H$O$+$.$j$^$;$s$N$GCm0U$7$F$/$@$5$$!K(B C-u C-c C-n $B$N$h$&$K0z?t(B
$B$r$D$1$F<B9T$9$k$H!"<B9T7k2L$r:G=i$+$i2r@O$7D>$7$^$9!#(B

  $B$3$N%Q%C%A$rMxMQ$9$k$K$O!"(Bcmutex.el $B$NB8:_$9$k%G%#%l%/%H%j$K0\F0$7!"(B

 patch < $B$3$N%U%!%$%k(B

$B$r<B9T$7$?8e!"(Bcmutex.el $B$r%P%$%H%3%s%Q%$%k$7D>$7$F$/$@$5$$!#(B

  $B%Q%C%AItJ,$NCx:n8"$O:n<T$N$o$?$7$K$"$j$^$9$,!"MxMQ$K$O0l@Z@)8B$r@_$1(B
$B$^$;$s!#2~NI$r9T$J$C$?>l9g$K$O!"$=$NFbMF$rCN$i$;$F$$$?$@$1$k$H4r$7$/;W(B
$B$$$^$9!#(B

  $B$J$*!"(Bcmutex $B$NF0:n$rJQ99$7$?$N$O<!$N#2E@$G$9!#(B
$B!{(B "save buffer ??? first?" $B$H$$$A$$$AJ9$$$F$3$J$$$h$&$K$7$?!#(B
$B!{(B TeX $B$r<B9T$9$k$?$S$K(B *tex-shell* $B$NFbMF$r>C5n$9$k$h$&$K$7$?!#(B
$B>e$N$[$&$NJQ99$O!"(Btex-next-error $B$N<BAu$K$O4X78$"$j$^$;$s!#(B

  $B$*3Z$7$_$/$@$5$$$^$7!#(B

$BIMED(B $BD><y(B
nao@jaist-east.ac.jp

*** cmutex.el.origFri May  1 12:06:59 1992
--- cmutex.elMon Feb 15 14:50:13 1993
***************
*** 153,158 ****
--- 153,165 ----
  ;;   users happy. This whole line-beginning-with-\-is-a paragraph-break
  ;;   stuff is pretty suspect, anyway, if you ask me.
  
+ ;; Nao <nao@jaist-east.ac.jp> 4/92
+ ;; - Function tex-next-error is implimented and its corresponding
+ ;;   changes (changing key maps, etc.) are made.
+ ;;
+ ;; Nao 3/93
+ ;; - Bugs in in-error-message-p are fixed.
+ ;;   Network release (hime version)
  
  ;; This file is part of GNU Emacs.
  ;; GNU Emacs is distributed in the hope that it will be useful,
***************
*** 281,286 ****
--- 288,294 ----
    (define-key tex-mode-map "\C-c\C-r" 'tex-region)
    (define-key tex-mode-map "\C-c\C-b" 'tex-buffer)
    (define-key tex-mode-map "\C-cb"    'bibtex-buffer)
+   (define-key tex-mode-map "\C-c\C-n"  'tex-next-error)
    )
  
  ;;; Shuffled keybindings so that
***************
*** 340,345 ****
--- 348,354 ----
    (define-key latex-mode-map "\C-cV" 'latex-verbatim)
    (define-key latex-mode-map "\C-c " 'latex-close-block) ;easy to type
    (define-key latex-mode-map "\C-c$" 'latex-mathmode)
+   (define-key latex-mode-map "\C-c\C-n" 'tex-next-error)
    )
  
  (defvar tex-shell-map nil
***************
*** 1073,1079 ****
      ;; Offer to save buffer if a modified file buffer.
      (if (and fname
       (buffer-modified-p)
!      (y-or-n-p (format "Save buffer %s first? " (buffer-name))))
  (save-buffer))
      (if (and fname (not (buffer-modified-p)))
  ;; If unmodified file buffer, then tex it directly.
--- 1082,1089 ----
      ;; Offer to save buffer if a modified file buffer.
      (if (and fname
       (buffer-modified-p)
! ;     (y-or-n-p (format "Save buffer %s first? " (buffer-name)))
!      )
  (save-buffer))
      (if (and fname (not (buffer-modified-p)))
  ;; If unmodified file buffer, then tex it directly.
***************
*** 1092,1098 ****
      (tex-recenter-output-buffer 0)
      (save-excursion
        (set-buffer buf)
!       (goto-char (point-max))
        (insert (format "\n--- Running process: %s %s\n--- working directory %s\n"
        command fname dir)))
      (if (and old-proc (memq (process-status old-proc) '(run stop)))
--- 1102,1110 ----
      (tex-recenter-output-buffer 0)
      (save-excursion
        (set-buffer buf)
! ;      (goto-char (point-max))
!       (delete-region (point-min) (point-max))
!       (setq error-point nil)
        (insert (format "\n--- Running process: %s %s\n--- working directory %s\n"
        command fname dir)))
      (if (and old-proc (memq (process-status old-proc) '(run stop)))
***************
*** 1212,1217 ****
--- 1224,1293 ----
  (run-hooks 'cmutex-load-hook)
  
  
+ (defvar error-point nil 
+   "The point where the next search begins. If it is nil, 
+ there is no search yet.")
+ 
+ (defun tex-next-error (&optional argp)
+   "Visit the next error message in *tex-shell* buffer
+ and move to corresponding tex code in the current buffer.
+ A non-nil argument (prefix arg, if interactive)
+ means searching as there was no search yet."
+   (interactive "P")
+   (let ((output-buffer (get-buffer "*tex-shell*"))
+ (input-file-name)
+ (input-file-buffer)
+ (error-line))
+     (if (null output-buffer) (error "TeX process has not run."))
+     (set-buffer output-buffer)
+     (if (or argp (null error-point)) (goto-char (point-min))
+       (goto-char error-point))
+     (if (null (re-search-forward 
+        "^\\(LaTeX error\\|AmS-TeX error\\|^! \\)" nil t nil))
+ (error "No more errors."))
+     (set-window-start (display-buffer output-buffer) (match-beginning 1))
+     (if (null (re-search-forward "^l\\.\\([0-9]*\\)" nil t nil))
+ (error "Error position not specified."))
+     (setq error-line
+   (string-to-int (buffer-substring 
+   (match-beginning 1) (match-end 1))))
+     (forward-line 1)
+     (setq error-point (point))
+     (find-file (find-file-name))
+     (goto-line error-line)))
+ 
+ (defun find-file-name ()
+   "TeX prints the name of the file it reads in parentheses. This function 
+ searches for the name of the file the error has been detected in."
+   (save-excursion
+     (let ((parenthesis-level 1)
+   (file-name-begin))
+       (while (> parenthesis-level 0)
+ (while (progn
+  (if (null (re-search-backward "\(\\|\)" nil t nil))
+      (error "Can't specify file name."))
+  (in-error-message-p)))
+ (setq parenthesis-level
+       (if (string= (buffer-substring (point) (1+ (point))) "\)")
+   (1+ parenthesis-level)
+ (1- parenthesis-level))))
+       (goto-char (1+ (point)))
+       (setq file-name-begin (point))
+       (if (null (re-search-forward "\(\\|\C-j\\| " nil t nil))
+   (error "Can't specify file name."))
+       (buffer-substring file-name-begin (1- (point))))))
+ 
+ (defun in-error-message-p ()
+   "TeX may print parentheses which has no relation to the file it reads
+ in its error messages. This function checks whether the current point 
+ is inside TeX's error message or not."
+   (save-excursion
+     (setq here (point))
+     (and (re-search-backward "^! " nil t nil)
+  (if (null (re-search-forward "^l." nil t nil))
+      (error "Error message lacks line number.")
+      (beginning-of-line 3)
+      (< here (point))))))
  
  ;;;Notes on validation
  ;;;============================================================================
