;;; Code:
+(require 'custom)
(require 'cl)
(require 'nnheader)
(require 'timezone)
(select-window ,tempvar)))))
(put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
-(put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
(put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
(defmacro gnus-intern-safe (string hashtable)
(defmacro gnus-buffer-exists-p (buffer)
`(let ((buffer ,buffer))
- (and buffer
- (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
- buffer))))
+ (when buffer
+ (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
+ buffer))))
(defmacro gnus-kill-buffer (buffer)
`(let ((buf ,buffer))
- (if (gnus-buffer-exists-p buf)
- (kill-buffer buf))))
+ (when (gnus-buffer-exists-p buf)
+ (kill-buffer buf))))
(defsubst gnus-point-at-bol ()
"Return point at the beginning of the line."
;; First find the address - the thing with the @ in it. This may
;; not be accurate in mail addresses, but does the trick most of
;; the time in news messages.
- (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
- (setq address (substring from (match-beginning 0) (match-end 0))))
+ (when (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
+ (setq address (substring from (match-beginning 0) (match-end 0))))
;; Then we check whether the "name <address>" format is used.
(and address
;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
(setq idx 0))
;; Replace all occurrences of `.' with `/'.
(while (< idx len)
- (if (= (aref newsgroup idx) ?.)
- (aset newsgroup idx ?/))
+ (when (= (aref newsgroup idx) ?.)
+ (aset newsgroup idx ?/))
(setq idx (1+ idx)))
newsgroup))
`(gnus-define-keys-1 (quote ,keymap) (quote ,plist) t))
(put 'gnus-define-keys 'lisp-indent-function 1)
-(put 'gnus-define-keys 'lisp-indent-hook 1)
(put 'gnus-define-keys-safe 'lisp-indent-function 1)
-(put 'gnus-define-keys-safe 'lisp-indent-hook 1)
(put 'gnus-local-set-keys 'lisp-indent-function 1)
-(put 'gnus-local-set-keys 'lisp-indent-hook 1)
(defmacro gnus-define-keymap (keymap &rest plist)
"Define all keys in PLIST in KEYMAP."
`(gnus-define-keys-1 ,keymap (quote ,plist)))
+(put 'gnus-define-keymap 'lisp-indent-function 1)
+
(defun gnus-define-keys-1 (keymap plist &optional safe)
(when (null keymap)
(error "Can't set keys in a null keymap"))
;; it yet. -erik selberg@cs.washington.edu
(defun gnus-dd-mmm (messy-date)
"Return a string like DD-MMM from a big messy string"
- (let ((datevec (condition-case () (timezone-parse-date messy-date)
- (error nil))))
+ (let ((datevec (ignore-errors (timezone-parse-date messy-date))))
(if (not datevec)
"??-???"
(format "%2s-%s"
timezone-months-assoc))
"???"))))))
+(defmacro gnus-date-get-time (date)
+ "Convert DATE string to Emacs time.
+Cache the result as a text property stored in DATE."
+ ;; Either return the cached value...
+ `(let ((d ,date))
+ (if (equal "" d)
+ '(0 0)
+ (or (get-text-property 0 'gnus-time d)
+ ;; or compute the value...
+ (let ((time (nnmail-date-to-time d)))
+ ;; and store it back in the string.
+ (put-text-property 0 1 'gnus-time time d)
+ time)))))
+
+(defsubst gnus-time-iso8601 (time)
+ "Return a string of TIME in YYMMDDTHHMMSS format."
+ (format-time-string "%Y%m%dT%H%M%S" time))
+
(defun gnus-date-iso8601 (header)
"Convert the date field in HEADER to YYMMDDTHHMMSS"
(condition-case ()
- (format-time-string "%Y%m%dT%H%M%S"
- (nnmail-date-to-time (mail-header-date header)))
+ (gnus-time-iso8601 (gnus-date-get-time (mail-header-date header)))
(error "")))
(defun gnus-mode-string-quote (string)
- "Quote all \"%\" in STRING."
+ "Quote all \"%\"'s in STRING."
(save-excursion
(gnus-set-work-buffer)
(insert string)
(setq i (* 2 i)))
(1- i)))
-(defvar gnus-verbose 7
+(defcustom gnus-verbose 7
"*Integer that says how verbose Gnus should be.
The higher the number, the more messages Gnus will flash to say what
it's doing. At zero, Gnus will be totally mute; at five, Gnus will
display most important messages; and at ten, Gnus will keep on
-jabbering all the time.")
+jabbering all the time."
+ :group 'gnus-start
+ :type 'integer)
;; Show message if message has a lower level than `gnus-verbose'.
;; Guideline for numbers:
(max 0))
;; Find the longest line currently displayed in the window.
(goto-char (window-start))
- (while (and (not (eobp))
+ (while (and (not (eobp))
(< (point) end))
(end-of-line)
(setq max (max max (current-column)))
(interactive
(list (read-file-name "Copy file: " default-directory)
(read-file-name "Copy file to: " default-directory)))
- (or to (setq to (read-file-name "Copy file to: " default-directory)))
- (and (file-directory-p to)
- (setq to (concat (file-name-as-directory to)
- (file-name-nondirectory file))))
+ (unless to
+ (setq to (read-file-name "Copy file to: " default-directory)))
+ (when (file-directory-p to)
+ (setq to (concat (file-name-as-directory to)
+ (file-name-nondirectory file))))
(copy-file file to))
(defun gnus-kill-all-overlays ()
(make-directory directory t))
t)
+(defun gnus-write-buffer (file)
+ "Write the current buffer's contents to FILE."
+ ;; Make sure the directory exists.
+ (gnus-make-directory (file-name-directory file))
+ ;; Write the buffer.
+ (write-region (point-min) (point-max) file nil 'quietly))
+
(defmacro gnus-delete-assq (key list)
`(let ((listval (eval ,list)))
(setq ,list (delq (assq ,key listval) listval))))