changeset 156:9b5c19e860d8 dev

Simplify codes.
author yuuji@gentei.org
date Thu, 09 Dec 2010 14:41:57 +0900
parents 4fd09665b2be
children e3d7307f71e0
files yahtml.el
diffstat 1 files changed, 17 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/yahtml.el	Thu Dec 09 13:51:20 2010 +0900
+++ b/yahtml.el	Thu Dec 09 14:41:57 2010 +0900
@@ -1,6 +1,6 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; (c) 1994-2010 by HIROSE Yuuji [yuuji(@)yatex.org]
-;;; Last modified Thu Dec  9 13:50:21 2010 on firestorm
+;;; Last modified Thu Dec  9 14:40:52 2010 on firestorm
 ;;; $Id$
 
 (defconst yahtml-revision-number "1.74.2"
@@ -2338,7 +2338,10 @@
   "Enclose each item in a region with <td>..</td>.
 Interactive prefix argument consults enclosing element other than td."
   (interactive "P\nsDelimiter(s): \nr")
-  (let ((e (if (and e (listp e)) (read-string "Enclose with : " "td") "td"))
+  (let ((e (cond
+	    ((null e) "td")
+	    ((stringp e) e)
+	    (t (read-string "Enclose with: " "td"))))
 	p q (ws "[ \t]"))
     (if (string= delim "") (setq delim " \t\n"))
     (setq delim (concat "[" delim "]+"))
@@ -2363,21 +2366,18 @@
 (defun yahtml-tr-region (e delim beg end)
   "Enclose lines in a form tab-sv/csv with <tr><td>..</td></tr>."
   (interactive "P\nsDelimiter(s): \nr")
-  (let ((e (if (and e (listp e)) (read-string "Enclose with : " "td") "td"))
-	p q)
-    (if (string= delim "") (setq delim " \t\n"))
-    ;; (setq delim (concat "[" delim "]+")) ;unnecessary here
-    (save-excursion
-      (save-restriction
-	(narrow-to-region (point) (mark))
-	(goto-char (point-min))
-	(while (not (eobp))
-	  (insert "<tr>")
-	  (yahtml-td-region e delim (point) (point-end-of-line))
-	  (end-of-line)
-	  (insert "</tr>")
-	  (yahtml-indent-line)
-	  (forward-line 1))))))
+  (setq e (if (and e (listp e)) (read-string "Enclose with: " "th")))
+  (save-excursion
+    (save-restriction
+      (narrow-to-region (point) (mark))
+      (goto-char (point-min))
+      (while (not (eobp))
+	(insert "<tr>")
+	(yahtml-td-region e delim (point) (point-end-of-line))
+	(end-of-line)
+	(insert "</tr>")
+	(yahtml-indent-line)
+	(forward-line 1)))))
 	
 ;;; ---------- filling ----------
 (defvar yahtml-saved-move-to-column (symbol-function 'move-to-column))

yatex.org