yatex
changeset 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 | 2c2b70f41fb3 |
children | e17589ce8b0d |
files | yahtml.el yatex.el yatex.new yatexenv.el |
diffstat | 4 files changed, 127 insertions(+), 15 deletions(-) [+] |
line diff
1.1 --- a/yahtml.el Mon Dec 22 11:27:28 2014 +0900 1.2 +++ b/yahtml.el Mon Dec 22 22:33:02 2014 +0900 1.3 @@ -1,6 +1,6 @@ 1.4 ;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*- 1.5 ;;; (c) 1994-2013 by HIROSE Yuuji [yuuji(@)yatex.org] 1.6 -;;; Last modified Sun Dec 21 14:02:00 2014 on firestorm 1.7 +;;; Last modified Mon Dec 22 22:17:24 2014 on firestorm 1.8 ;;; $Id$ 1.9 1.10 (defconst yahtml-revision-number "1.77" 1.11 @@ -2500,10 +2500,61 @@ 1.12 ; (apply 'YaTeX-saved-indent-new-comment-line (if soft (list soft)))) 1.13 ; (fset 'move-to-column yahtml-saved-move-to-column))) 1.14 1.15 +;;; 1.16 +;;; ---------- move forward/backward field ---------- 1.17 +;;; 1.18 +(defun yahtml-element-path () 1.19 + "Return the element path from <body> at point as a list" 1.20 + (let (path elm) 1.21 + (save-excursion 1.22 + (while (and (YaTeX-beginning-of-environment) 1.23 + (looking-at (concat "<\\(" yahtml-command-regexp "\\)\\>")) 1.24 + (not (string= (setq elm (downcase (YaTeX-match-string 1))) 1.25 + "body"))) 1.26 + (setq path (cons elm path) 1.27 + elm nil)) 1.28 + (and elm (setq path (cons elm path)))))) 1.29 + 1.30 +(defun yahtml-forward-field (arg) 1.31 + "Move ARGth forward cell to table element. 1.32 +ENVINFO is a cons of target element name and its beginning point." 1.33 + (interactive "p") 1.34 + (let (inenv elm path sibs) 1.35 + (cond 1.36 + ((< arg 0) (yahtml-backward-field (- arg))) 1.37 + ((= arg 0) nil) 1.38 + ((and (setq path (nreverse (yahtml-element-path))) 1.39 + (catch 'sibling 1.40 + (while path 1.41 + (if (setq elm (car-safe 1.42 + (member (car path) '("td" "th" "li" "dt" "dd")))) 1.43 + (throw 'sibling elm)) 1.44 + (setq path (cdr path))))) 1.45 + (setq inenv (YaTeX-in-environment-p elm) 1.46 + sibs (cdr (assoc elm '(("td" . "td\\|th") 1.47 + ("th" . "td\\|th") 1.48 + ("li" . "li") 1.49 + ("dt" . "dt\\|dd") 1.50 + ("dd" . "dt\\|dd"))))) 1.51 + (goto-char (cdr inenv)) 1.52 + (while (>= (setq arg (1- arg)) 0) 1.53 + (yahtml-goto-corresponding-begend) 1.54 + (if (looking-at "<") (forward-list 1)) 1.55 + (skip-chars-forward "^<")) 1.56 + (while (looking-at "\\s \\|\\(</\\)") 1.57 + (if (match-beginning 1) (forward-list 1) 1.58 + (skip-chars-forward "\n\t "))) 1.59 + (forward-list 1) ;; step into environment 1.60 + (skip-chars-forward " \t\n") 1.61 + (if (looking-at (concat "<\\(" sibs "\\)\\>")) 1.62 + (forward-list 1)) 1.63 + )))) 1.64 + 1.65 + 1.66 ;;; 1.67 ;;; ---------- indentation ---------- 1.68 ;;; 1.69 -(defun yahtml-indent-line () 1.70 +(defun yahtml-indent-line-1 () 1.71 "Indent a line (faster wrapper)" 1.72 (interactive) 1.73 (let (indent) 1.74 @@ -2526,6 +2577,18 @@ 1.75 (and (bolp) (skip-chars-forward " \t"))) 1.76 (yahtml-indent-line-real)))) 1.77 1.78 +(defun yahtml-indent-line () 1.79 + "Indent a line (Second level wrapper). 1.80 +See also yahtml-indent-line-1 and yahtml-indent-line-real." 1.81 + (interactive) 1.82 + (let ((cc (current-column)) (p (point))) 1.83 + (yahtml-indent-line-1) 1.84 + (and (= cc (current-column)) 1.85 + (= p (point)) 1.86 + (equal last-command 'yahtml-indent-line) 1.87 + (yahtml-forward-field 1)))) 1.88 + 1.89 + 1.90 (defun yahtml-this-indent () 1.91 (let ((envs "[uod]l\\|table\\|[ht][rhd0-6]\\|select\\|blockquote\\|center\\|menu\\|dir\\|d[td]\\|li") 1.92 (itemizing-envs "^\\([uod]l\\|menu\\|dir\\|li\\|d[td]\\)$")
2.1 --- a/yatex.el Mon Dec 22 11:27:28 2014 +0900 2.2 +++ b/yatex.el Mon Dec 22 22:33:02 2014 +0900 2.3 @@ -1,6 +1,6 @@ 2.4 ;;; yatex.el --- Yet Another tex-mode for emacs //野鳥// -*- coding: sjis -*- 2.5 ;;; (c)1991-2014 by HIROSE Yuuji.[yuuji@yatex.org] 2.6 -;;; Last modified Sun Dec 21 23:13:59 2014 on firestorm 2.7 +;;; Last modified Mon Dec 22 22:23:52 2014 on firestorm 2.8 ;;; $Id$ 2.9 ;;; The latest version of this software is always available at; 2.10 ;;; http://www.yatex.org/ 2.11 @@ -2677,7 +2677,7 @@ 2.12 (regexp-quote 2.13 (YaTeX-replace-format-args 2.14 YaTeX-struct-begin env "" "")) 2.15 - "\\)\\|\\(" 2.16 + "\\>\\)\\|\\(" 2.17 (regexp-quote 2.18 (YaTeX-replace-format-args 2.19 YaTeX-struct-end env "" "")) 2.20 @@ -3013,6 +3013,42 @@ 2.21 (if (string= c "t") (insert (YaTeX-read-accent-char c))) 2.22 (forward-char 1)))) 2.23 2.24 +;; Field skip in tabular 2.25 +(defun YaTeX-forward-field (arg) 2.26 + "Move forward to the ARGth next column field of table." 2.27 + (interactive "p") 2.28 + (if (< arg 0) 2.29 + (YaTeX-backward-field (- arg)) 2.30 + (let ((ep (save-excursion (YaTeX-end-of-environment) (point))) 2.31 + (wc (car (YaTeX-array-what-column-internal)))) 2.32 + (while (>= (setq arg (1- arg)) 0) 2.33 + (skip-chars-forward "^&\\\\") 2.34 + (while (and (not (eobp)) 2.35 + (> ep (point)) 2.36 + (looking-at "\\&\\|\\\\") 2.37 + (= wc (car (YaTeX-array-what-column-internal)))) 2.38 + (skip-chars-forward "&\\\\" ep) 2.39 + (skip-chars-forward "\n\t " ep)))))) 2.40 + 2.41 +(defun YaTeX-backward-field (arg) 2.42 + "Move backward to the ARGth next column field of table." 2.43 + (interactive "p") 2.44 + (if (< arg 0) 2.45 + (YaTeX-forward-field (- arg)) 2.46 + (let ((bp (save-excursion 2.47 + (YaTeX-beginning-of-environment) 2.48 + (point-end-of-line))) 2.49 + (wc (car (YaTeX-array-what-column-internal)))) 2.50 + (while (>= (setq arg (1- arg)) 0) 2.51 + (skip-chars-backward "^&\\\\" bp) 2.52 + (while (and (not (bobp)) 2.53 + (< bp (point)) 2.54 + (memq (preceding-char) '(?& ?\\)) 2.55 + (= wc (car (YaTeX-array-what-column-internal)))) 2.56 + (skip-chars-backward "&\\\\" bp) 2.57 + (skip-chars-backward "\n\t " bp)) 2.58 + (if (eolp) (skip-chars-forward "^&\\\\")))))) 2.59 + 2.60 ;; Indentation 2.61 (defun YaTeX-current-indentation () 2.62 "Return the indentation of current environment." 2.63 @@ -3116,7 +3152,7 @@ 2.64 ((YaTeX-literal-p) ;verbatims 2.65 (tab-to-tab-stop)) 2.66 ((string-match "\\(tabular\\|array\\)" inenv) ;1.73 2.67 - (let ((n 1)) 2.68 + (let ((n 1) (cc (current-column)) (p (point))) 2.69 (condition-case err 2.70 (save-excursion 2.71 (beginning-of-line) 2.72 @@ -3128,7 +3164,12 @@ 2.73 (YaTeX-reindent 2.74 (+ (YaTeX-current-indentation) 2.75 YaTeX-environment-indent 2.76 - (* (1- n) YaTeX-tabular-indentation))))) 2.77 + (* (1- n) YaTeX-tabular-indentation))) 2.78 + (and (= cc (current-column)) 2.79 + (= p (point)) 2.80 + (equal last-command 'YaTeX-indent-line) 2.81 + ;; if NO indent action occured, move to the next column 2.82 + (YaTeX-forward-field 1)))) 2.83 ((and inenv (not (equal "document" inenv))) 2.84 (funcall indent-relative)) 2.85 ((YaTeX-on-section-command-p YaTeX-sectioning-regexp)
3.1 --- a/yatex.new Mon Dec 22 11:27:28 2014 +0900 3.2 +++ b/yatex.new Mon Dec 22 22:33:02 2014 +0900 3.3 @@ -2,10 +2,15 @@ 3.4 野鳥/yahtml - 各バージョンの変更点について 3.5 3.6 1.78 Drag&Dropサポートを追加。 3.7 + tabular環境内で2連続以上Tabで、1カラム進む機能を追加。 3.8 === yatex === 3.9 主な外部コマンド名を変数化。 3.10 [prefix] t d の直後のデフォルトヴューアはPDF用のものに。 3.11 「%#!コマンド -オプション」のときは親ファイル指定なしと判定。 3.12 + 地の段落での [prefix] t g でヴューアの forward-search を試みる。 3.13 + [prefix] t e の環境タイプセットの結果を可能なら画像に。 3.14 + === yahtml === 3.15 + table, ul, ol, dl 内で2連続以上Tabで、1カラム進む機能を追加。 3.16 3.17 1.77 last-command-char 廃止対策を追加。 3.18 === yatex ===
4.1 --- a/yatexenv.el Mon Dec 22 11:27:28 2014 +0900 4.2 +++ b/yatexenv.el Mon Dec 22 22:33:02 2014 +0900 4.3 @@ -1,6 +1,6 @@ 4.4 ;;; yatexenv.el --- YaTeX environment-specific functions 4.5 ;;; (c) 1994-2013 by HIROSE Yuuji.[yuuji@yatex.org] 4.6 -;;; Last modified Sun Dec 21 13:58:31 2014 on firestorm 4.7 +;;; Last modified Mon Dec 22 12:49:03 2014 on firestorm 4.8 ;;; $Id$ 4.9 4.10 ;;; Code: 4.11 @@ -12,24 +12,27 @@ 4.12 (defun YaTeX-array-what-column-internal () 4.13 "Return the cons of matching column and its title of array environment. 4.14 When calling from a program, make sure to be in array/tabular environment." 4.15 - (let ((p (point)) beg eot bor (nlptn "\\\\\\\\") (andptn "[^\\]&") 4.16 + (let ((p (point)) bot beg eot bor eoll (nlptn "\\\\\\\\") (andptn "[^\\]&") 4.17 (n 0) j 4.18 (firsterr "This line might be the first row.")) 4.19 (save-excursion 4.20 (YaTeX-beginning-of-environment) 4.21 + (setq eoll (save-excursion ;end of logical line 4.22 + (YaTeX-goto-corresponding-environment) (point))) 4.23 (search-forward "{" p) (up-list 1) 4.24 (search-forward "{" p) (up-list 1) 4.25 ;;(re-search-forward andptn p) 4.26 - (while (progn (search-forward "&" p) 4.27 + (setq bot (point)) ;beginning of tabular 4.28 + (while (progn (search-forward "&" eoll) 4.29 (equal (char-after (1- (match-beginning 0))) ?\\ ))) 4.30 (setq beg (1- (point))) ;beg is the point of the first & 4.31 - (or (re-search-forward nlptn p t) 4.32 + (or (re-search-forward nlptn eoll t) 4.33 (error firsterr)) 4.34 (setq eot (point)) ;eot is the point of the first \\ 4.35 (goto-char p) 4.36 - (or (re-search-backward nlptn beg t) 4.37 - (error firsterr)) 4.38 - (setq bor (point)) ;bor is the beginning of this row. 4.39 + (setq bor (if (re-search-backward nlptn bot 1) 4.40 + (point) ;bor is the beginning of this row. 4.41 + bot)) 4.42 (while (< (1- (point)) p) 4.43 (if (equal (following-char) ?&) 4.44 (forward-char 1) 4.45 @@ -54,8 +57,8 @@ 4.46 (setq j (1- j))) 4.47 (skip-chars-forward "\\s ") 4.48 (list n 4.49 - (buffer-substring 4.50 - (point) 4.51 + (YaTeX-buffer-substring 4.52 + (progn (skip-chars-forward "\n \t") (point)) 4.53 (progn 4.54 (re-search-forward (concat andptn "\\|" nlptn) eot) 4.55 (goto-char (match-beginning 0))