(encode-mime-charset-region (point-min) (point-max) mime-charset))
(as-binary-output-file
(write-region (point-min) (point-max) filename nil 'no-msg)))
- (message (format "%s is not writable." filename)))))
+ (message "%s is not writable." filename))))
(defun elmo-object-save (filename object &optional mime-charset)
"Save OBJECT to the file specified by FILENAME.
(concat field "(2) Search by") default)
")"))
((string-match "Since\\|Before" field)
- (concat (downcase field) ":"
- (completing-read (format "Value for '%s': " field)
- (mapcar (function
- (lambda (x)
- (list (format "%s" (car x)))))
- elmo-date-descriptions))))
+ (let ((default (format-time-string "%Y-%m-%d")))
+ (setq value (completing-read
+ (format "Value for '%s' [%s]: " field default)
+ (mapcar (function
+ (lambda (x)
+ (list (format "%s" (car x)))))
+ elmo-date-descriptions)))
+ (concat (downcase field) ":"
+ (if (equal value "") default value))))
(t
(setq value (read-from-minibuffer (format "Value for '%s': " field)))
(unless (string-match (concat "^" elmo-condition-atom-regexp "$")
;; time ::= "yesterday" / "lastweek" / "lastmonth" / "lastyear" /
;; number SPACE* "daysago" /
;; number "-" month "-" number ; ex. 10-May-2000
+;; number "-" number "-" number ; ex. 2000-05-10
;; number ::= [0-9]+
;; month ::= "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" /
;; "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"
(looking-at "lastmonth") (looking-at "lastyear")
(looking-at "[0-9]+ *daysago")
(looking-at "[0-9]+-[A-Za-z]+-[0-9]+")
+ (looking-at "[0-9]+-[0-9]+-[0-9]+")
(looking-at "[0-9]+")
(looking-at elmo-condition-atom-regexp))
(prog1 (elmo-match-buffer 0)
lst)
(defun elmo-list-insert (list element after)
- "Insert an ELEMENT to the LIST, just after AFTER."
- (let ((li list)
- (curn 0)
- p pn)
- (while li
- (if (eq (car li) after)
- (setq p li pn curn li nil)
- (incf curn))
- (setq li (cdr li)))
- (if pn
- (setcdr (nthcdr pn list) (cons element (cdr p)))
+ (let* ((match (memq after list))
+ (rest (and match (cdr (memq after list)))))
+ (if match
+ (progn
+ (setcdr match (list element))
+ (nconc list rest))
(nconc list (list element)))))
(defun elmo-string-partial-p (string)
(write-region (point-min) (point-max)
filename nil 'no-msg)
(set-file-modes filename 384))
- (message (format "%s is not writable." filename)))
+ (message "%s is not writable." filename))
(kill-buffer tmp-buffer))))
(defun elmo-get-passwd (key)
(setq last-modified (+ (* (nth 0 last-modified)
(float 65536)) (nth 1 last-modified)))))
-(defun elmo-make-directory (path)
+(defun elmo-make-directory (path &optional mode)
"Create directory recursively."
(let ((parent (directory-file-name (file-name-directory path))))
(if (null (file-directory-p parent))
(elmo-make-directory parent))
(make-directory path)
- (if (string= path (expand-file-name elmo-msgdb-directory))
- (set-file-modes path (+ (* 64 7) (* 8 0) 0))))) ; chmod 0700
+ (set-file-modes path (or mode
+ (+ (* 64 7) (* 8 0) 0))))) ; chmod 0700
(defun elmo-delete-directory (path &optional no-hierarchy)
"Delete directory recursively."
(setq l1 (cdr l1)))
(cons diff1 (list l2)))))
+(defmacro elmo-filter-condition-p (filter)
+ `(or (vectorp ,filter) (consp ,filter)))
+
(defmacro elmo-filter-type (filter)
(` (aref (, filter) 0)))
(length (memq number number-list)))
(string-to-int (elmo-filter-value condition)))))
((string= (elmo-filter-key condition) "since")
- (let ((date (elmo-date-get-datevec (elmo-filter-value condition))))
+ (let ((field-date (elmo-date-make-sortable-string
+ (timezone-fix-time
+ (std11-field-body "date")
+ (current-time-zone) nil)))
+ (specified-date (elmo-date-make-sortable-string
+ (elmo-date-get-datevec
+ (elmo-filter-value condition)))))
(setq result
- (string<
- (timezone-make-sortable-date (aref date 0)
- (aref date 1)
- (aref date 2)
- (timezone-make-time-string
- (aref date 3)
- (aref date 4)
- (aref date 5)))
- (timezone-make-date-sortable (std11-field-body "date"))))))
+ (or (string= field-date specified-date)
+ (string< specified-date field-date)))))
((string= (elmo-filter-key condition) "before")
- (let ((date (elmo-date-get-datevec (elmo-filter-value condition))))
- (setq result
- (string<
- (timezone-make-date-sortable (std11-field-body "date"))
- (timezone-make-sortable-date (aref date 0)
- (aref date 1)
- (aref date 2)
- (timezone-make-time-string
- (aref date 3)
- (aref date 4)
- (aref date 5)))))))
+ (setq result
+ (string<
+ (elmo-date-make-sortable-string
+ (timezone-fix-time
+ (std11-field-body "date")
+ (current-time-zone) nil))
+ (elmo-date-make-sortable-string
+ (elmo-date-get-datevec
+ (elmo-filter-value condition))))))
((string= (elmo-filter-key condition) "body")
(and (re-search-forward "^$" nil t) ; goto body
(setq result (search-forward (elmo-filter-value condition)
file (nth 2 condition) number number-list)))))
(defmacro elmo-get-hash-val (string hashtable)
- (let ((sym (list 'intern-soft string hashtable)))
- (list 'if (list 'boundp sym)
- (list 'symbol-value sym))))
+ `(and (stringp ,string)
+ (let ((sym (intern-soft ,string ,hashtable)))
+ (if (boundp sym)
+ (symbol-value sym)))))
(defmacro elmo-set-hash-val (string value hashtable)
(list 'set (list 'intern string hashtable) value))
(defun elmo-progress-clear (label)
(let ((counter (assq label elmo-progress-counter-alist)))
(when counter
- (elmo-display-progress label "" 100)
+ (elmo-display-progress label
+ (elmo-progress-counter-format counter)
+ 100)
(setq elmo-progress-counter-alist
(delq counter elmo-progress-counter-alist)))))
(defmacro elmo-string (string)
"STRING without text property."
(` (let ((obj (copy-sequence (, string))))
- (set-text-properties 0 (length obj) nil obj)
+ (and obj (set-text-properties 0 (length obj) nil obj))
obj)))
(defun elmo-flatten (list-of-list)
(defun elmo-file-cache-delete (path)
"Delete a cache on PATH."
- (let (files)
- (when (file-exists-p path)
- (if (file-directory-p path)
- (progn
- (setq files (directory-files path t "^[^\\.]"))
- (while files
- (delete-file (car files))
- (setq files (cdr files)))
- (delete-directory path))
- (delete-file path)))))
+ (when (file-exists-p path)
+ (if (file-directory-p path)
+ (progn
+ (dolist (file (directory-files path t "^[^\\.]"))
+ (delete-file file))
+ (delete-directory path))
+ (delete-file path))
+ t))
(defun elmo-file-cache-exists-p (msgid)
"Returns 'section or 'entire if a cache which corresponds to MSGID exists."