aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2018-06-09 11:03:20 +0300
committerEli Zaretskii2018-06-09 11:03:20 +0300
commitca369a8ca67a4cb279a5412cca36109e719a520e (patch)
treec65e52d0a1b68e862bef06adbc53c1a0e3a34be0
parentf716ad94a8b0417d006a86baaa1977a40574407c (diff)
downloademacs-ca369a8ca67a4cb279a5412cca36109e719a520e.tar.gz
emacs-ca369a8ca67a4cb279a5412cca36109e719a520e.zip
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.
-rw-r--r--doc/emacs/rmail.texi33
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/mail/rmailout.el70
3 files changed, 82 insertions, 28 deletions
diff --git a/doc/emacs/rmail.texi b/doc/emacs/rmail.texi
index 068111cab1e..a17ef4938e6 100644
--- a/doc/emacs/rmail.texi
+++ b/doc/emacs/rmail.texi
@@ -529,13 +529,18 @@ file name from the message @samp{Subject} header.
529@kindex C-o @r{(Rmail)} 529@kindex C-o @r{(Rmail)}
530@findex rmail-output-as-seen 530@findex rmail-output-as-seen
531 The commands @kbd{o} and @kbd{C-o} copy the current message into a 531 The commands @kbd{o} and @kbd{C-o} copy the current message into a
532specified file, adding it at the end. The two commands differ mainly 532specified file, adding it at the end. A positive prefix argument
533in how much to copy: @kbd{o} copies the full message headers, even if 533serves as a repeat count: that many consecutive messages will be
534they are not all visible, while @kbd{C-o} copies exactly the headers 534copied to the specified file, starting with the current one and
535currently displayed and no more. @xref{Rmail Display}. In addition, 535ignoring deleted messages.
536@kbd{o} converts the message to Babyl format (used by Rmail in Emacs 536
537version 22 and before) if the file is in Babyl format; @kbd{C-o} 537The two commands differ mainly in how much to copy: @kbd{o} copies the
538cannot output to Babyl files at all. 538full message headers, even if they are not all visible, while
539@kbd{C-o} copies exactly the headers currently displayed and no more.
540@xref{Rmail Display}. In addition, @kbd{o} converts the message to
541Babyl format (used by Rmail in Emacs version 22 and before) if the
542file is in Babyl format; @kbd{C-o} cannot output to Babyl files at
543all.
539@c FIXME remove BABYL mention in some future version? 544@c FIXME remove BABYL mention in some future version?
540 545
541 If the output file is currently visited in an Emacs buffer, the 546 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
565match the regular expression). If no files match, you cannot select 570match the regular expression). If no files match, you cannot select
566this menu item. 571this menu item.
567 572
568@vindex rmail-delete-after-output
569 Copying a message with @kbd{o} or @kbd{C-o} gives the original copy 573 Copying a message with @kbd{o} or @kbd{C-o} gives the original copy
570of the message the @samp{filed} attribute, so that @samp{filed} 574of the message the @samp{filed} attribute, so that @samp{filed}
571appears in the mode line when such a message is current. 575appears in the mode line when such a message is current.
572 576
577@vindex rmail-delete-after-output
573 If you like to keep just a single copy of every mail message, set 578 If you like to keep just a single copy of every mail message, set
574the variable @code{rmail-delete-after-output} to @code{t}; then the 579the variable @code{rmail-delete-after-output} to @code{t}; then the
575@kbd{o}, @kbd{C-o} and @kbd{w} commands delete the original message 580@kbd{o}, @kbd{C-o} and @kbd{w} commands delete the original message
576after copying it. (You can undelete it afterward if you wish, see 581after copying it. (You can undelete it afterward if you wish, see
577@ref{Rmail Deletion}.) 582@ref{Rmail Deletion}.)
578 583
584@vindex rmail-output-reset-deleted-flag
585 By default, @kbd{o} will leave the deleted status of a message it
586outputs as it was on the original message; thus, a message deleted
587before it was output will appear as deleted in the output file.
588Setting the variable @code{rmail-output-reset-deleted-flag} to a
589non-@code{nil} value countermands that: the copy of the message will
590have its deleted status reset, so the message will appear as undeleted
591in the output file. In addition, when this variable is
592non-@code{nil}, specifying a positive argument to @kbd{o} will not
593ignore deleted messages when looking for consecutive messages to
594output.
595
579@vindex rmail-output-file-alist 596@vindex rmail-output-file-alist
580 The variable @code{rmail-output-file-alist} lets you specify 597 The variable @code{rmail-output-file-alist} lets you specify
581intelligent defaults for the output file, based on the contents of the 598intelligent defaults for the output file, based on the contents of the
diff --git a/etc/NEWS b/etc/NEWS
index 3371718473f..4ea34407547 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -482,6 +482,13 @@ It now applies to epg functions as well as epa functions.
482been removed. Use 'encode-coding-string', 'decode-coding-string', and 482been removed. Use 'encode-coding-string', 'decode-coding-string', and
483'select-safe-coding-system' instead. 483'select-safe-coding-system' instead.
484 484
485** Rmail
486
487+++
488*** New user option 'rmail-output-reset-deleted-flag'.
489If this option is non-nil, messages appended to an output file by the
490'rmail-output' command have their Deleted flag reset.
491
485* New Modes and Packages in Emacs 27.1 492* New Modes and Packages in Emacs 27.1
486 493
487+++ 494+++
diff --git a/lisp/mail/rmailout.el b/lisp/mail/rmailout.el
index eee8805ab4c..824b1a59fb9 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."
56 regexp) 56 regexp)
57 :group 'rmail-output) 57 :group 'rmail-output)
58 58
59(defcustom rmail-output-reset-deleted-flag nil
60 "Non-nil means reset the \"deleted\" flag when outputting a message to a file."
61 :type '(choice (const :tag "Output with the \"deleted\" flag reset" t)
62 (const :tag "Output with the \"deleted\" flag intact" nil))
63 :version "27.1"
64 :group 'rmail-output)
65
59(defun rmail-output-read-file-name () 66(defun rmail-output-read-file-name ()
60 "Read the file name to use for `rmail-output'. 67 "Read the file name to use for `rmail-output'.
61Set `rmail-default-file' to this name as well as returning it. 68Set `rmail-default-file' to this name as well as returning it.
@@ -472,9 +479,15 @@ buffer, updates it accordingly.
472This command always outputs the complete message header, even if 479This command always outputs the complete message header, even if
473the header display is currently pruned. 480the header display is currently pruned.
474 481
482If `rmail-output-reset-deleted-flag' is non-nil, the message's
483deleted flag is reset in the message appended to the destination
484file. Otherwise, the appended message will remain marked as
485deleted if it was deleted before invoking this command.
486
475Optional prefix argument COUNT (default 1) says to output that 487Optional prefix argument COUNT (default 1) says to output that
476many consecutive messages, starting with the current one (ignoring 488many consecutive messages, starting with the current one (ignoring
477deleted messages). If `rmail-delete-after-output' is non-nil, deletes 489deleted messages, unless `rmail-output-reset-deleted-flag' is
490non-nil). If `rmail-delete-after-output' is non-nil, deletes
478messages after output. 491messages after output.
479 492
480The optional third argument NOATTRIBUTE, if non-nil, says not to 493The 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."
533 (if (zerop rmail-total-messages) 546 (if (zerop rmail-total-messages)
534 (error "No messages to output")) 547 (error "No messages to output"))
535 (let ((orig-count count) 548 (let ((orig-count count)
536 beg end) 549 beg end delete-attr-reset-p)
537 (while (> count 0) 550 (while (> count 0)
538 (setq beg (rmail-msgbeg rmail-current-message) 551 (when (and rmail-output-reset-deleted-flag
539 end (rmail-msgend rmail-current-message)) 552 (rmail-message-deleted-p rmail-current-message))
540 ;; All access to the buffer's local variables is now finished... 553 (rmail-set-attribute rmail-deleted-attr-index nil)
541 (save-excursion 554 (setq delete-attr-reset-p t))
542 ;; ... so it is ok to go to a different buffer. 555 ;; Make sure we undo our messing with the DELETED attribute.
543 (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer)) 556 (unwind-protect
544 (setq cur (current-buffer)) 557 (progn
545 (save-restriction 558 (setq beg (rmail-msgbeg rmail-current-message)
546 (widen) 559 end (rmail-msgend rmail-current-message))
547 (with-temp-buffer 560 ;; All access to the buffer's local variables is now finished...
548 (insert-buffer-substring cur beg end) 561 (save-excursion
549 (if babyl-format 562 ;; ... so it is ok to go to a different buffer.
550 (rmail-output-as-babyl file-name noattribute) 563 (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer))
551 (rmail-output-as-mbox file-name noattribute))))) 564 (setq cur (current-buffer))
565 (save-restriction
566 (widen)
567 (with-temp-buffer
568 (insert-buffer-substring cur beg end)
569 (if babyl-format
570 (rmail-output-as-babyl file-name noattribute)
571 (rmail-output-as-mbox file-name noattribute))))))
572 (if delete-attr-reset-p
573 (rmail-set-attribute rmail-deleted-attr-index t)))
552 (or noattribute ; mark message as "filed" 574 (or noattribute ; mark message as "filed"
553 (rmail-set-attribute rmail-filed-attr-index t)) 575 (rmail-set-attribute rmail-filed-attr-index t))
554 (setq count (1- count)) 576 (setq count (1- count))
555 (let ((next-message-p 577 (let ((next-message-p
556 (if rmail-delete-after-output 578 (if rmail-output-reset-deleted-flag
557 (rmail-delete-forward) 579 (progn
558 (if (> count 0) 580 (if rmail-delete-after-output
559 (rmail-next-undeleted-message 1)))) 581 (rmail-delete-message))
582 (if (> count 0)
583 (let ((msgnum rmail-current-message))
584 (rmail-next-message 1)
585 (eq rmail-current-message (1+ msgnum)))))
586 (if rmail-delete-after-output
587 (rmail-delete-forward)
588 (if (> count 0)
589 (rmail-next-undeleted-message 1)))))
560 (num-appended (- orig-count count))) 590 (num-appended (- orig-count count)))
561 (if (and (> count 0) (not next-message-p)) 591 (if (and (> count 0) (not next-message-p))
562 (error "Only %d message%s appended" num-appended 592 (error "Only %d message%s appended" num-appended