X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=tl-str.el;h=e4f60b37aac2c9a13d578f827366f93c71b7b119;hb=8e18eb1fd95180a6ea115a00ce2f045815809b49;hp=5dce601b9ed826d7aa5d2a60cdce84ccd281ab50;hpb=6f60f010f0797bb67af3aa0bf0f202b61ad7b72d;p=elisp%2Ftm.git diff --git a/tl-str.el b/tl-str.el index 5dce601..e4f60b3 100644 --- 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) ))) @@ -42,23 +100,39 @@ (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) + ) + )))))