Gnus development mailing list
 help / color / mirror / Atom feed
* PATCH: Overwrite files when saving
@ 1996-10-18  8:18 Kees de Bruin
  0 siblings, 0 replies; only message in thread
From: Kees de Bruin @ 1996-10-18  8:18 UTC (permalink / raw)
  Cc: Lars Magne Ingebrigtsen

When saving articles to a mail file, it would be nice that we can replace
the current file for a new one. This is handy when FAQ files are archived,
but has also got some other uses. I have copied the definition of the
function `gnus-summary-save-in-mail' to create a new function and added the
correct bindings in the summary keymap. I can now use "O a" to archive the
message while replacing any existing ones. Here's the patch against Red
Gnus v0.52:

-----[ rgnus-0.52.diff ]---------------------------------------------------
--- lisp/gnus-art.el.orig	Fri Oct 18 09:42:34 1996
+++ lisp/gnus-art.el	Fri Oct 18 09:48:55 1996
@@ -73,14 +73,16 @@
 * gnus-summary-save-in-rmail (Rmail format)
 * gnus-summary-save-in-mail (Unix mail format)
 * gnus-summary-save-in-folder (MH folder)
-* gnus-summary-save-in-file (article format).
-* gnus-summary-save-in-vm (use VM's folder format)."
+* gnus-summary-save-in-file (article format)
+* gnus-summary-save-in-vm (use VM's folder format)
+* gnus-summary-save-in-mail-overwrite (Unix mail format)."
   :group 'article
   :type '(radio (function-item gnus-summary-save-in-rmail)
 		(function-item gnus-summary-save-in-mail)
 		(function-item gnus-summary-save-in-folder)
 		(function-item gnus-summary-save-in-file)
-		(function-item gnus-summary-save-in-vm)))
+		(function-item gnus-summary-save-in-vm)
+		(function-item gnus-summary-save-in-mail-overwrite)))
 
 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
   "A function generating a file name to save articles in Rmail format.
@@ -470,6 +472,33 @@
 	      (gnus-output-to-rmail filename)
 	    (let ((mail-use-rfc822 t))
 	      (rmail-output filename 1 t t))))))
+    ;; Remember the directory name to save articles.
+    (setq gnus-newsgroup-last-mail filename)))
+
+(defun gnus-summary-save-in-mail-overwrite (&optional filename)
+  "Save this article to Unix mail file and overwrite any existing file.
+Optional argument FILENAME specifies file name.
+Directory to save to is default to `gnus-article-save-directory'."
+  (interactive)
+  (gnus-set-global-variables)
+  (let ((default-name
+	  (funcall gnus-mail-save-name gnus-newsgroup-name
+		   gnus-current-headers gnus-newsgroup-last-mail)))
+    (setq filename (gnus-read-save-file-name
+		    "Save %s in Unix mail file:" default-name filename))
+    (setq filename
+	  (expand-file-name filename
+			    (and default-name
+				 (file-name-directory default-name))))
+    (gnus-make-directory (file-name-directory filename))
+    (gnus-eval-in-buffer-window gnus-original-article-buffer
+      (save-excursion
+	(save-restriction
+	  (widen)
+	  (if (file-exists-p filename)
+	      (delete-file filename))
+	  (let ((mail-use-rfc822 t))
+	    (rmail-output filename 1 t t)))))
     ;; Remember the directory name to save articles.
     (setq gnus-newsgroup-last-mail filename)))
 
--- lisp/gnus-sum.el.orig	Fri Oct 18 09:51:38 1996
+++ lisp/gnus-sum.el	Fri Oct 18 09:53:38 1996
@@ -1494,6 +1494,7 @@
   (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
     "o" gnus-summary-save-article
     "m" gnus-summary-save-article-mail
+    "a" gnus-summary-save-article-mail-overwrite
     "r" gnus-summary-save-article-rmail
     "f" gnus-summary-save-article-file
     "b" gnus-summary-save-article-body-file
@@ -1685,6 +1686,7 @@
 	["Save in default format" gnus-summary-save-article t]
 	["Save in file" gnus-summary-save-article-file t]
 	["Save in Unix mail format" gnus-summary-save-article-mail t]
+	["Replace in Unix mail format" gnus-summary-save-article-mail-overwrite t]
 	["Save in MH folder" gnus-summary-save-article-folder t]
 	["Save in VM folder" gnus-summary-save-article-vm t]
 	["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
@@ -7959,6 +7961,17 @@
   (interactive "P")
   (gnus-set-global-variables)
   (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
+    (gnus-summary-save-article arg)))
+
+(defun gnus-summary-save-article-mail-overwrite (&optional arg)
+  "Save the current article to an mail file replacing old file.
+If N is a positive number, save the N next articles.
+If N is a negative number, save the N previous articles.
+If N is nil and any articles have been marked with the process mark,
+save those articles instead."
+  (interactive "P")
+  (gnus-set-global-variables)
+  (let ((gnus-default-article-saver 'gnus-summary-save-in-mail-overwrite))
     (gnus-summary-save-article arg)))
 
 (defun gnus-summary-save-article-rmail (&optional arg)
-----[ end-of-file ]-------------------------------------------------------

Kind regards,

-- 
Kees de Bruin                                           Tasking Software BV
Software Engineer
---------------------------------------------------------------------------
telephone:  +31 33 455 85 84                            Tasking Software BV
fax:        +31 33 455 10 05                            Plotterweg 31
email:      kees_de_bruin@tasking.com                   3821 BB  Amersfoort
WWW:        http://www.tasking.com                      The Netherlands
CompuServe: GO TASKING
---------------------------------------------------------------------------
	     -----  Quality Development Tools Worldwide  -----
		    -----------------------------------


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-10-18  8:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-18  8:18 PATCH: Overwrite files when saving Kees de Bruin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).