• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/gnus/

Lines Matching +refs:nndoc +refs:babyl +refs:type

0 ;;; nndoc.el --- single file access for Gnus
41 (nnoo-declare nndoc)
43 (defvoo nndoc-article-type 'guess
45 One of `mbox', `babyl', `digest', `news', `rnews', `mmdf', `forward',
50 (defvoo nndoc-post-type 'mail
51 "*Whether the nndoc group is `mail' or `post'.")
53 (defvoo nndoc-open-document-hook 'nnheader-ms-strip-cr
58 (defvar nndoc-type-alist
70 (generate-head-function . nndoc-generate-mime-parts-head)
71 (article-transform-function . nndoc-transform-mime-parts))
78 (body-end-function . nndoc-rnews-body-end))
80 (article-begin-function . nndoc-mbox-article-begin)
81 (body-end-function . nndoc-mbox-body-end))
82 (babyl
85 (body-begin-function . nndoc-babyl-body-begin)
86 (head-begin-function . nndoc-babyl-head-begin))
89 (body-end-function . nndoc-exim-bounce-body-end-function))
93 (prepare-body-function . nndoc-unquote-dashes))
97 (prepare-body-function . nndoc-unquote-dashes))
103 (generate-head-function . nndoc-generate-clari-briefs-head)
104 (article-transform-function . nndoc-transform-clari-briefs))
109 (prepare-body-function . nndoc-unquote-dashes)
110 (body-end-function . nndoc-digest-body-end)
118 (body-end-function . nndoc-digest-body-end)
121 (prepare-body-function . nndoc-unquote-dashes)
130 (generate-head-function . nndoc-generate-lanl-gov-head)
131 (article-transform-function . nndoc-transform-lanl-gov-announce)
135 (body-end-function . nndoc-rfc822-forward-body-end-function)
136 (generate-head-function . nndoc-rfc822-forward-generate-head)
137 (generate-article-function . nndoc-rfc822-forward-generate-article))
139 (article-begin-function . nndoc-outlook-article-begin)
142 (dissection-function . nndoc-oe-dbx-dissection)
143 (generate-head-function . nndoc-oe-dbx-generate-head)
144 (generate-article-function . nndoc-oe-dbx-generate-article))
148 (prepare-body-function . nndoc-unquote-dashes))
150 (article-begin-function . nndoc-mail-in-mail-article-begin))
161 (defvar nndoc-binary-file-names ".[Dd][Bb][Xx]$"
162 "Regexp for binary nndoc file names.")
166 (defvoo nndoc-file-begin nil)
167 (defvoo nndoc-first-article nil)
168 (defvoo nndoc-article-begin nil)
169 (defvoo nndoc-head-begin nil)
170 (defvoo nndoc-head-end nil)
171 (defvoo nndoc-file-end nil)
172 (defvoo nndoc-body-begin nil)
173 (defvoo nndoc-body-end-function nil)
174 (defvoo nndoc-body-begin-function nil)
175 (defvoo nndoc-head-begin-function nil)
176 (defvoo nndoc-body-end nil)
177 ;; nndoc-dissection-alist is a list of sublists. Each sublist holds the
180 ;; [3] are positions in the `nndoc' buffer. LINE-COUNT [4] is a count of
185 (defvoo nndoc-dissection-alist nil)
186 (defvoo nndoc-prepare-body-function nil)
187 (defvoo nndoc-generate-head-function nil)
188 (defvoo nndoc-article-transform-function nil)
189 (defvoo nndoc-article-begin-function nil)
190 (defvoo nndoc-generate-article-function nil)
191 (defvoo nndoc-dissection-function nil)
193 (defvoo nndoc-status-string "")
194 (defvoo nndoc-group-alist nil)
195 (defvoo nndoc-current-buffer nil
196 "Current nndoc news buffer.")
197 (defvoo nndoc-address nil)
199 (defconst nndoc-version "nndoc 1.0"
200 "nndoc version.")
207 (nnoo-define-basics nndoc)
209 (deffoo nndoc-retrieve-headers (articles &optional newsgroup server fetch-old)
210 (when (nndoc-possibly-change-buffer newsgroup server)
219 nndoc-dissection-alist)))
221 (if nndoc-generate-head-function
222 (funcall nndoc-generate-head-function article)
224 nndoc-current-buffer (car entry) (nth 1 entry)))
234 (deffoo nndoc-request-article (article &optional newsgroup server buffer)
235 (nndoc-possibly-change-buffer newsgroup server)
238 (entry (cdr (assq article nndoc-dissection-alist)))
245 (nndoc-generate-article-function
246 (funcall nndoc-generate-article-function article))
249 nndoc-current-buffer (car entry) (nth 1 entry))
253 nndoc-current-buffer (nth 2 entry) (nth 3 entry))
255 (when nndoc-prepare-body-function
256 (funcall nndoc-prepare-body-function))
257 (when nndoc-article-transform-function
258 (funcall nndoc-article-transform-function article))
261 (deffoo nndoc-request-group (group &optional server dont-check)
265 ((not (nndoc-possibly-change-buffer group server))
266 (nnheader-report 'nndoc "No such file or buffer: %s"
267 nndoc-address))
269 (nnheader-report 'nndoc "Selected group %s" group)
271 ((zerop (setq number (length nndoc-dissection-alist)))
272 (nndoc-close-group group)
273 (nnheader-report 'nndoc "No articles in group %s" group))
277 (deffoo nndoc-request-type (group &optional article)
279 (nndoc-post-type nndoc-post-type)
282 (deffoo nndoc-close-group (group &optional server)
283 (nndoc-possibly-change-buffer group server)
284 (and nndoc-current-buffer
285 (buffer-name nndoc-current-buffer)
286 (kill-buffer nndoc-current-buffer))
287 (setq nndoc-group-alist (delq (assoc group nndoc-group-alist)
288 nndoc-group-alist))
289 (setq nndoc-current-buffer nil)
290 (nnoo-close-server 'nndoc server)
291 (setq nndoc-dissection-alist nil)
294 (deffoo nndoc-request-list (&optional server)
297 (deffoo nndoc-request-newgroups (date &optional server)
300 (deffoo nndoc-request-list-newsgroups (&optional server)
307 (defun nndoc-possibly-change-buffer (group source)
311 ((and nndoc-current-buffer
312 (buffer-name nndoc-current-buffer)
313 (eq nndoc-current-buffer
314 (setq buf (cdr (assoc group nndoc-group-alist))))))
318 (setq nndoc-current-buffer buf))
320 ((or (and (bufferp nndoc-address)
321 (buffer-name nndoc-address))
322 (and (stringp nndoc-address)
323 (file-exists-p nndoc-address)
324 (not (file-directory-p nndoc-address))))
325 (push (cons group (setq nndoc-current-buffer
327 (concat " *nndoc " group "*"))))
328 nndoc-group-alist)
329 (setq nndoc-dissection-alist nil)
331 (set-buffer nndoc-current-buffer)
333 (if (and (stringp nndoc-address)
334 (string-match nndoc-binary-file-names nndoc-address))
336 (mm-insert-file-contents nndoc-address))
337 (if (stringp nndoc-address)
338 (nnheader-insert-file-contents nndoc-address)
339 (insert-buffer-substring nndoc-address))
340 (run-hooks 'nndoc-open-document-hook)))))
341 ;; Initialize the nndoc structures according to this new document.
342 (when (and nndoc-current-buffer
343 (not nndoc-dissection-alist))
345 (set-buffer nndoc-current-buffer)
346 (nndoc-set-delims)
347 (if (eq nndoc-article-type 'mime-parts)
348 (nndoc-dissect-mime-parts)
349 (nndoc-dissect-buffer))))
350 (unless nndoc-current-buffer
351 (nndoc-close-server))
353 nndoc-current-buffer))
356 ;;; Deciding what document type we have
359 (defun nndoc-set-delims ()
360 "Set the nndoc delimiter variables according to the type of the document."
361 (let ((vars '(nndoc-file-begin
362 nndoc-first-article
363 nndoc-article-begin-function
364 nndoc-head-begin nndoc-head-end
365 nndoc-file-end nndoc-article-begin
366 nndoc-body-begin nndoc-body-end-function nndoc-body-end
367 nndoc-prepare-body-function nndoc-article-transform-function
368 nndoc-generate-head-function nndoc-body-begin-function
369 nndoc-head-begin-function
370 nndoc-generate-article-function
371 nndoc-dissection-function)))
375 ;; Guess away until we find the real file type.
376 (while (assq 'guess (setq defs (cdr (assq nndoc-article-type
377 nndoc-type-alist))))
378 (setq nndoc-article-type (nndoc-guess-type nndoc-article-type)))
379 ;; Set the nndoc variables.
381 (set (intern (format "nndoc-%s" (caar defs)))
384 (defun nndoc-guess-type (subtype)
385 (let ((alist nndoc-type-alist)
395 (format "nndoc-%s-type-p"
400 (error "Document is not of any recognized type"))
406 ;;; Built-in type predicates and functions
409 (defun nndoc-mbox-type-p ()
413 (defun nndoc-mbox-article-begin ()
417 (defun nndoc-mbox-body-end ()
436 (defun nndoc-mmdf-type-p ()
440 (defun nndoc-news-type-p ()
444 (defun nndoc-rnews-type-p ()
448 (defun nndoc-rnews-body-end ()
449 (and (re-search-backward nndoc-article-begin nil t)
453 (defun nndoc-babyl-type-p ()
457 (defun nndoc-babyl-body-begin ()
461 (re-search-forward nndoc-article-begin nil t))
469 (defun nndoc-babyl-head-begin ()
475 (defun nndoc-forward-type-p ()
481 (defun nndoc-rfc934-type-p ()
488 (defun nndoc-mailman-type-p ()
492 (defun nndoc-rfc822-forward-type-p ()
498 (defun nndoc-rfc822-forward-body-end-function ()
501 (defun nndoc-rfc822-forward-generate-article (article &optional head)
502 (let ((entry (cdr (assq article nndoc-dissection-alist)))
505 (with-current-buffer nndoc-current-buffer
509 (insert-buffer-substring nndoc-current-buffer (car entry) (nth 3 entry))
521 (defun nndoc-rfc822-forward-generate-head (article)
522 (nndoc-rfc822-forward-generate-article article 'head))
524 (defun nndoc-mime-parts-type-p ()
536 (defun nndoc-transform-mime-parts (article)
537 (let* ((entry (cdr (assq article nndoc-dissection-alist)))
543 (defun nndoc-generate-mime-parts-head (article)
544 (let* ((entry (cdr (assq article nndoc-dissection-alist)))
549 nndoc-current-buffer (car entry) (nth 1 entry))
554 (defun nndoc-clari-briefs-type-p ()
559 (defun nndoc-transform-clari-briefs (article)
563 (nndoc-generate-clari-briefs-head article))
565 (defun nndoc-generate-clari-briefs-head (article)
566 (let ((entry (cdr (assq article nndoc-dissection-alist)))
569 (set-buffer nndoc-current-buffer)
585 (defun nndoc-exim-bounce-type-p ()
589 (defun nndoc-exim-bounce-body-end-function ()
593 (defun nndoc-mime-digest-type-p ()
604 (setq entry (assq 'mime-digest nndoc-type-alist))
611 (cons 'body-end-function 'nndoc-digest-body-end)
615 (defun nndoc-standard-digest-type-p ()
621 (defun nndoc-digest-body-end ()
622 (and (re-search-forward nndoc-article-begin nil t)
625 (defun nndoc-slack-digest-type-p ()
628 (defun nndoc-lanl-gov-announce-type-p ()
633 (defun nndoc-transform-lanl-gov-announce (article)
650 (defun nndoc-generate-lanl-gov-head (article)
651 (let ((entry (cdr (assq article nndoc-dissection-alist)))
655 (set-buffer nndoc-current-buffer)
679 (defun nndoc-nsmail-type-p ()
683 (defun nndoc-outlook-article-begin ()
687 (defun nndoc-outlook-type-p ()
691 (defun nndoc-oe-dbx-type-p ()
694 (defun nndoc-read-little-endian ()
700 (defun nndoc-oe-dbx-decode-block ()
702 (nndoc-read-little-endian) ;; this address
703 (nndoc-read-little-endian) ;; next address offset
704 (nndoc-read-little-endian) ;; blocksize
705 (nndoc-read-little-endian))) ;; next address
707 (defun nndoc-oe-dbx-dissection ()
712 (setq blk (nndoc-oe-dbx-decode-block)))
715 (push (list (incf i) p nil nil nil 0) nndoc-dissection-alist)
718 (setq blk (nndoc-oe-dbx-decode-block)))
728 blk (nndoc-oe-dbx-decode-block)))))))
730 (defun nndoc-oe-dbx-generate-article (article &optional head)
731 (let ((entry (cdr (assq article nndoc-dissection-alist)))
735 (with-current-buffer nndoc-current-buffer
739 (setq blk (nndoc-oe-dbx-decode-block))
742 (insert-buffer-substring nndoc-current-buffer p (+ p (nth 2 blk))))
754 (defun nndoc-oe-dbx-generate-head (article)
755 (nndoc-oe-dbx-generate-article article 'head))
757 (defun nndoc-mail-in-mail-type-p ()
772 (defun nndoc-mail-in-mail-article-begin ()
788 (deffoo nndoc-request-accept-article (group &optional server last)
795 (defun nndoc-search (regexp)
800 (defun nndoc-dissect-buffer ()
805 (setq nndoc-dissection-alist nil)
807 (set-buffer nndoc-current-buffer)
812 (if nndoc-dissection-function
813 (funcall nndoc-dissection-function)
815 (when nndoc-file-begin
816 (nndoc-search nndoc-file-begin))
818 (while (if (and first nndoc-first-article)
819 (nndoc-search nndoc-first-article)
822 (nndoc-article-begin)))
825 (cond (nndoc-head-begin-function
826 (funcall nndoc-head-begin-function))
827 (nndoc-head-begin
828 (nndoc-search nndoc-head-begin)))
830 (and nndoc-file-end
831 (looking-at nndoc-file-end)))
834 (nndoc-search (or nndoc-head-end "^$"))
836 (if nndoc-body-begin-function
837 (funcall nndoc-body-begin-function)
838 (nndoc-search (or nndoc-body-begin "^\n")))
840 (or (and nndoc-body-end-function
841 (funcall nndoc-body-end-function))
842 (and nndoc-body-end
843 (nndoc-search nndoc-body-end))
844 (and (nndoc-article-begin)
848 (when nndoc-file-end
849 (and (re-search-backward nndoc-file-end nil t)
854 nndoc-dissection-alist)))))))
856 (defun nndoc-article-begin ()
857 (if nndoc-article-begin-function
858 (funcall nndoc-article-begin-function)
860 (nndoc-search nndoc-article-begin))))
862 (defun nndoc-unquote-dashes ()
868 (defvar nndoc-mime-split-ordinal)
870 (defun nndoc-dissect-mime-parts ()
874 (setq nndoc-dissection-alist nil
875 nndoc-mime-split-ordinal 0)
877 (set-buffer nndoc-current-buffer)
878 (nndoc-dissect-mime-parts-sub (point-min) (point-max) nil nil nil)))
880 (defun nndoc-dissect-mime-parts-sub (head-begin body-end article-insert
891 subject content-type type subtype boundary-regexp)
903 (setq content-type (message-fetch-field "Content-Type"))
904 (when content-type
906 "^ *\\([^ \t\n/;]+\\)/\\([^ \t\n/;]+\\)" content-type)
907 (setq type (downcase (match-string 1 content-type))
908 subtype (downcase (match-string 2 content-type))
909 message-rfc822 (and (string= type "message")
911 multipart-any (string= type "multipart")))
912 (when (string-match ";[ \t\n]*name=\\([^ \t\n;]+\\)" content-type)
913 (setq subject (match-string 1 content-type)))
914 (when (string-match "boundary=\"?\\([^\"\n]*[^\" \t\n]\\)" content-type)
917 (match-string 1 content-type))
922 (unless type
923 (setq type "text"
940 (cond ((string= subtype "plain") type)
941 ((string= subtype "basic") type)
965 (push (list (incf nndoc-mime-split-ordinal)
969 nndoc-dissection-alist)
975 (nndoc-dissect-mime-parts-sub body-begin body-end nil
999 (nndoc-dissect-mime-parts-sub
1007 (defun nndoc-add-type (definition &optional position)
1008 "Add document DEFINITION to the list of nndoc document definitions.
1014 (gnus-pull (car definition) nndoc-type-alist)
1018 (setq nndoc-type-alist (nconc nndoc-type-alist (list definition))))
1020 (push definition nndoc-type-alist))
1022 (let ((list (memq (assq position nndoc-type-alist)
1023 nndoc-type-alist)))
1028 (provide 'nndoc)
1031 ;;; nndoc.el ends here