diff --git a/yahtml.el b/yahtml.el index f013371..d2facb5 100644 --- a/yahtml.el +++ b/yahtml.el @@ -1,6 +1,6 @@ ;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*- ;;; (c) 1994-2013 by HIROSE Yuuji [yuuji(@)yatex.org] -;;; Last modified Sun Dec 21 14:02:00 2014 on firestorm +;;; Last modified Mon Dec 22 22:17:24 2014 on firestorm ;;; $Id$ (defconst yahtml-revision-number "1.77" @@ -2500,10 +2500,61 @@ ; (apply 'YaTeX-saved-indent-new-comment-line (if soft (list soft)))) ; (fset 'move-to-column yahtml-saved-move-to-column))) +;;; +;;; ---------- move forward/backward field ---------- +;;; +(defun yahtml-element-path () + "Return the element path from at point as a list" + (let (path elm) + (save-excursion + (while (and (YaTeX-beginning-of-environment) + (looking-at (concat "<\\(" yahtml-command-regexp "\\)\\>")) + (not (string= (setq elm (downcase (YaTeX-match-string 1))) + "body"))) + (setq path (cons elm path) + elm nil)) + (and elm (setq path (cons elm path)))))) + +(defun yahtml-forward-field (arg) + "Move ARGth forward cell to table element. +ENVINFO is a cons of target element name and its beginning point." + (interactive "p") + (let (inenv elm path sibs) + (cond + ((< arg 0) (yahtml-backward-field (- arg))) + ((= arg 0) nil) + ((and (setq path (nreverse (yahtml-element-path))) + (catch 'sibling + (while path + (if (setq elm (car-safe + (member (car path) '("td" "th" "li" "dt" "dd")))) + (throw 'sibling elm)) + (setq path (cdr path))))) + (setq inenv (YaTeX-in-environment-p elm) + sibs (cdr (assoc elm '(("td" . "td\\|th") + ("th" . "td\\|th") + ("li" . "li") + ("dt" . "dt\\|dd") + ("dd" . "dt\\|dd"))))) + (goto-char (cdr inenv)) + (while (>= (setq arg (1- arg)) 0) + (yahtml-goto-corresponding-begend) + (if (looking-at "<") (forward-list 1)) + (skip-chars-forward "^<")) + (while (looking-at "\\s \\|\\(")) + (forward-list 1)) + )))) + + ;;; ;;; ---------- indentation ---------- ;;; -(defun yahtml-indent-line () +(defun yahtml-indent-line-1 () "Indent a line (faster wrapper)" (interactive) (let (indent) @@ -2526,6 +2577,18 @@ (and (bolp) (skip-chars-forward " \t"))) (yahtml-indent-line-real)))) +(defun yahtml-indent-line () + "Indent a line (Second level wrapper). +See also yahtml-indent-line-1 and yahtml-indent-line-real." + (interactive) + (let ((cc (current-column)) (p (point))) + (yahtml-indent-line-1) + (and (= cc (current-column)) + (= p (point)) + (equal last-command 'yahtml-indent-line) + (yahtml-forward-field 1)))) + + (defun yahtml-this-indent () (let ((envs "[uod]l\\|table\\|[ht][rhd0-6]\\|select\\|blockquote\\|center\\|menu\\|dir\\|d[td]\\|li") (itemizing-envs "^\\([uod]l\\|menu\\|dir\\|li\\|d[td]\\)$") diff --git a/yatex.el b/yatex.el index 06e46c4..7ed8537 100644 --- a/yatex.el +++ b/yatex.el @@ -1,6 +1,6 @@ ;;; yatex.el --- Yet Another tex-mode for emacs //�쒹// -*- coding: sjis -*- ;;; (c)1991-2014 by HIROSE Yuuji.[yuuji@yatex.org] -;;; Last modified Sun Dec 21 23:13:59 2014 on firestorm +;;; Last modified Mon Dec 22 22:23:52 2014 on firestorm ;;; $Id$ ;;; The latest version of this software is always available at; ;;; http://www.yatex.org/ @@ -2677,7 +2677,7 @@ (regexp-quote (YaTeX-replace-format-args YaTeX-struct-begin env "" "")) - "\\)\\|\\(" + "\\>\\)\\|\\(" (regexp-quote (YaTeX-replace-format-args YaTeX-struct-end env "" "")) @@ -3013,6 +3013,42 @@ (if (string= c "t") (insert (YaTeX-read-accent-char c))) (forward-char 1)))) +;; Field skip in tabular +(defun YaTeX-forward-field (arg) + "Move forward to the ARGth next column field of table." + (interactive "p") + (if (< arg 0) + (YaTeX-backward-field (- arg)) + (let ((ep (save-excursion (YaTeX-end-of-environment) (point))) + (wc (car (YaTeX-array-what-column-internal)))) + (while (>= (setq arg (1- arg)) 0) + (skip-chars-forward "^&\\\\") + (while (and (not (eobp)) + (> ep (point)) + (looking-at "\\&\\|\\\\") + (= wc (car (YaTeX-array-what-column-internal)))) + (skip-chars-forward "&\\\\" ep) + (skip-chars-forward "\n\t " ep)))))) + +(defun YaTeX-backward-field (arg) + "Move backward to the ARGth next column field of table." + (interactive "p") + (if (< arg 0) + (YaTeX-forward-field (- arg)) + (let ((bp (save-excursion + (YaTeX-beginning-of-environment) + (point-end-of-line))) + (wc (car (YaTeX-array-what-column-internal)))) + (while (>= (setq arg (1- arg)) 0) + (skip-chars-backward "^&\\\\" bp) + (while (and (not (bobp)) + (< bp (point)) + (memq (preceding-char) '(?& ?\\)) + (= wc (car (YaTeX-array-what-column-internal)))) + (skip-chars-backward "&\\\\" bp) + (skip-chars-backward "\n\t " bp)) + (if (eolp) (skip-chars-forward "^&\\\\")))))) + ;; Indentation (defun YaTeX-current-indentation () "Return the indentation of current environment." @@ -3116,7 +3152,7 @@ ((YaTeX-literal-p) ;verbatims (tab-to-tab-stop)) ((string-match "\\(tabular\\|array\\)" inenv) ;1.73 - (let ((n 1)) + (let ((n 1) (cc (current-column)) (p (point))) (condition-case err (save-excursion (beginning-of-line) @@ -3128,7 +3164,12 @@ (YaTeX-reindent (+ (YaTeX-current-indentation) YaTeX-environment-indent - (* (1- n) YaTeX-tabular-indentation))))) + (* (1- n) YaTeX-tabular-indentation))) + (and (= cc (current-column)) + (= p (point)) + (equal last-command 'YaTeX-indent-line) + ;; if NO indent action occured, move to the next column + (YaTeX-forward-field 1)))) ((and inenv (not (equal "document" inenv))) (funcall indent-relative)) ((YaTeX-on-section-command-p YaTeX-sectioning-regexp) diff --git a/yatex.new b/yatex.new index a8b2b4a..3688f96 100644 --- a/yatex.new +++ b/yatex.new @@ -2,10 +2,15 @@ �쒹/yahtml - �e�o�[�W�����̕ύX�_�ɂ‚��� 1.78 Drag&Drop�T�|�[�g��lj��B + tabular�‹�����2�A���ȏ�Tab�ŁA1�J�����i�ދ@�\��lj��B === yatex === ��ȊO���R�}���h����ϐ����B [prefix] t d �̒���̃f�t�H���g�����[�A��PDF�p�̂��̂ɁB �u%#!�R�}���h -�I�v�V�����v�̂Ƃ��͐e�t�@�C���w��Ȃ��Ɣ���B + �n�̒i���ł� [prefix] t g �Ń����[�A�� forward-search �����݂�B + [prefix] t e �̊‹��^�C�v�Z�b�g�̌��ʂ��”\�Ȃ�摜�ɁB + === yahtml === + table, ul, ol, dl ����2�A���ȏ�Tab�ŁA1�J�����i�ދ@�\��lj��B 1.77 last-command-char �p�~�΍��lj��B === yatex === diff --git a/yatexenv.el b/yatexenv.el index e30814e..044deed 100644 --- a/yatexenv.el +++ b/yatexenv.el @@ -1,6 +1,6 @@ ;;; yatexenv.el --- YaTeX environment-specific functions ;;; (c) 1994-2013 by HIROSE Yuuji.[yuuji@yatex.org] -;;; Last modified Sun Dec 21 13:58:31 2014 on firestorm +;;; Last modified Mon Dec 22 12:49:03 2014 on firestorm ;;; $Id$ ;;; Code: @@ -12,24 +12,27 @@ (defun YaTeX-array-what-column-internal () "Return the cons of matching column and its title of array environment. When calling from a program, make sure to be in array/tabular environment." - (let ((p (point)) beg eot bor (nlptn "\\\\\\\\") (andptn "[^\\]&") + (let ((p (point)) bot beg eot bor eoll (nlptn "\\\\\\\\") (andptn "[^\\]&") (n 0) j (firsterr "This line might be the first row.")) (save-excursion (YaTeX-beginning-of-environment) + (setq eoll (save-excursion ;end of logical line + (YaTeX-goto-corresponding-environment) (point))) (search-forward "{" p) (up-list 1) (search-forward "{" p) (up-list 1) ;;(re-search-forward andptn p) - (while (progn (search-forward "&" p) + (setq bot (point)) ;beginning of tabular + (while (progn (search-forward "&" eoll) (equal (char-after (1- (match-beginning 0))) ?\\ ))) (setq beg (1- (point))) ;beg is the point of the first & - (or (re-search-forward nlptn p t) + (or (re-search-forward nlptn eoll t) (error firsterr)) (setq eot (point)) ;eot is the point of the first \\ (goto-char p) - (or (re-search-backward nlptn beg t) - (error firsterr)) - (setq bor (point)) ;bor is the beginning of this row. + (setq bor (if (re-search-backward nlptn bot 1) + (point) ;bor is the beginning of this row. + bot)) (while (< (1- (point)) p) (if (equal (following-char) ?&) (forward-char 1) @@ -54,8 +57,8 @@ (setq j (1- j))) (skip-chars-forward "\\s ") (list n - (buffer-substring - (point) + (YaTeX-buffer-substring + (progn (skip-chars-forward "\n \t") (point)) (progn (re-search-forward (concat andptn "\\|" nlptn) eot) (goto-char (match-beginning 0))