yatex
changeset 154:d3bcc4e2166a dev
Two new function added.
`[prefix] }' yahtml-td-region
`[prefix] ]' yahtml-tr-region
author | yuuji@gentei.org |
---|---|
date | Thu, 09 Dec 2010 12:23:22 +0900 |
parents | 207f0b4af9df |
children | 4fd09665b2be |
files | yahtml.el |
diffstat | 1 files changed, 47 insertions(+), 1 deletions(-) [+] |
line diff
1.1 --- a/yahtml.el Sat Nov 06 19:24:34 2010 +0900 1.2 +++ b/yahtml.el Thu Dec 09 12:23:22 2010 +0900 1.3 @@ -1,6 +1,6 @@ 1.4 ;;; -*- Emacs-Lisp -*- 1.5 ;;; (c) 1994-2010 by HIROSE Yuuji [yuuji(@)yatex.org] 1.6 -;;; Last modified Sat Nov 6 19:22:54 2010 on firestorm 1.7 +;;; Last modified Thu Dec 9 12:21:27 2010 on firestorm 1.8 ;;; $Id$ 1.9 1.10 (defconst yahtml-revision-number "1.74.2" 1.11 @@ -369,6 +369,8 @@ 1.12 (YaTeX-define-key ";" 'yahtml-translate-region map) 1.13 (YaTeX-define-key ":" 'yahtml-translate-reverse-region map) 1.14 (YaTeX-define-key "#" 'yahtml-escape-chars-region map) 1.15 + (YaTeX-define-key "}" 'yahtml-td-region map) 1.16 + (YaTeX-define-key "]" 'yahtml-tr-region map) 1.17 ;;;;;(YaTeX-define-key "i" 'yahtml-fill-item map) 1.18 (YaTeX-define-key "\e" 'yahtml-quit map)) 1.19 (substitute-all-key-definition 1.20 @@ -2331,6 +2333,50 @@ 1.21 left) 1.22 (store-match-data md)))) 1.23 1.24 +;;; ---------- table-ize region ---------- 1.25 +(defun yahtml-td-region (e delim beg end) 1.26 + "Enclose each item in a region with <td>..</td>. 1.27 +Interactive prefix argument consults enclosing element other than td." 1.28 + (interactive "P\nsDelimiter(s): \nr") 1.29 + (let ((e (if (and e (listp e)) (read-string "Enclose with : " "td") "td")) 1.30 + p q) 1.31 + (if (string= delim "") (setq delim " \t\n")) 1.32 + (setq delim (concat "[" delim "]+")) 1.33 + (save-excursion 1.34 + (save-restriction 1.35 + (narrow-to-region beg end) 1.36 + (goto-char (setq p (point-min))) 1.37 + (while (re-search-forward delim nil t) 1.38 + (goto-char (match-beginning 0)) 1.39 + (insert "</" e ">") 1.40 + (save-excursion 1.41 + (goto-char p) 1.42 + (insert "<" e ">")) 1.43 + (setq p (point)) 1.44 + (while (and (not (eobp)) (looking-at delim)) 1.45 + (delete-char 1))) 1.46 + (insert "<" e ">") 1.47 + (goto-char (point-max)) 1.48 + (insert "</" e ">"))))) 1.49 + 1.50 +(defun yahtml-tr-region (e delim beg end) 1.51 + "Enclose lines in a form tab-sv/csv with <tr><td>..</td></tr>." 1.52 + (interactive "P\nsDelimiter(s): \nr") 1.53 + (let ((e (if (and e (listp e)) (read-string "Enclose with : " "td") "td")) 1.54 + p q) 1.55 + (if (string= delim "") (setq delim " \t\n")) 1.56 + ;; (setq delim (concat "[" delim "]+")) ;unnecessary here 1.57 + (save-excursion 1.58 + (save-restriction 1.59 + (narrow-to-region (point) (mark)) 1.60 + (goto-char (point-min)) 1.61 + (while (not (eobp)) 1.62 + (insert "<tr>") 1.63 + (yahtml-td-region e delim (point) (point-end-of-line)) 1.64 + (end-of-line) 1.65 + (insert "</tr>") 1.66 + (forward-line 1)))))) 1.67 + 1.68 ;;; ---------- filling ---------- 1.69 (defvar yahtml-saved-move-to-column (symbol-function 'move-to-column)) 1.70 (defun yahtml-move-to-column (col &optional force)