[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master ca369a8: Allow to reset Deleted flag when exporting
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] master ca369a8: Allow to reset Deleted flag when exporting messages in Rmail |
Date: |
Sat, 9 Jun 2018 04:04:39 -0400 (EDT) |
branch: master
commit ca369a8ca67a4cb279a5412cca36109e719a520e
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Allow to reset Deleted flag when exporting messages in Rmail
* lisp/mail/rmailout.el (rmail-output-reset-deleted-flag): New
defcustom.
(rmail-output): When 'rmail-output-reset-deleted-flag' is non-nil,
reset the Deleted flag of the appended messages, and if COUNT is
greater than 1, do not ignore deleted messages. Update the doc
string accordingly. (Bug#31271)
* doc/emacs/rmail.texi (Rmail Output): Document
'rmail-output-reset-deleted-flag'.
* etc/NEWS: Mention the new user option.
---
doc/emacs/rmail.texi | 33 ++++++++++++++++++------
etc/NEWS | 7 ++++++
lisp/mail/rmailout.el | 70 ++++++++++++++++++++++++++++++++++++---------------
3 files changed, 82 insertions(+), 28 deletions(-)
diff --git a/doc/emacs/rmail.texi b/doc/emacs/rmail.texi
index 068111c..a17ef49 100644
--- a/doc/emacs/rmail.texi
+++ b/doc/emacs/rmail.texi
@@ -529,13 +529,18 @@ file name from the message @samp{Subject} header.
@kindex C-o @r{(Rmail)}
@findex rmail-output-as-seen
The commands @kbd{o} and @kbd{C-o} copy the current message into a
-specified file, adding it at the end. The two commands differ mainly
-in how much to copy: @kbd{o} copies the full message headers, even if
-they are not all visible, while @kbd{C-o} copies exactly the headers
-currently displayed and no more. @xref{Rmail Display}. In addition,
address@hidden converts the message to Babyl format (used by Rmail in Emacs
-version 22 and before) if the file is in Babyl format; @kbd{C-o}
-cannot output to Babyl files at all.
+specified file, adding it at the end. A positive prefix argument
+serves as a repeat count: that many consecutive messages will be
+copied to the specified file, starting with the current one and
+ignoring deleted messages.
+
+The two commands differ mainly in how much to copy: @kbd{o} copies the
+full message headers, even if they are not all visible, while
address@hidden copies exactly the headers currently displayed and no more.
address@hidden Display}. In addition, @kbd{o} converts the message to
+Babyl format (used by Rmail in Emacs version 22 and before) if the
+file is in Babyl format; @kbd{C-o} cannot output to Babyl files at
+all.
@c FIXME remove BABYL mention in some future version?
If the output file is currently visited in an Emacs buffer, the
@@ -565,17 +570,29 @@ second says which files in that directory to offer (all
those that
match the regular expression). If no files match, you cannot select
this menu item.
address@hidden rmail-delete-after-output
Copying a message with @kbd{o} or @kbd{C-o} gives the original copy
of the message the @samp{filed} attribute, so that @samp{filed}
appears in the mode line when such a message is current.
address@hidden rmail-delete-after-output
If you like to keep just a single copy of every mail message, set
the variable @code{rmail-delete-after-output} to @code{t}; then the
@kbd{o}, @kbd{C-o} and @kbd{w} commands delete the original message
after copying it. (You can undelete it afterward if you wish, see
@ref{Rmail Deletion}.)
address@hidden rmail-output-reset-deleted-flag
+ By default, @kbd{o} will leave the deleted status of a message it
+outputs as it was on the original message; thus, a message deleted
+before it was output will appear as deleted in the output file.
+Setting the variable @code{rmail-output-reset-deleted-flag} to a
address@hidden value countermands that: the copy of the message will
+have its deleted status reset, so the message will appear as undeleted
+in the output file. In addition, when this variable is
address@hidden, specifying a positive argument to @kbd{o} will not
+ignore deleted messages when looking for consecutive messages to
+output.
+
@vindex rmail-output-file-alist
The variable @code{rmail-output-file-alist} lets you specify
intelligent defaults for the output file, based on the contents of the
diff --git a/etc/NEWS b/etc/NEWS
index 3371718..4ea3440 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -482,6 +482,13 @@ It now applies to epg functions as well as epa functions.
been removed. Use 'encode-coding-string', 'decode-coding-string', and
'select-safe-coding-system' instead.
+** Rmail
+
++++
+*** New user option 'rmail-output-reset-deleted-flag'.
+If this option is non-nil, messages appended to an output file by the
+'rmail-output' command have their Deleted flag reset.
+
* New Modes and Packages in Emacs 27.1
+++
diff --git a/lisp/mail/rmailout.el b/lisp/mail/rmailout.el
index eee8805..824b1a5 100644
--- a/lisp/mail/rmailout.el
+++ b/lisp/mail/rmailout.el
@@ -56,6 +56,13 @@ The function `rmail-delete-unwanted-fields' uses this,
ignoring case."
regexp)
:group 'rmail-output)
+(defcustom rmail-output-reset-deleted-flag nil
+ "Non-nil means reset the \"deleted\" flag when outputting a message to a
file."
+ :type '(choice (const :tag "Output with the \"deleted\" flag reset" t)
+ (const :tag "Output with the \"deleted\" flag intact" nil))
+ :version "27.1"
+ :group 'rmail-output)
+
(defun rmail-output-read-file-name ()
"Read the file name to use for `rmail-output'.
Set `rmail-default-file' to this name as well as returning it.
@@ -472,9 +479,15 @@ buffer, updates it accordingly.
This command always outputs the complete message header, even if
the header display is currently pruned.
+If `rmail-output-reset-deleted-flag' is non-nil, the message's
+deleted flag is reset in the message appended to the destination
+file. Otherwise, the appended message will remain marked as
+deleted if it was deleted before invoking this command.
+
Optional prefix argument COUNT (default 1) says to output that
many consecutive messages, starting with the current one (ignoring
-deleted messages). If `rmail-delete-after-output' is non-nil, deletes
+deleted messages, unless `rmail-output-reset-deleted-flag' is
+non-nil). If `rmail-delete-after-output' is non-nil, deletes
messages after output.
The optional third argument NOATTRIBUTE, if non-nil, says not to
@@ -533,30 +546,47 @@ from a non-Rmail buffer. In this case, COUNT is ignored."
(if (zerop rmail-total-messages)
(error "No messages to output"))
(let ((orig-count count)
- beg end)
+ beg end delete-attr-reset-p)
(while (> count 0)
- (setq beg (rmail-msgbeg rmail-current-message)
- end (rmail-msgend rmail-current-message))
- ;; All access to the buffer's local variables is now finished...
- (save-excursion
- ;; ... so it is ok to go to a different buffer.
- (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer))
- (setq cur (current-buffer))
- (save-restriction
- (widen)
- (with-temp-buffer
- (insert-buffer-substring cur beg end)
- (if babyl-format
- (rmail-output-as-babyl file-name noattribute)
- (rmail-output-as-mbox file-name noattribute)))))
+ (when (and rmail-output-reset-deleted-flag
+ (rmail-message-deleted-p rmail-current-message))
+ (rmail-set-attribute rmail-deleted-attr-index nil)
+ (setq delete-attr-reset-p t))
+ ;; Make sure we undo our messing with the DELETED attribute.
+ (unwind-protect
+ (progn
+ (setq beg (rmail-msgbeg rmail-current-message)
+ end (rmail-msgend rmail-current-message))
+ ;; All access to the buffer's local variables is now finished...
+ (save-excursion
+ ;; ... so it is ok to go to a different buffer.
+ (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer))
+ (setq cur (current-buffer))
+ (save-restriction
+ (widen)
+ (with-temp-buffer
+ (insert-buffer-substring cur beg end)
+ (if babyl-format
+ (rmail-output-as-babyl file-name noattribute)
+ (rmail-output-as-mbox file-name noattribute))))))
+ (if delete-attr-reset-p
+ (rmail-set-attribute rmail-deleted-attr-index t)))
(or noattribute ; mark message as "filed"
(rmail-set-attribute rmail-filed-attr-index t))
(setq count (1- count))
(let ((next-message-p
- (if rmail-delete-after-output
- (rmail-delete-forward)
- (if (> count 0)
- (rmail-next-undeleted-message 1))))
+ (if rmail-output-reset-deleted-flag
+ (progn
+ (if rmail-delete-after-output
+ (rmail-delete-message))
+ (if (> count 0)
+ (let ((msgnum rmail-current-message))
+ (rmail-next-message 1)
+ (eq rmail-current-message (1+ msgnum)))))
+ (if rmail-delete-after-output
+ (rmail-delete-forward)
+ (if (> count 0)
+ (rmail-next-undeleted-message 1)))))
(num-appended (- orig-count count)))
(if (and (> count 0) (not next-message-p))
(error "Only %d message%s appended" num-appended
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master ca369a8: Allow to reset Deleted flag when exporting messages in Rmail,
Eli Zaretskii <=