X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=elmo%2Felmo-date.el;h=47d10c9b45c9e62a34afb5aa1ad11d07ace5ffb2;hb=7f48b955f3b8da23ddcf1e76c38790867ce8b635;hp=8a10d42193d39322ae1f03c6ac6ef6e50f298169;hpb=e64882498d21cef2b964ddc18d41421ab36bd19b;p=elisp%2Fwanderlust.git diff --git a/elmo/elmo-date.el b/elmo/elmo-date.el index 8a10d42..47d10c9 100644 --- a/elmo/elmo-date.el +++ b/elmo/elmo-date.el @@ -1,6 +1,6 @@ -;;; elmo-date.el -- Date processing module for ELMO. +;;; elmo-date.el --- Date processing module for ELMO. -;; Copyright 1998,1999,2000 Yuuichi Teranishi +;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi ;; Author: Yuuichi Teranishi ;; Keywords: mail, net news @@ -24,17 +24,74 @@ ;; ;;; Commentary: -;; +;; ;;; Code: -;; +;; (require 'path-util) -(if (module-installed-p 'timezone) - (require 'timezone)) +(require 'timezone) (require 'elmo-vars) +(defmacro elmo-match-substring (pos string from) + "Substring of POSth matched string of STRING." + (` (substring (, string) + (+ (match-beginning (, pos)) (, from)) + (match-end (, pos))))) + +(defmacro elmo-match-string (pos string) + "Substring POSth matched STRING." + (` (substring (, string) (match-beginning (, pos)) (match-end (, pos))))) + +(defmacro elmo-match-buffer (pos) + "Substring POSth matched from the current buffer." + (` (buffer-substring-no-properties + (match-beginning (, pos)) (match-end (, pos))))) + +;; from subr.el +(defun elmo-replace-in-string (str regexp newtext &optional literal) + "Replace all matches in STR for REGEXP with NEWTEXT string. +And returns the new string. +Optional LITERAL non-nil means do a literal replacement. +Otherwise treat \\ in NEWTEXT string as special: + \\& means substitute original matched text, + \\N means substitute match for \(...\) number N, + \\\\ means insert one \\." + (let ((rtn-str "") + (start 0) + (special) + match prev-start) + (while (setq match (string-match regexp str start)) + (setq prev-start start + start (match-end 0) + rtn-str + (concat + rtn-str + (substring str prev-start match) + (cond (literal newtext) + (t (mapconcat + (function + (lambda (c) + (if special + (progn + (setq special nil) + (cond ((eq c ?\\) "\\") + ((eq c ?&) + (elmo-match-string 0 str)) + ((and (>= c ?0) (<= c ?9)) + (if (> c (+ ?0 (length + (match-data)))) + ;; Invalid match num + (error "Invalid match num: %c" c) + (setq c (- c ?0)) + (elmo-match-string c str))) + (t (char-to-string c)))) + (if (eq c ?\\) (progn (setq special t) nil) + (char-to-string c))))) + newtext "")))))) + (concat rtn-str (substring str start)))) + (defvar elmo-date-descriptions '((yesterday . [0 0 1]) (lastweek . [0 0 7])