changeset 515:b6853d450b0a dev

Add a function to examine the point is in %#BEGIN/%#END or not.
author HIROSE Yuuji <yuuji@gentei.org>
date Thu, 04 Jan 2018 23:58:07 +0900
parents 8e0822416fc6
children 603acc1caec7
files yatexlib.el
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/yatexlib.el	Thu Jan 04 23:53:17 2018 +0900
+++ b/yatexlib.el	Thu Jan 04 23:58:07 2018 +0900
@@ -1,7 +1,7 @@
 ;;; yatexlib.el --- YaTeX and yahtml common libraries -*- coding: sjis -*-
 ;;; 
-;;; (c)1994-2017 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Tue Jan  2 17:50:03 2018 on firestorm
+;;; (c)1994-2018 by HIROSE Yuuji.[yuuji@yatex.org]
+;;; Last modified Thu Jan  4 13:58:20 2018 on firestorm
 ;;; $Id$
 
 ;;; Code:
@@ -1224,6 +1224,23 @@
 	;;(if (eobp) nil (forward-char 1))	;OUT 2015/1/5
 	))))
 
+(defun YaTeX-in-BEGEND-p ()
+  "Check if the point is in a %#BEGIN...%#END region.
+Return the list of beginning and ending point of the region and arg-string
+if the point is in BEGEND.  Otherwise nil."
+  (let ((b "%#BEGIN") bp args (e "%#END") (p (point)))
+    (save-excursion
+      (save-match-data			;emacs-19+ yatex1.80+
+	(and (re-search-backward b nil t)
+	     (progn
+	       (setq bp (match-beginning 0))
+	       (goto-char (match-end 0))	;Start to get args of %#BEGIN
+	       (skip-chars-forward " \t")
+	       (setq args (YaTeX-buffer-substring (point) (point-end-of-line))))
+	     (re-search-forward e nil t)
+	     (> (point) p)
+	     (list bp (match-end 0) args))))))
+
 (defun YaTeX-kill-buffer (buffer)
   "Make effort to show parent buffer after kill."
   (interactive "bKill buffer: ")