yatex

changeset 250:4f73b796ec20 dev

Fix intelligent-newline for alignat(*).
author yuuji@gentei.org
date Sat, 11 Feb 2012 12:08:55 +0900
parents c2aa2457a74b
children ceca2d094d6f
files yatexenv.el
diffstat 1 files changed, 23 insertions(+), 26 deletions(-) [+]
line diff
     1.1 --- a/yatexenv.el	Sat Feb 11 12:05:11 2012 +0900
     1.2 +++ b/yatexenv.el	Sat Feb 11 12:08:55 2012 +0900
     1.3 @@ -2,7 +2,7 @@
     1.4  ;;; YaTeX environment-specific functions.
     1.5  ;;; yatexenv.el
     1.6  ;;; (c) 1994-2006 by HIROSE Yuuji.[yuuji@yatex.org]
     1.7 -;;; Last modified Sun Jan 29 19:34:13 2012 on firestorm
     1.8 +;;; Last modified Sat Feb 11 10:35:22 2012 on firestorm
     1.9  ;;; $Id$
    1.10  
    1.11  ;;;
    1.12 @@ -134,12 +134,10 @@
    1.13  	     ((eq type 'alignat)
    1.14  	      (max
    1.15  	       1
    1.16 -	       (1-
    1.17 -		(* 2
    1.18 -		   (string-to-int
    1.19 -		    (buffer-substring
    1.20 -		     (point)
    1.21 -		     (progn (up-list -1) (forward-list 1) (1- (point)))))))))
    1.22 +	       (* 2 (string-to-int
    1.23 +		     (buffer-substring
    1.24 +		      (point)
    1.25 +		      (progn (up-list -1) (forward-list 1) (1- (point))))))))
    1.26  	     (t
    1.27  	      (YaTeX-tabular-parse-format-count-cols (point) eoform))))
    1.28        (list cols (1+ eoform)))))
    1.29 @@ -174,29 +172,28 @@
    1.30  (fset 'YaTeX-intelligent-newline-array 'YaTeX-intelligent-newline-tabular)
    1.31  (fset 'YaTeX-intelligent-newline-supertabular 'YaTeX-intelligent-newline-tabular)
    1.32  
    1.33 -(defun YaTeX-intelligent-newline-alignat ()
    1.34 -  (YaTeX-intelligent-newline-tabular 'alignat))
    1.35 -(fset 'YaTeX-intelligent-newline-alignat* 'YaTeX-intelligent-newline-alignat)
    1.36 -
    1.37  (defun YaTeX-intelligent-newline-align ()
    1.38    "Intelligent newline function for align.
    1.39  Count the number of & in the first align line and insert that many &s."
    1.40 -  (let*((p (point)) (cols 0))
    1.41 +  (let*((p (point)) (amps 0))
    1.42 +    (if (string-match "alignat" env)
    1.43 +	(setq amps (1- (car (YaTeX-tabular-parse-format 'alignat))))
    1.44 +      (save-excursion
    1.45 +	(YaTeX-beginning-of-environment)
    1.46 +	(catch 'done
    1.47 +	  (while (YaTeX-re-search-active-forward
    1.48 +		  "\\(&\\)\\|\\(\\\\\\\\\\)" YaTeX-comment-prefix p t)
    1.49 +	    (if (match-beginning 1) (setq amps (1+ amps)) (throw 'done t))))))
    1.50      (save-excursion
    1.51 -      (YaTeX-beginning-of-environment)
    1.52 -      (catch 'done
    1.53 -	(while (YaTeX-re-search-active-forward
    1.54 -		"\\(&\\)\\|\\(\\\\\\\\\\)" YaTeX-comment-prefix p t)
    1.55 -	  (if (match-beginning 1) (setq cols (1+ cols)) (throw 'done t)))))
    1.56 -    (if (> cols 0)
    1.57 -	(save-excursion
    1.58 -	  (forward-line -1)
    1.59 -	  (end-of-line)
    1.60 -	  (skip-chars-backward " \t")
    1.61 -	  (or (and (= (preceding-char) ?\\) (= (char-after (- (point) 2)) ?\\))
    1.62 -	      (insert "\\\\"))))
    1.63 +      (forward-line -1)
    1.64 +      (skip-chars-forward " \t")
    1.65 +      (or (prog1 (looking-at "\\\\begin{") (end-of-line))
    1.66 +	  (save-excursion
    1.67 +	    (skip-chars-backward " \t")
    1.68 +	    (and (= (preceding-char) ?\\) (= (char-after (- (point) 2)) ?\\)))
    1.69 +	  (insert "\\\\")))
    1.70      (save-excursion
    1.71 -      (while (>= (setq cols (1- cols)) 0)
    1.72 +      (while (>= (setq amps (1- amps)) 0)
    1.73  	(insert "& ")))
    1.74      (YaTeX-indent-line)))
    1.75  
    1.76 @@ -206,7 +203,7 @@
    1.77  			   (symbol-name s)))
    1.78  	  'YaTeX-intelligent-newline-align))
    1.79   '(align* flalign  flalign* matrix pmatrix bmatrix Bmatrix vmatrix Vmatrix
    1.80 -   cases eqnarray eqnarray*))
    1.81 +   cases eqnarray eqnarray* alignat alignat*))
    1.82  
    1.83  ;;;
    1.84  ;; Functions for tabbing environment