yatex
diff yahtml.el @ 359:dbef6cf84f98
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 |
line diff
1.1 --- a/yahtml.el Sun Dec 21 14:20:01 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]\\)$")