tm 7.99.
[elisp/tm.git] / tl-str.el
index 5dce601..e4f60b3 100644 (file)
--- a/tl-str.el
+++ b/tl-str.el
@@ -1,9 +1,65 @@
 ;;;
-;;; $Id: tl-str.el,v 1.3 1994/08/31 06:54:15 morioka Exp $
+;;; $Id: tl-str.el,v 3.2 1994/12/19 10:03:57 morioka Exp $
 ;;;
 
 (provide 'tl-str)
 
+
+;;; @@ about rightful dividing for multi-octet string
+;;;
+;; by mol. 1993/9/26
+(defun rightful-boundary-short-string (str width)
+  (substring str 0 
+            (let ((i 0) (w 0) chr (len (length str)))
+              (catch 'label
+                (while (< i len)
+                  (setq chr (elt str i))
+                  (setq w (+ w (char-width chr)))
+                  (if (> w width)
+                      (throw 'label i))
+                  (setq i (+ i (char-bytes chr)))
+                  )
+                i))
+            ))
+
+
+;;; @@ RCS version
+;;;
+
+(defun get-version-string (id)
+  (and (string-match "[0-9][0-9.]*" id)
+       (substring id (match-beginning 0)(match-end 0))
+       ))
+
+
+;;; @@ file name
+;;;
+(defun replace-as-filename (str)
+  (let ((dest "")
+       (i 0)(len (length str))
+       chr)
+    (while (< i len)
+      (setq chr (elt str i))
+      (if (or (and (<= ?+ chr)(<= chr ?.))
+             (and (<= ?0 chr)(<= chr ?:))
+             (= chr ?=)
+             (and (<= ?@ chr)(<= chr ?\[))
+             (and (<= ?\] chr)(<= chr ?_))
+             (and (<= ?a chr)(<= chr ?{))
+             (and (<= ?} chr)(<= chr ?~))
+             )
+         (setq dest (concat dest
+                            (char-to-string chr)))
+       )
+      (setq i (+ i 1))
+      )
+    dest))
+
+
+;;; @@ message editing utilities
+;;;
+(defvar cited-prefix-regexp "^[^ \t>]*[>|]+[ \t#]*")
+
 (defun fill-cited-region (beg end)
   (interactive "*r")
   (save-excursion
@@ -16,7 +72,9 @@
       (narrow-to-region beg end)
       (goto-char (point-min))
       (let* ((fill-prefix
-             (and (re-search-forward "^[^ \t>]*[>|]+[ \t]*" nil t)
+             (and (re-search-forward cited-prefix-regexp nil t)
+                  (or (re-search-forward cited-prefix-regexp nil t)
+                      t)
                   (buffer-substring (match-beginning 0)
                                     (match-end 0)
                                     )))
     (replace-match new)
     ))
 
-(defun replace-as-filename (str)
-  (let ((dest "")
-       (i 0)(len (length str))
-       chr)
-    (while (< i len)
-      (setq chr (elt str i))
-      (if (or (and (<= ?+ chr)(<= chr ?.))
-             (and (<= ?0 chr)(<= chr ?:))
-             (= chr ?=)
-             (and (<= ?@ chr)(<= chr ?\[))
-             (and (<= ?\] chr)(<= chr ?_))
-             (and (<= ?a chr)(<= chr ?{))
-             (and (<= ?} chr)(<= chr ?~))
-             )
-         (setq dest (concat dest
-                            (char-to-string chr)))
-       )
-      (setq i (+ i 1))
-      )
-    dest))
+
+;;; @@ jinn compatible functions
+;;;
+
+(defun symbol-concat (&rest args)
+  (intern (apply (function concat)
+                (mapcar (function
+                         (lambda (s)
+                           (cond ((symbolp s) (symbol-name s))
+                                 ((stringp s) s)
+                                 )
+                           ))
+                        args)))
+  )
+
+(defun top-string-match (pat str)
+  (if (string-match
+       (concat "^" (regexp-quote pat))
+       str)
+      (list pat (substring str (match-end 0)))
+    ))
+
+(defun middle-string-match (pat str)
+  (if (equal pat str)
+      (list nil pat nil)
+    (if (string-match (regexp-quote pat) str)
+       (let ((b (match-beginning 0))
+             (e (match-end 0)) )
+         (list (if (not (= b 0))
+                   (substring str 0 b)
+                 )
+               pat
+               (if (> (length str) e)
+                   (substring str e)
+                 )
+               )))))