changeset 414:0863123199f0 dev

Treat () and Zenkaku-paren chars as non-parens in YaTeX-on-section-command-p
author HIROSE Yuuji <yuuji@koeki-u.ac.jp>
date Wed, 08 Jul 2015 13:30:56 +0900
parents 368a86a179ff
children f0b90aee0390
files yatex.el
diffstat 1 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/yatex.el	Wed Jul 08 09:16:35 2015 +0900
+++ b/yatex.el	Wed Jul 08 13:30:56 2015 +0900
@@ -1,6 +1,6 @@
 ;;; yatex.el --- Yet Another tex-mode for emacs //野鳥// -*- coding: sjis -*-
 ;;; (c)1991-2015 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Fri Feb 13 20:40:56 2015 on firestorm
+;;; Last modified Wed Jul  8 13:29:03 2015 on duke
 ;;; $Id$
 ;;; The latest version of this software is always available at;
 ;;; http://www.yatex.org/
@@ -612,6 +612,18 @@
   (modify-syntax-entry ?\\ "/" YaTeX-mode-syntax-table)
   (modify-syntax-entry ?~ " " YaTeX-mode-syntax-table))
 
+(defvar YaTeX-mode-syntax-table-nonparen nil
+  "Syntax table for yatex-mode with normal parentheses treated white spaces")
+(if YaTeX-mode-syntax-table-nonparen nil
+  (setq YaTeX-mode-syntax-table-nonparen
+	(make-syntax-table YaTeX-mode-syntax-table))
+  (let ((zenparens "()()「」『』【】《》") (i 0) s)
+    (while (string-match "." zenparens i)
+      (setq s (substring zenparens (match-beginning 0) (match-end 0))
+	    i (1+ i))
+      (modify-syntax-entry
+       (string-to-char s) " " YaTeX-mode-syntax-table-nonparen))))
+
 ;---------- Provide YaTeX-mode ----------
 ;;;
 ;; Major mode definition
@@ -2064,10 +2076,14 @@
 	       (goto-char (match-beginning 0))
 	       (throw 'found t))
 	  ;;If inside of parentheses, try to escape.
-	  (while (and (not (= (preceding-char) ?\])) ;skip optional arg
-		      (condition-case err
-			  (progn (up-list -1) t)
-			(error nil))))
+	  (unwind-protect
+	      (progn
+		(set-syntax-table YaTeX-mode-syntax-table-nonparen)
+		(while (and (not (= (preceding-char) ?\])) ;skip optional arg
+			    (condition-case err
+				(progn (up-list -1) t)
+			      (error nil)))))
+	    (set-syntax-table YaTeX-mode-syntax-table))
 	  (while (equal (preceding-char) ?\]) (backward-list))
 	  ;;(2) search command directly
 	  (skip-chars-forward "^{}[]")

yatex.org