summaryrefslogtreecommitdiff
path: root/lisp/gnus/nndoc.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/gnus/nndoc.el')
-rw-r--r--lisp/gnus/nndoc.el64
1 files changed, 52 insertions, 12 deletions
diff --git a/lisp/gnus/nndoc.el b/lisp/gnus/nndoc.el
index 6c9ef1cef87..0dee06d2937 100644
--- a/lisp/gnus/nndoc.el
+++ b/lisp/gnus/nndoc.el
@@ -138,6 +138,14 @@ from the document.")
(generate-head-function . nndoc-generate-lanl-gov-head)
(article-transform-function . nndoc-transform-lanl-gov-announce)
(subtype preprints guess))
+ (git
+ (file-begin . "\n- Log ---.*")
+ (article-begin . "^commit ")
+ (head-begin . "^Author: ")
+ (body-begin . "^$")
+ (file-end . "\n-----------------------------------------------------------------------")
+ (article-transform-function . nndoc-transform-git-article)
+ (header-transform-function . nndoc-transform-git-headers))
(rfc822-forward
(article-begin . "^\n+")
(body-end-function . nndoc-rfc822-forward-body-end-function)
@@ -193,6 +201,7 @@ from the document.")
(defvoo nndoc-prepare-body-function nil)
(defvoo nndoc-generate-head-function nil)
(defvoo nndoc-article-transform-function nil)
+(defvoo nndoc-header-transform-function nil)
(defvoo nndoc-article-begin-function nil)
(defvoo nndoc-generate-article-function nil)
(defvoo nndoc-dissection-function nil)
@@ -223,17 +232,22 @@ from the document.")
(while articles
(when (setq entry (cdr (assq (setq article (pop articles))
nndoc-dissection-alist)))
- (insert (format "221 %d Article retrieved.\n" article))
- (if nndoc-generate-head-function
- (funcall nndoc-generate-head-function article)
- (insert-buffer-substring
- nndoc-current-buffer (car entry) (nth 1 entry)))
- (goto-char (point-max))
- (unless (eq (char-after (1- (point))) ?\n)
- (insert "\n"))
- (insert (format "Lines: %d\n" (nth 4 entry)))
- (insert ".\n")))
-
+ (let ((start (point)))
+ (insert (format "221 %d Article retrieved.\n" article))
+ (if nndoc-generate-head-function
+ (funcall nndoc-generate-head-function article)
+ (insert-buffer-substring
+ nndoc-current-buffer (car entry) (nth 1 entry)))
+ (goto-char (point-max))
+ (unless (eq (char-after (1- (point))) ?\n)
+ (insert "\n"))
+ (insert (format "Lines: %d\n" (nth 4 entry)))
+ (insert ".\n")
+ (when nndoc-header-transform-function
+ (save-excursion
+ (save-restriction
+ (narrow-to-region start (point))
+ (funcall nndoc-header-transform-function entry)))))))
(nnheader-fold-continuation-lines)
'headers)))))
@@ -373,6 +387,7 @@ from the document.")
nndoc-file-end nndoc-article-begin
nndoc-body-begin nndoc-body-end-function nndoc-body-end
nndoc-prepare-body-function nndoc-article-transform-function
+ nndoc-header-transform-function
nndoc-generate-head-function nndoc-body-begin-function
nndoc-head-begin-function
nndoc-generate-article-function
@@ -649,6 +664,30 @@ from the document.")
(defun nndoc-slack-digest-type-p ()
0)
+(defun nndoc-git-type-p ()
+ (and (search-forward "\n- Log ---" nil t)
+ (search-forward "\ncommit " nil t)
+ (search-forward "\nAuthor: " nil t)))
+
+(defun nndoc-transform-git-article (article)
+ (goto-char (point-min))
+ (when (re-search-forward "^Author: " nil t)
+ (replace-match "From: " t t)))
+
+(defun nndoc-transform-git-headers (entry)
+ (goto-char (point-min))
+ (when (re-search-forward "^Author: " nil t)
+ (replace-match "From: " t t))
+ (let (subject)
+ (with-current-buffer nndoc-current-buffer
+ (goto-char (car entry))
+ (when (search-forward "\n\n" nil t)
+ (setq subject (buffer-substring (point) (line-end-position)))))
+ (when subject
+ (goto-char (point-min))
+ (forward-line 1)
+ (insert (format "Subject: %s\n" subject)))))
+
(defun nndoc-lanl-gov-announce-type-p ()
(when (let ((case-fold-search nil))
(re-search-forward "^\\\\\\\\\n\\(Paper\\( (\\*cross-listing\\*)\\)?: [a-zA-Z-\\.]+/[0-9]+\\|arXiv:\\)" nil t))
@@ -879,7 +918,8 @@ from the document.")
(setq body-end (point))
(push (list (incf i) head-begin head-end body-begin body-end
(count-lines body-begin body-end))
- nndoc-dissection-alist)))))))
+ nndoc-dissection-alist)))))
+ (setq nndoc-dissection-alist (nreverse nndoc-dissection-alist))))
(defun nndoc-article-begin ()
(if nndoc-article-begin-function