Output alists with dotted pair notation in .dir-locals.el
[emacs.git] / lisp / gnus / gnus-vm.el
blob24235d9c7184a84260109b8f14d7fdd51ccdc8d0
1 ;;; gnus-vm.el --- vm interface for Gnus
3 ;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
5 ;; Author: Per Persson <pp@gnu.ai.mit.edu>
6 ;; Keywords: news, mail
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;; Major contributors:
26 ;; Christian Limpach <Christian.Limpach@nice.ch>
27 ;; Some code stolen from:
28 ;; Rick Sladkey <jrs@world.std.com>
30 ;;; Code:
32 (require 'sendmail)
33 (require 'message)
34 (require 'gnus)
35 (require 'gnus-msg)
37 (defvar gnus-vm-inhibit-window-system nil
38 "Inhibit loading `win-vm' if using a window-system.
39 Has to be set before gnus-vm is loaded.")
41 (unless gnus-vm-inhibit-window-system
42 (ignore-errors
43 (when window-system
44 (require 'win-vm))))
46 (declare-function vm-mode "ext:vm" (&optional read-only))
48 (defun gnus-vm-make-folder (&optional buffer)
49 (require 'vm)
50 (let ((article (or buffer (current-buffer)))
51 (tmp-folder (generate-new-buffer " *tmp-folder*"))
52 (start (point-min))
53 (end (point-max)))
54 (set-buffer tmp-folder)
55 (insert-buffer-substring article start end)
56 (goto-char (point-min))
57 (if (looking-at "^\\(From [^ ]+ \\).*$")
58 (replace-match (concat "\\1" (current-time-string)))
59 (insert "From " gnus-newsgroup-name " "
60 (current-time-string) "\n"))
61 (while (re-search-forward "\n\nFrom " nil t)
62 (replace-match "\n\n>From "))
63 ;; insert a newline, otherwise the last line gets lost
64 (goto-char (point-max))
65 (insert "\n")
66 (vm-mode)
67 tmp-folder))
69 (defun gnus-summary-save-article-vm (&optional arg)
70 "Append the current article to a vm folder.
71 If N is a positive number, save the N next articles.
72 If N is a negative number, save the N previous articles.
73 If N is nil and any articles have been marked with the process mark,
74 save those articles instead."
75 (interactive "P")
76 (require 'gnus-art)
77 (let ((gnus-default-article-saver 'gnus-summary-save-in-vm))
78 (gnus-summary-save-article arg)))
80 (declare-function vm-save-message "ext:vm-save" (folder &optional count))
82 (defun gnus-summary-save-in-vm (&optional folder)
83 (interactive)
84 (require 'vm)
85 (setq folder
86 (gnus-read-save-file-name
87 "Save %s in VM folder:" folder
88 gnus-mail-save-name gnus-newsgroup-name
89 gnus-current-headers 'gnus-newsgroup-last-mail))
90 (gnus-eval-in-buffer-window gnus-original-article-buffer
91 (save-excursion
92 (save-restriction
93 (widen)
94 (let ((vm-folder (gnus-vm-make-folder)))
95 (vm-save-message folder)
96 (kill-buffer vm-folder))))))
98 (provide 'gnus-vm)
100 ;;; gnus-vm.el ends here