yatex

changeset 129:b11d6271207e dev

YaTeX-{quick-,}in-environment-p return cons of envname and the begpoint instead of t.
author yuuji@gentei.org
date Thu, 27 May 2010 13:49:44 +0900
parents d5e19b856ca1
children 8703f090c628
files yatex.el
diffstat 1 files changed, 17 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/yatex.el	Thu May 27 11:34:41 2010 +0900
     1.2 +++ b/yatex.el	Thu May 27 13:49:44 2010 +0900
     1.3 @@ -2,7 +2,7 @@
     1.4  ;;; Yet Another tex-mode for emacs - //–ì’¹//
     1.5  ;;; yatex.el rev. 1.74.3
     1.6  ;;; (c)1991-2010 by HIROSE Yuuji.[yuuji@yatex.org]
     1.7 -;;; Last modified Thu May 27 10:09:18 2010 on firestorm
     1.8 +;;; Last modified Thu May 27 13:45:10 2010 on firestorm
     1.9  ;;; $Id$
    1.10  ;;; The latest version of this software is always available at;
    1.11  ;;; http://www.yatex.org/
    1.12 @@ -2471,7 +2471,8 @@
    1.13  		    (if (match-beginning 2)
    1.14  			(setq nest (1+ nest))
    1.15  		      (setq nest (1- nest)))
    1.16 -		    (if (< nest 0) (throw 'open t)))))))
    1.17 +		    (if (< nest 0)
    1.18 +			(throw 'open (cons env (match-beginning 0)))))))))
    1.19       ((listp env)
    1.20        (setq p
    1.21  	    (or (YaTeX-in-environment-p (car env))
    1.22 @@ -2485,21 +2486,25 @@
    1.23  ENV is given in the form of environment's name or its list.
    1.24  This function returns correct result only if ENV is NOT nested."
    1.25    (save-excursion
    1.26 -    (let ((md (match-data)) (p (point)) rc clfound)
    1.27 +    (let ((md (match-data)) m0 (p (point)) rc clfound)
    1.28        (cond
    1.29         ((listp env)
    1.30  	(or (YaTeX-quick-in-environment-p (car env))
    1.31  	    (and (cdr env) (YaTeX-quick-in-environment-p (cdr env)))))
    1.32         (t
    1.33 -	(if (YaTeX-search-active-backward
    1.34 -	     (YaTeX-replace-format-args YaTeX-struct-begin env "" "")
    1.35 -	     YaTeX-comment-prefix nil t)
    1.36 -	    (setq rc (not (YaTeX-search-active-forward
    1.37 -			   (YaTeX-replace-format-args
    1.38 -			    YaTeX-struct-end env)
    1.39 -			   YaTeX-comment-prefix p t nil))))
    1.40 -	(store-match-data md)
    1.41 -	rc)))))
    1.42 +	(unwind-protect
    1.43 +	    (if (prog1
    1.44 +		    (YaTeX-search-active-backward
    1.45 +		     (YaTeX-replace-format-args YaTeX-struct-begin env "" "")
    1.46 +		     YaTeX-comment-prefix nil t)
    1.47 +		  (setq m0 (match-beginning 0)))
    1.48 +		(if (YaTeX-search-active-forward
    1.49 +		     (YaTeX-replace-format-args
    1.50 +		      YaTeX-struct-end env)
    1.51 +		     YaTeX-comment-prefix p t nil)
    1.52 +		    nil			;if \end{env} found, return nil
    1.53 +		  (cons env m0)))	;else, return meaningful values
    1.54 +	  (store-match-data md)))))))
    1.55  
    1.56  ;; Filling \item
    1.57  (defun YaTeX-remove-trailing-comment (start end)