yatex

diff yatexenv.el @ 45:b0fc9c2950cd

Prepare for supporting Emacs-19.
author yuuji
date Sun, 24 Jul 1994 15:07:23 +0000
parents b00c74813e56
children cd1b63102eed
line diff
     1.1 --- a/yatexenv.el	Thu Jul 07 16:37:05 1994 +0000
     1.2 +++ b/yatexenv.el	Sun Jul 24 15:07:23 1994 +0000
     1.3 @@ -2,7 +2,7 @@
     1.4  ;;; YaTeX environment-specific functions.
     1.5  ;;; yatexenv.el
     1.6  ;;; (c ) 1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
     1.7 -;;; Last modified Fri Jul  8 00:48:40 1994 on figaro
     1.8 +;;; Last modified Mon Jul 11 02:01:18 1994 on 98fa
     1.9  ;;; $Id$
    1.10  
    1.11  ;;;
    1.12 @@ -76,6 +76,65 @@
    1.13     (t (message "Not in array/tabuar environment.")))
    1.14  )
    1.15  
    1.16 +(defun YaTeX-tabular-parse-format (&optional tabular*)
    1.17 +  "Parse `tabular' format.
    1.18 +Return the list of (No.ofCols PointEndofFormat)"
    1.19 +  (let ((p (point)) elt boform eoform (cols 0))
    1.20 +    (save-excursion
    1.21 +      (if (null (YaTeX-beginning-of-environment t))
    1.22 +	  (error "Beginning of tabular not found."))
    1.23 +      (skip-chars-forward "^{")
    1.24 +      (forward-list 1)
    1.25 +      (if tabular*
    1.26 +	  (progn (skip-chars-forward "^{")
    1.27 +		 (forward-list 1)))
    1.28 +      (skip-chars-forward "^{" p)
    1.29 +      (if (/= (following-char) ?\{) (error "Tabular format not found."))
    1.30 +      (setq boform (1+ (point))
    1.31 +	    eoform (progn (forward-list 1) (1- (point))))
    1.32 +      (if (> eoform p) (error "Non-terminated tabular format."))
    1.33 +      (goto-char boform)
    1.34 +      (while (< (point) eoform)
    1.35 +	(setq elt (following-char))
    1.36 +	(cond
    1.37 +	 ((string-match (char-to-string elt) "clr") ;normal indicators.
    1.38 +	  (setq cols (1+ cols))
    1.39 +	  (forward-char 1))
    1.40 +	 ((equal elt ?|)		;vertical
    1.41 +	  (forward-char 1))
    1.42 +	 ((string-match (char-to-string elt) "p@") ;p or @ expression
    1.43 +	  (setq cols (+ (if (eq elt ?p) 1 0) cols))
    1.44 +	  (skip-chars-forward "^{" p)
    1.45 +	  (forward-list 1))))
    1.46 +      (list cols (1+ eoform))))
    1.47 +)
    1.48 +;; Insert &
    1.49 +(defun YaTeX-intelligent-newline-tabular (&optional tabular*)
    1.50 +  "Parse current tabular format and insert that many `&'s."
    1.51 +  (let*((p (point)) (format (YaTeX-tabular-parse-format tabular*))
    1.52 +	(cols (car format)) (beg (car (cdr format)))
    1.53 +	space hline)
    1.54 +    (setq hline (search-backward "\\hline" beg t))
    1.55 +    (goto-char p)
    1.56 +    (setq space (if (search-backward "\t&" beg t) "\t" " "))
    1.57 +    (goto-char p)
    1.58 +    (YaTeX-indent-line)
    1.59 +    (setq p (point))
    1.60 +    (while (> (1- cols) 0)
    1.61 +      (insert "&" space)
    1.62 +      (setq cols (1- cols)))
    1.63 +    (insert "\\\\")
    1.64 +    (if hline (insert " \\hline"))
    1.65 +    (goto-char p))
    1.66 +)
    1.67 +
    1.68 +(defun YaTeX-intelligent-newline-tabular* ()
    1.69 +  "Parse current tabular* format and insert that many `&'s."
    1.70 +  (YaTeX-intelligent-newline-tabular t)
    1.71 +)
    1.72 +
    1.73 +(fset 'YaTeX-intelligent-newline-array 'YaTeX-intelligent-newline-tabular)
    1.74 +
    1.75  ;;;
    1.76  ;; Functions for tabbing environment
    1.77  ;;;