(nnheader-insert-file-contents file)
(nnheader-remove-body)
(setq header (nnheader-parse-naked-head)))
- (mail-header-set-number header (car downloaded))
+ (setf (mail-header-number header) (car downloaded))
(if nov-arts
(let ((key (concat "^" (int-to-string (car nov-arts))
"\t")))
(setq lines-chars (nnheader-get-lines-and-char))
(nnheader-remove-body)
(setq headers (nnheader-parse-naked-head))
- (mail-header-set-number headers number)
- (mail-header-set-lines headers (car lines-chars))
- (mail-header-set-chars headers (cadr lines-chars))
+ (setf (mail-header-number headers) number)
+ (setf (mail-header-lines headers) (car lines-chars))
+ (setf (mail-header-chars headers) (cadr lines-chars))
(gnus-cache-change-buffer group)
(set-buffer (cdr gnus-cache-buffer))
(goto-char (point-max))
(let ((headers gnus-newsgroup-headers))
(if gnus-kill-killed
(setq gnus-newsgroup-kill-headers
- (mapcar (lambda (header) (mail-header-number header))
- headers))
+ (mapcar #'mail-header-number headers))
(while headers
(unless (gnus-member-of-range
(mail-header-number (car headers))
((cond ((fboundp
(setq function
(intern-soft
- (concat "mail-header-" (downcase field)))))
- (setq function `(lambda (h) (,function h))))
+ (concat "mail-header-" (downcase field))))))
((when (setq extras
(member (downcase field)
(mapcar (lambda (header)
(header (if (vectorp header) header
(progn
(setq header (make-mail-header "*****"))
- (mail-header-set-number header 0)
- (mail-header-set-lines header 0)
- (mail-header-set-chars header 0)
+ (setf (mail-header-number header) 0)
+ (setf (mail-header-lines header) 0)
+ (setf (mail-header-chars header) 0)
header)))
(gnus-tmp-from (mail-header-from header))
(gnus-tmp-subject (mail-header-subject header))
"references"
(symbol-name (caar elem)))
(cdar elem)))
- (setcar (car elem)
- `(lambda (h)
- (,func h))))
+ (setcar (car elem) func))
(setq elem (cdr elem)))
(setq malist (cdr malist)))
;; Then we score away.
(add-hook gnus-select-group-hook
(lambda ()
(mapcar (lambda (header)
- (mail-header-set-subject
- header
- (gnus-simplify-subject
- (mail-header-subject header) \\='re-only)))
+ (setf (mail-header-subject header)
+ (gnus-simplify-subject
+ (mail-header-subject header) \\='re-only)))
gnus-newsgroup-headers)))"
:group 'gnus-group-select
:type 'hook)
(setq id-dep (puthash (setq id (nnmail-message-id))
(list header)
dependencies))
- (mail-header-set-id header id))
+ (setf (mail-header-id header) id))
;; The last case ignores an existing entry, except it adds any
;; additional Xrefs (in case the two articles came from different
;; Also sets `header' to nil meaning that the `dependencies'
;; table was *not* modified.
(t
- (mail-header-set-xref
- (car id-dep)
- (concat (or (mail-header-xref (car id-dep))
- "")
- (or (mail-header-xref header) "")))
+ (setf (mail-header-xref (car id-dep))
+ (concat (or (mail-header-xref (car id-dep))
+ "")
+ (or (mail-header-xref header) "")))
(setq header nil)))
(when (and header (not replaced))
;; Yuk! This is a reference loop. Make the article be a
;; root article.
(progn
- (mail-header-set-references (car id-dep) "none")
+ (setf (mail-header-references (car id-dep)) "none")
(setq ref nil)
(setq parent-id nil))
(setq ref (gnus-parent-id (mail-header-references ref-header)))))
(when (and (string= references "")
(setq in-reply-to (mail-header-extra header))
(setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
- (mail-header-set-references
- header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
+ (setf (mail-header-references header)
+ (gnus-extract-message-id-from-in-reply-to in-reply-to)))
(when gnus-alter-header-function
(funcall gnus-alter-header-function header))
(setq subject
(concat (substring subject 0 (match-beginning 1))
(substring subject (match-end 1)))))
- (mail-header-set-subject header subject))))))
+ (setf (mail-header-subject header) subject))))))
(defun gnus-fetch-headers (articles &optional limit force-new dependencies)
"Fetch headers of ARTICLES."
(setq gnus-newsgroup-limit (copy-sequence articles))
;; Remove canceled articles from the list of unread articles.
(setq fetched-articles
- (mapcar (lambda (headers) (mail-header-number headers))
- gnus-newsgroup-headers))
+ (mapcar #'mail-header-number gnus-newsgroup-headers))
(setq gnus-newsgroup-articles fetched-articles)
(setq gnus-newsgroup-unreads
(gnus-sorted-nintersection
(search-forward "\nXref:" nil t))
(goto-char (1+ (match-end 0)))
(setq xref (buffer-substring (point) (point-at-eol)))
- (mail-header-set-xref headers xref)))))))
+ (setf (mail-header-xref headers) xref)))))))
(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
"Find article ID and insert the summary line for that article.
(let ((gnus-newsgroup-headers (list header)))
(gnus-summary-remove-list-identifiers))
(when old-header
- (mail-header-set-number header (mail-header-number old-header)))
+ (setf (mail-header-number header) (mail-header-number old-header)))
(setq gnus-newsgroup-sparse
(delq (setq number (mail-header-number header))
gnus-newsgroup-sparse))
(interactive "P")
(when total
(setq gnus-newsgroup-limits
- (list (mapcar (lambda (h) (mail-header-number h))
- gnus-newsgroup-headers))))
+ (list (mapcar #'mail-header-number gnus-newsgroup-headers))))
(unless gnus-newsgroup-limits
(error "No limit to pop"))
(prog1
(setq gnus-newsgroup-limit (sort gnus-newsgroup-limit #'<))
(let ((articles (gnus-sorted-ndifference
(sort
- (mapcar (lambda (h) (mail-header-number h))
- gnus-newsgroup-headers)
+ (mapcar #'mail-header-number gnus-newsgroup-headers)
#'<)
gnus-newsgroup-limit))
article)
This search includes all articles in the current group that Gnus has
fetched headers for, whether they are displayed or not."
(let ((articles nil)
- ;; FIXME: Can't η-reduce because it's a macro (make it define-inline)
- (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
+ (func (intern (concat "mail-header-" header)))
(case-fold-search t))
(dolist (header gnus-newsgroup-headers)
;; FIXME: when called from gnus-summary-limit-include-thread via
(error "%s is an invalid header" header))
(unless (fboundp (intern (concat "mail-header-" header)))
(error "%s is not a valid header" header))
- ;; FIXME: eta-reduce!
- (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
+ (setq func (intern (concat "mail-header-" header))))
(dolist (d (if (eq backward 'all)
gnus-newsgroup-data
(gnus-data-find-list
;; If we fetched by Message-ID and the article came from
;; a different group (or server), we fudge some bogus
;; article numbers for this article.
- (mail-header-set-number header gnus-reffed-article-number))
+ (setf (mail-header-number header) gnus-reffed-article-number))
(with-current-buffer gnus-summary-buffer
(cl-decf gnus-reffed-article-number)
(gnus-remove-header (mail-header-number header))
"Add a nov line for the GROUP base."
(with-current-buffer (nndiary-open-nov group)
(goto-char (point-max))
- (mail-header-set-number headers article)
+ (setf (mail-header-number headers) article)
(nnheader-insert-nov headers)))
(defsubst nndiary-header-value ()
(goto-char (point-min))
(if (search-forward "\n\n" nil t) (1- (point)) (point-max))))
(let ((headers (nnheader-parse-naked-head)))
- (mail-header-set-chars headers chars)
- (mail-header-set-number headers number)
+ (setf (mail-header-chars headers) chars)
+ (setf (mail-header-number headers) number)
headers))))
(defun nndiary-open-nov (group)
(with-temp-buffer
(insert-buffer-substring buf b e)
(let ((headers (nnheader-parse-naked-head)))
- (mail-header-set-chars headers chars)
- (mail-header-set-number headers number)
+ (setf (mail-header-chars headers) chars)
+ (setf (mail-header-number headers) number)
headers)))))
(defun nnfolder-add-nov (group article headers)
"Add a nov line for the GROUP base."
(with-current-buffer (nnfolder-open-nov group)
(goto-char (point-max))
- (mail-header-set-number headers article)
+ (setf (mail-header-number headers) article)
(nnheader-insert-nov headers)))
(provide 'nnfolder)
;; (That next-to-last entry is defined as "misc" in the NOV format,
;; but Gnus uses it for xrefs.)
-(defmacro mail-header-number (header)
- "Return article number in HEADER."
- `(aref ,header 0))
-
-(defmacro mail-header-set-number (header number)
- "Set article number of HEADER to NUMBER."
- `(aset ,header 0 ,number))
-
-(defmacro mail-header-subject (header)
- "Return subject string in HEADER."
- `(aref ,header 1))
-
-(defmacro mail-header-set-subject (header subject)
- "Set article subject of HEADER to SUBJECT."
- `(aset ,header 1 ,subject))
-
-(defmacro mail-header-from (header)
- "Return author string in HEADER."
- `(aref ,header 2))
-
-(defmacro mail-header-set-from (header from)
- "Set article author of HEADER to FROM."
- `(aset ,header 2 ,from))
-
-(defmacro mail-header-date (header)
- "Return date in HEADER."
- `(aref ,header 3))
-
-(defmacro mail-header-set-date (header date)
- "Set article date of HEADER to DATE."
- `(aset ,header 3 ,date))
-
-(defalias 'mail-header-message-id 'mail-header-id)
-(defmacro mail-header-id (header)
- "Return Id in HEADER."
- `(aref ,header 4))
-
-(defalias 'mail-header-set-message-id 'mail-header-set-id)
-(defmacro mail-header-set-id (header id)
- "Set article Id of HEADER to ID."
- `(aset ,header 4 ,id))
-
-(defmacro mail-header-references (header)
- "Return references in HEADER."
- `(aref ,header 5))
-
-(defmacro mail-header-set-references (header ref)
- "Set article references of HEADER to REF."
- `(aset ,header 5 ,ref))
-
-(defmacro mail-header-chars (header)
- "Return number of chars of article in HEADER."
- `(aref ,header 6))
-
-(defmacro mail-header-set-chars (header chars)
- "Set number of chars in article of HEADER to CHARS."
- `(aset ,header 6 ,chars))
-
-(defmacro mail-header-lines (header)
- "Return lines in HEADER."
- `(aref ,header 7))
-
-(defmacro mail-header-set-lines (header lines)
- "Set article lines of HEADER to LINES."
- `(aset ,header 7 ,lines))
-
-(defmacro mail-header-xref (header)
- "Return xref string in HEADER."
- `(aref ,header 8))
-
-(defmacro mail-header-set-xref (header xref)
- "Set article XREF of HEADER to xref."
- `(aset ,header 8 ,xref))
-
-(defmacro mail-header-extra (header)
- "Return the extra headers in HEADER."
- `(aref ,header 9))
-
-(defun mail-header-set-extra (header extra)
- "Set the extra headers in HEADER to EXTRA."
- (aset header 9 extra))
+(cl-defstruct (mail-header
+ (:type vector)
+ (:constructor nil)
+ (:constructor make-full-mail-header
+ (&optional number subject from date id
+ references chars lines xref
+ extra)))
+ number
+ subject
+ from
+ date
+ id
+ references
+ chars
+ lines
+ xref
+ extra)
+
+(defalias 'mail-header-message-id #'mail-header-id)
(defsubst make-mail-header (&optional init)
"Create a new mail header structure initialized with INIT."
- (make-vector 10 init))
-
-(defsubst make-full-mail-header (&optional number subject from date id
- references chars lines xref
- extra)
- "Create a new mail header structure initialized with the parameters given."
- (vector number subject from date id references chars lines xref extra))
+ (make-full-mail-header init init init init init
+ init init init init init))
;; fake message-ids: generation and detection
(mail-header-number novitem)))
(art (car (rassq artno articleids))))
(when art
- (mail-header-set-number novitem art)
+ (setf (mail-header-number novitem) art)
(push novitem headers))
(forward-line 1)))))
(setq headers
(setq cur (nnheader-parse-nov))
(when corr
(setq article (+ (mail-header-number cur) numc))
- (mail-header-set-number cur article))
+ (setf (mail-header-number cur) article))
(setq xref (mail-header-xref cur))
(when (and (stringp xref)
(string-match (format "[ \t]%s:[0-9]+" backendgroup) xref))
(setq xref (replace-match (format " %s:%d" mairixgroup article) t nil xref))
- (mail-header-set-xref cur xref))
+ (setf (mail-header-xref cur) xref))
(set-buffer buf)
(nnheader-insert-nov cur)
(set-buffer nntp-server-buffer)
"Add a nov line for the GROUP nov headers, incrementally."
(with-current-buffer (nnml-open-incremental-nov group)
(goto-char (point-max))
- (mail-header-set-number headers article)
+ (setf (mail-header-number headers) article)
(nnheader-insert-nov headers)))
(defun nnml-add-nov (group article headers)
"Add a nov line for the GROUP base."
(with-current-buffer (nnml-open-nov group)
(goto-char (point-max))
- (mail-header-set-number headers article)
+ (setf (mail-header-number headers) article)
(nnheader-insert-nov headers)))
(defsubst nnml-header-value ()
(1- (point))
(point-max))))
(let ((headers (nnheader-parse-naked-head)))
- (mail-header-set-chars headers chars)
- (mail-header-set-number headers number)
+ (setf (mail-header-chars headers) chars)
+ (setf (mail-header-number headers) number)
headers))))
(defun nnml-get-nov-buffer (group &optional incrementalp)
(subject (mail-header-subject header))
(rfc2047-encoding-type 'mime))
(when (string-match " \\([^:]+\\)[:/]\\([0-9]+\\)" xref)
- (mail-header-set-xref
- header
- (format "http://article.gmane.org/%s/%s/raw"
- (match-string 1 xref)
- (match-string 2 xref))))
+ (setf (mail-header-xref header)
+ (format "http://article.gmane.org/%s/%s/raw"
+ (match-string 1 xref)
+ (match-string 2 xref))))
;; Add host part to gmane-encrypted addresses
(when (string-match "@$" from)
- (mail-header-set-from header
- (concat from "public.gmane.org")))
+ (setf (mail-header-from header)
+ (concat from "public.gmane.org")))
- (mail-header-set-subject header
- (rfc2047-encode-string subject))
+ (setf (mail-header-subject header)
+ (rfc2047-encode-string subject))
(unless (nnweb-get-hashtb (mail-header-xref header))
- (mail-header-set-number header (cl-incf (cdr active)))
+ (setf (mail-header-number header) (cl-incf (cdr active)))
(push (list (mail-header-number header) header) map)
(nnweb-set-hashtb (cadar map) (car map))))))
(forward-line 1)))