comparison yatexenv.el @ 359:dbef6cf84f98 dev

Two or more consecutive [Tab] in column of table jump to the next column.
author HIROSE Yuuji <yuuji@gentei.org>
date Mon, 22 Dec 2014 22:33:02 +0900
parents 2a72779d9c50
children d69fd7b1ac4d
comparison
equal deleted inserted replaced
358:2c2b70f41fb3 359:dbef6cf84f98
1 ;;; yatexenv.el --- YaTeX environment-specific functions 1 ;;; yatexenv.el --- YaTeX environment-specific functions
2 ;;; (c) 1994-2013 by HIROSE Yuuji.[yuuji@yatex.org] 2 ;;; (c) 1994-2013 by HIROSE Yuuji.[yuuji@yatex.org]
3 ;;; Last modified Sun Dec 21 13:58:31 2014 on firestorm 3 ;;; Last modified Mon Dec 22 12:49:03 2014 on firestorm
4 ;;; $Id$ 4 ;;; $Id$
5 5
6 ;;; Code: 6 ;;; Code:
7 ;;; 7 ;;;
8 ;; Functions for tabular environment 8 ;; Functions for tabular environment
10 10
11 ;; Showing the matching column of tabular environment. 11 ;; Showing the matching column of tabular environment.
12 (defun YaTeX-array-what-column-internal () 12 (defun YaTeX-array-what-column-internal ()
13 "Return the cons of matching column and its title of array environment. 13 "Return the cons of matching column and its title of array environment.
14 When calling from a program, make sure to be in array/tabular environment." 14 When calling from a program, make sure to be in array/tabular environment."
15 (let ((p (point)) beg eot bor (nlptn "\\\\\\\\") (andptn "[^\\]&") 15 (let ((p (point)) bot beg eot bor eoll (nlptn "\\\\\\\\") (andptn "[^\\]&")
16 (n 0) j 16 (n 0) j
17 (firsterr "This line might be the first row.")) 17 (firsterr "This line might be the first row."))
18 (save-excursion 18 (save-excursion
19 (YaTeX-beginning-of-environment) 19 (YaTeX-beginning-of-environment)
20 (setq eoll (save-excursion ;end of logical line
21 (YaTeX-goto-corresponding-environment) (point)))
20 (search-forward "{" p) (up-list 1) 22 (search-forward "{" p) (up-list 1)
21 (search-forward "{" p) (up-list 1) 23 (search-forward "{" p) (up-list 1)
22 ;;(re-search-forward andptn p) 24 ;;(re-search-forward andptn p)
23 (while (progn (search-forward "&" p) 25 (setq bot (point)) ;beginning of tabular
26 (while (progn (search-forward "&" eoll)
24 (equal (char-after (1- (match-beginning 0))) ?\\ ))) 27 (equal (char-after (1- (match-beginning 0))) ?\\ )))
25 (setq beg (1- (point))) ;beg is the point of the first & 28 (setq beg (1- (point))) ;beg is the point of the first &
26 (or (re-search-forward nlptn p t) 29 (or (re-search-forward nlptn eoll t)
27 (error firsterr)) 30 (error firsterr))
28 (setq eot (point)) ;eot is the point of the first \\ 31 (setq eot (point)) ;eot is the point of the first \\
29 (goto-char p) 32 (goto-char p)
30 (or (re-search-backward nlptn beg t) 33 (setq bor (if (re-search-backward nlptn bot 1)
31 (error firsterr)) 34 (point) ;bor is the beginning of this row.
32 (setq bor (point)) ;bor is the beginning of this row. 35 bot))
33 (while (< (1- (point)) p) 36 (while (< (1- (point)) p)
34 (if (equal (following-char) ?&) 37 (if (equal (following-char) ?&)
35 (forward-char 1) 38 (forward-char 1)
36 (re-search-forward andptn nil 1)) 39 (re-search-forward andptn nil 1))
37 (setq n (1+ n))) ;Check current column number 40 (setq n (1+ n))) ;Check current column number
52 (or (re-search-forward andptn p nil) 55 (or (re-search-forward andptn p nil)
53 (error "This column exceeds the limit.")) 56 (error "This column exceeds the limit."))
54 (setq j (1- j))) 57 (setq j (1- j)))
55 (skip-chars-forward "\\s ") 58 (skip-chars-forward "\\s ")
56 (list n 59 (list n
57 (buffer-substring 60 (YaTeX-buffer-substring
58 (point) 61 (progn (skip-chars-forward "\n \t") (point))
59 (progn 62 (progn
60 (re-search-forward (concat andptn "\\|" nlptn) eot) 63 (re-search-forward (concat andptn "\\|" nlptn) eot)
61 (goto-char (match-beginning 0)) 64 (goto-char (match-beginning 0))
62 (if (looking-at andptn) 65 (if (looking-at andptn)
63 (forward-char 1)) 66 (forward-char 1))

yatex.org