yatex

changeset 165:b9f0c694f30e dev

Two fixes; [prefix] \ inserts \backslash or \textbackslash according to math-mode state. Replace some 'buffer-substring with 'YaTeX-buffer-substring.
author yuuji@gentei.org
date Mon, 14 Feb 2011 12:48:06 +0900
parents 59e47ed6b334
children 2f183a28d798
files yatex.el
diffstat 1 files changed, 26 insertions(+), 20 deletions(-) [+]
line diff
     1.1 --- a/yatex.el	Mon Feb 14 12:40:11 2011 +0900
     1.2 +++ b/yatex.el	Mon Feb 14 12:48:06 2011 +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 14:55:07 2010 on firestorm
     1.8 +;;; Last modified Mon Feb 14 12:45:22 2011 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 @@ -459,8 +459,9 @@
    1.13    (YaTeX-define-key ")" 'YaTeX-insert-parens-region)
    1.14    (YaTeX-define-key "$" 'YaTeX-insert-dollars-region)
    1.15    (YaTeX-define-key "i" 'YaTeX-fill-item)
    1.16 -  (YaTeX-define-key
    1.17 -   "\\" '(lambda () (interactive) (insert "$\\backslash$")))
    1.18 +  (YaTeX-define-key "\\"
    1.19 +   '(lambda () (interactive)
    1.20 +      (insert (if (YaTeX-in-math-mode-p) "\\backslash" "\\textbackslash"))))
    1.21    (if YaTeX-no-begend-shortcut
    1.22        (progn
    1.23  	(YaTeX-define-key "B" 'YaTeX-make-begin-end-region)
    1.24 @@ -982,9 +983,11 @@
    1.25  	 'section-table 'user-section-table 'tmp-section-table)
    1.26  	(if YaTeX-current-position-register
    1.27  	    (point-to-register YaTeX-current-position-register))
    1.28 -	(if (string= (buffer-substring (- (point) 2) (point)) "{}")
    1.29 -	  (forward-char -1))
    1.30 -	(while (string= (buffer-substring (- (point) 3) (1- (point))) "{}")
    1.31 +	(if (string= (YaTeX-buffer-substring (- (point) 2) (point))
    1.32 +		     "{}")
    1.33 +	    (forward-char -1))
    1.34 +	(while (string= (YaTeX-buffer-substring (- (point) 3) (1- (point)))
    1.35 +			"{}")
    1.36  	  (forward-char -2))
    1.37  	(YaTeX-package-auto-usepackage section 'section))
    1.38      (if (<= (minibuffer-depth) 0) (use-global-map global-map))
    1.39 @@ -1105,7 +1108,7 @@
    1.40         (t
    1.41  	(mapcar 'YaTeX-sync-local-table
    1.42  		'(tmp-section-table tmp-env-table tmp-singlecmd-table))
    1.43 -	(let*((pattern (buffer-substring begin end))
    1.44 +	(let*((pattern (YaTeX-buffer-substring begin end))
    1.45  	      (all-table
    1.46  	       (append
    1.47  		section-table user-section-table tmp-section-table
    1.48 @@ -1119,8 +1122,9 @@
    1.49  	      ;; Next,
    1.50  	      ;; search completion with backslash
    1.51  	      (setq completion
    1.52 -		    (try-completion (buffer-substring (1- begin) end)
    1.53 -				    all-table nil)
    1.54 +		    (try-completion
    1.55 +		     (YaTeX-buffer-substring (1- begin) end)
    1.56 +		     all-table nil)
    1.57  		    begin (1- begin)))
    1.58  	  (cond
    1.59  	   ((null completion)
    1.60 @@ -1496,7 +1500,8 @@
    1.61  			((= c ?l) "%#LPR")))
    1.62  	(if (re-search-forward key nil t)
    1.63  	    (progn
    1.64 -	      (setq string (buffer-substring (point) (point-end-of-line)))
    1.65 +	      (setq string (YaTeX-buffer-substring
    1.66 +			    (point) (point-end-of-line)))
    1.67  	      (delete-region (point) (progn (end-of-line) (point))))
    1.68  	  (open-line 1)
    1.69  	  (delete-region (point) (progn (beginning-of-line)(point)));for 19 :-<
    1.70 @@ -1565,7 +1570,7 @@
    1.71  		 "\\\\bibitem\\(\\[[^]]+\\]\\)?{%k}\\|^\\s *@[a-z]+{%k,")
    1.72  		("bibitem" . "\\\\cite\\(\\[[^]]+\\]\\)?")))))
    1.73        (goto-char (match-end 0))
    1.74 -      (let ((label (buffer-substring 
    1.75 +      (let ((label (YaTeX-buffer-substring 
    1.76  		    (1- (point)) (progn (backward-list 1) (1+ (point)))))
    1.77  	    (fp (make-marker))fl fn
    1.78  	    (goother (function (lambda (buffer point)
    1.79 @@ -1664,7 +1669,7 @@
    1.80  	    nil
    1.81  	  (skip-chars-backward "^,{"))
    1.82  	(setq input-file
    1.83 -	      (buffer-substring
    1.84 +	      (YaTeX-buffer-substring
    1.85  	       (point) (progn (skip-chars-forward "^ ,}") (point))))
    1.86  	(if (not (string-match "\\.\\(tex\\|sty\\)$" input-file))
    1.87  	    (setq input-file (concat input-file ".tex"))))
    1.88 @@ -2248,8 +2253,8 @@
    1.89    (if (not (YaTeX-on-begin-end-p)) nil
    1.90      (save-excursion
    1.91        (let (p env (m1 (match-beginning 1)) (m2 (match-beginning 2)))
    1.92 -	(setq env (if m1 (buffer-substring m1 (match-end 1))
    1.93 -		    (buffer-substring m2 (match-end 2))))
    1.94 +	(setq env (if m1 (YaTeX-buffer-substring m1 (match-end 1))
    1.95 +		    (YaTeX-buffer-substring m2 (match-end 2))))
    1.96  	(goto-char (match-beginning 0))
    1.97  	(set-mark-command nil)
    1.98  	(YaTeX-goto-corresponding-environment)
    1.99 @@ -2293,7 +2298,7 @@
   1.100  			(YaTeX-addin cmd)
   1.101  		      (concat "["
   1.102  			      (read-string (format "Change `%s' to: "
   1.103 -						   (buffer-substring
   1.104 +						   (YaTeX-buffer-substring
   1.105  						    (1+ beg) (1- end))))
   1.106  			      "]"))))
   1.107  
   1.108 @@ -2304,7 +2309,7 @@
   1.109  	      (forward-list 1)
   1.110  	      (forward-char -1)
   1.111  	      (set-marker end (point))
   1.112 -	      (setq old (buffer-substring beg end))
   1.113 +	      (setq old (YaTeX-buffer-substring beg end))
   1.114  	      (goto-char p)
   1.115  	      (if (> (length old) 40)
   1.116  		  (setq old (concat (substring old 0 12) "..."
   1.117 @@ -2431,7 +2436,8 @@
   1.118  	      nil
   1.119  	    (goto-char (match-end 2))
   1.120  	    (skip-chars-forward
   1.121 -	     (concat "^" (buffer-substring (match-beginning 2) (match-end 2))))
   1.122 +	     (concat "^" (YaTeX-buffer-substring
   1.123 +			  (match-beginning 2) (match-end 2))))
   1.124  	    (and (< (match-beginning 2) point) (< (1- point) (point))))
   1.125  	(store-match-data md)))))
   1.126  
   1.127 @@ -2590,7 +2596,7 @@
   1.128  	  (newline)
   1.129  	  (indent-to col)
   1.130  	  (setq fill-prefix
   1.131 -		(buffer-substring (point-beginning-of-line)(point)))
   1.132 +		(YaTeX-buffer-substring (point-beginning-of-line)(point)))
   1.133  	  (beginning-of-line)
   1.134  	  (delete-region (point) (progn (forward-line 1) (point)))
   1.135  	  (re-search-forward item-term nil 1)
   1.136 @@ -2636,7 +2642,7 @@
   1.137  			  (setq end (point))  ;non-whitespace char
   1.138  			  (skip-chars-forward " \t")
   1.139  			  (equal (point) p))
   1.140 -	  (setq fill-prefix (buffer-substring p end)))
   1.141 +	  (setq fill-prefix (YaTeX-buffer-substring p end)))
   1.142  	 ((and ;;(not YaTeX-emacs-19)
   1.143  	       (string-match YaTeX-itemizing-env-regexp inenv)
   1.144  	       (setq ii (YaTeX-get-item-info)))
   1.145 @@ -2644,7 +2650,7 @@
   1.146  	    (beginning-of-line)
   1.147  	    (indent-to-column (car (cdr ii)))
   1.148  	    (setq fill-prefix
   1.149 -		  (buffer-substring (point) (point-beginning-of-line)))
   1.150 +		  (YaTeX-buffer-substring (point) (point-beginning-of-line)))
   1.151  	    (delete-region (point) (progn (beginning-of-line) (point))))))
   1.152  	(cond
   1.153  	 ((string-match "tabular" inenv)