Add git support to nndoc.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Tue, 19 Oct 2010 20:24:18 +0000 (22:24 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Tue, 19 Oct 2010 20:24:18 +0000 (22:24 +0200)
lisp/ChangeLog
lisp/nndoc.el

index aa81df1..035dbc3 100644 (file)
@@ -1,5 +1,10 @@
 2010-10-19  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * nndoc.el (nndoc-type-alist): Add git support.
+       (nndoc-git-type-p): New function.
+       (nndoc-transform-git-article): Ditto.
+       (nndoc-transform-git-headers): Ditto.
+
        * shr.el (shr-parse-style): New function.
        (shr-tag-span): Ditto.
 
index 6c9ef1c..5d946f5 100644 (file)
@@ -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)
@@ -234,6 +243,8 @@ from the document.")
              (insert (format "Lines: %d\n" (nth 4 entry)))
              (insert ".\n")))
 
+         (when nndoc-header-transform-function
+           (funcall nndoc-header-transform-function))
          (nnheader-fold-continuation-lines)
          'headers)))))
 
@@ -373,6 +384,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 +661,21 @@ 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 ()
+  (goto-char (point-min))
+  (while (re-search-forward "^Author: " nil t)
+    (replace-match "From: " t t)))
+
 (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))