[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r116833: Make Rmail delete and undelete commands han
From: |
Richard M. Stallman |
Subject: |
[Emacs-diffs] trunk r116833: Make Rmail delete and undelete commands handle repeat count. |
Date: |
Fri, 21 Mar 2014 23:12:59 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 116833
revision-id: address@hidden
parent: address@hidden
author: Richard Stallman
committer: Richard Stallman <address@hidden>
branch nick: trunk
timestamp: Fri 2014-03-21 19:09:02 -0400
message:
Make Rmail delete and undelete commands handle repeat count.
* lisp/mail/rmail.el (rmail-delete-message): Update summary.
(rmail-undelete-previous-message): Handle repeat count arg.
(rmail-delete-backward, rmail-delete-forward): Likewise.
* lisp/mail/rmailsum.el (rmail-summary-delete-forward):
Optimize case of reaching end and handling count.
(rmail-summary-mark-deleted): Optimize when N is current msg.
Don't create new summary line.
(rmail-summary-undelete): Pass arg to rmail-undelete-previous-message.
(rmail-summary-undelete-many): Rewrite for speed.
(rmail-summary-msg-number): New function.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/mail/rmail.el rmail.el-20091113204419-o5vbwnq5f7feedwu-8812
lisp/mail/rmailsum.el
rmailsum.el-20091113204419-o5vbwnq5f7feedwu-8819
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2014-03-21 21:27:25 +0000
+++ b/lisp/ChangeLog 2014-03-21 23:09:02 +0000
@@ -1,3 +1,17 @@
+2014-03-21 Richard Stallman <address@hidden>
+
+ * mail/rmailsum.el (rmail-summary-delete-forward):
+ Optimize case of reaching end and handling count.
+ (rmail-summary-mark-deleted): Optimize when N is current msg.
+ Don't create new summary line.
+ (rmail-summary-undelete): Pass arg to rmail-undelete-previous-message.
+ (rmail-summary-undelete-many): Rewrite for speed.
+ (rmail-summary-msg-number): New function.
+
+ * mail/rmail.el (rmail-delete-message): Update summary.
+ (rmail-undelete-previous-message): Handle repeat count arg.
+ (rmail-delete-backward, rmail-delete-forward): Likewise.
+
2014-03-21 Daniel Colascione <address@hidden>
* mail/emacsbug.el (report-emacs-bug): Include memory usage
=== modified file 'lisp/mail/rmail.el'
--- a/lisp/mail/rmail.el 2014-02-13 18:23:36 +0000
+++ b/lisp/mail/rmail.el 2014-03-21 23:09:02 +0000
@@ -3449,47 +3449,64 @@
"Delete this message and stay on it."
(interactive)
(rmail-set-attribute rmail-deleted-attr-index t)
- (run-hooks 'rmail-delete-message-hook))
-
-(defun rmail-undelete-previous-message ()
- "Back up to deleted message, select it, and undelete it."
- (interactive)
- (set-buffer rmail-buffer)
- (let ((msg rmail-current-message))
- (while (and (> msg 0)
- (not (rmail-message-deleted-p msg)))
- (setq msg (1- msg)))
- (if (= msg 0)
- (error "No previous deleted message")
- (if (/= msg rmail-current-message)
- (rmail-show-message msg))
- (rmail-set-attribute rmail-deleted-attr-index nil)
- (if (rmail-summary-exists)
- (with-current-buffer rmail-summary-buffer
- (rmail-summary-mark-undeleted msg)))
- (rmail-maybe-display-summary))))
-
-(defun rmail-delete-forward (&optional backward)
- "Delete this message and move to next nondeleted one.
-Deleted messages stay in the file until the \\[rmail-expunge] command is given.
-With prefix argument, delete and move backward.
-
-Returns t if a new message is displayed after the delete, or nil otherwise."
- (interactive "P")
- (rmail-set-attribute rmail-deleted-attr-index t)
(run-hooks 'rmail-delete-message-hook)
(let ((del-msg rmail-current-message))
(if (rmail-summary-exists)
(rmail-select-summary
- (rmail-summary-mark-deleted del-msg)))
- (prog1 (rmail-next-undeleted-message (if backward -1 1))
- (rmail-maybe-display-summary))))
-
-(defun rmail-delete-backward ()
+ (rmail-summary-mark-deleted del-msg)))))
+
+(defun rmail-undelete-previous-message (count)
+ "Back up to deleted message, select it, and undelete it."
+ (interactive "p")
+ (set-buffer rmail-buffer)
+ (let (value)
+ (dotimes (i count)
+ (let ((msg rmail-current-message))
+ (while (and (> msg 0)
+ (not (rmail-message-deleted-p msg)))
+ (setq msg (1- msg)))
+ (if (= msg 0)
+ (error "No previous deleted message")
+ (if (/= msg rmail-current-message)
+ (rmail-show-message msg))
+ (rmail-set-attribute rmail-deleted-attr-index nil)
+ (if (rmail-summary-exists)
+ (with-current-buffer rmail-summary-buffer
+ (rmail-summary-mark-undeleted msg))))))
+ (rmail-maybe-display-summary)))
+
+(defun rmail-delete-forward (&optional count)
+ "Delete this message and move to next nondeleted one.
+Deleted messages stay in the file until the \\[rmail-expunge] command is given.
+A prefix argument is a repeat count;
+negative argument means move backwards instead of forwards.
+
+Returns t if a new message is displayed after the delete, or nil otherwise."
+ (interactive "p")
+ (let (value backward)
+ (if (< count 0)
+ (setq count (- count) backward t))
+ (dotimes (i count)
+ (rmail-set-attribute rmail-deleted-attr-index t)
+ (run-hooks 'rmail-delete-message-hook)
+ (let ((del-msg rmail-current-message))
+ (if (rmail-summary-exists)
+ (rmail-select-summary
+ (rmail-summary-mark-deleted del-msg)))
+ (setq value (rmail-next-undeleted-message (if backward -1 1)))))
+ (rmail-maybe-display-summary)
+ value))
+
+(defun rmail-delete-backward (count)
"Delete this message and move to previous nondeleted one.
-Deleted messages stay in the file until the \\[rmail-expunge] command is
given."
- (interactive)
- (rmail-delete-forward t))
+Deleted messages stay in the file until the \\[rmail-expunge] command is given.
+A prefix argument is a repeat count;
+negative argument means move forwards instead of backwards.
+
+Returns t if a new message is displayed after the delete, or nil otherwise."
+
+ (interactive "p")
+ (rmail-delete-forward (- count)))
;; Expunging.
=== modified file 'lisp/mail/rmailsum.el'
--- a/lisp/mail/rmailsum.el 2014-02-10 01:34:22 +0000
+++ b/lisp/mail/rmailsum.el 2014-03-21 23:09:02 +0000
@@ -914,7 +914,10 @@
(unless (numberp count) (setq count 1))
(let (end del-msg
(backward (< count 0)))
- (while (/= count 0)
+ (while (and (/= count 0)
+ ;; Don't waste time if we are at the beginning
+ ;; and trying to go backward.
+ (not (and backward (bobp))))
(rmail-summary-goto-msg)
(with-current-buffer rmail-buffer
(rmail-delete-message)
@@ -924,11 +927,13 @@
(save-excursion (beginning-of-line)
(looking-at " *[0-9]+D")))
(forward-line (if backward -1 1)))
+ (setq count
+ (if (> count 0) (1- count) (1+ count)))
;; It looks ugly to move to the empty line at end of buffer.
+ ;; And don't waste time after hitting the end.
(and (eobp) (not backward)
- (forward-line -1))
- (setq count
- (if (> count 0) (1- count) (1+ count))))))
+ (progn (setq count 0)
+ (forward-line -1))))))
(defun rmail-summary-delete-backward (&optional count)
"Delete this message and move to previous nondeleted one.
@@ -939,8 +944,9 @@
(rmail-summary-delete-forward (- count)))
(defun rmail-summary-mark-deleted (&optional n undel)
- ;; Since third arg is t, this only alters the summary, not the Rmail buf.
- (and n (rmail-summary-goto-msg n t t))
+ (and n (not (eq n (rmail-summary-msg-number)))
+ ;; Since third arg is t, this only alters summary, not the Rmail buf.
+ (rmail-summary-goto-msg n t t))
(or (eobp)
(not (overlay-get rmail-summary-overlay 'face))
(let ((buffer-read-only nil))
@@ -951,9 +957,9 @@
(progn (delete-char 1) (insert " ")))
(delete-char 1)
(insert "D"))
- ;; Register a new summary line.
+ ;; Discard cached new summary line.
(with-current-buffer rmail-buffer
- (aset rmail-summary-vector (1- n) (rmail-create-summary-line n)))))
+ (aset rmail-summary-vector (1- n) nil))))
(beginning-of-line))
(defun rmail-summary-update-line (n)
@@ -1002,7 +1008,7 @@
(set-buffer rmail-buffer)
(rmail-pop-to-buffer rmail-buffer))
(and (rmail-message-deleted-p rmail-current-message)
- (rmail-undelete-previous-message))
+ (rmail-undelete-previous-message 1))
(if rmail-enable-mime
(rmail-pop-to-buffer rmail-buffer))
(rmail-pop-to-buffer rmail-summary-buffer))
@@ -1011,26 +1017,35 @@
(defun rmail-summary-undelete-many (&optional n)
"Undelete all deleted msgs, optional prefix arg N means undelete N prev
msgs."
(interactive "P")
- (with-current-buffer rmail-buffer
- (let* ((init-msg (if n rmail-current-message rmail-total-messages))
- (rmail-current-message init-msg)
- (n (or n rmail-total-messages))
- (msgs-undeled 0))
- (while (and (> rmail-current-message 0)
- (< msgs-undeled n))
- (if (rmail-message-deleted-p rmail-current-message)
- (progn (rmail-set-attribute rmail-deleted-attr-index nil)
- (setq msgs-undeled (1+ msgs-undeled))))
- (setq rmail-current-message (1- rmail-current-message)))
- (set-buffer rmail-summary-buffer)
- (setq rmail-current-message init-msg msgs-undeled 0)
- (while (and (> rmail-current-message 0)
- (< msgs-undeled n))
- (if (rmail-summary-deleted-p rmail-current-message)
- (progn (rmail-summary-mark-undeleted rmail-current-message)
- (setq msgs-undeled (1+ msgs-undeled))))
- (setq rmail-current-message (1- rmail-current-message))))
- (rmail-summary-goto-msg)))
+ (if n
+ (while (and (> n 0) (not (eobp)))
+ (rmail-summary-goto-msg)
+ (let (del-msg)
+ (when (rmail-summary-deleted-p)
+ (with-current-buffer rmail-buffer
+ (rmail-undelete-previous-message 1)
+ (setq del-msg rmail-current-message))
+ (rmail-summary-mark-undeleted del-msg)))
+ (while (and (not (eobp))
+ (save-excursion (beginning-of-line)
+ (looking-at " *[0-9]+ ")))
+ (forward-line 1))
+ (setq n (1- n)))
+ (rmail-summary-goto-msg 1)
+ (dotimes (i rmail-total-messages)
+ (rmail-summary-goto-msg)
+ (let (del-msg)
+ (when (rmail-summary-deleted-p)
+ (with-current-buffer rmail-buffer
+ (rmail-undelete-previous-message 1)
+ (setq del-msg rmail-current-message))
+ (rmail-summary-mark-undeleted del-msg)))
+ (if (not (eobp))
+ (forward-line 1))))
+
+ ;; It looks ugly to move to the empty line at end of buffer.
+ (and (eobp)
+ (forward-line -1)))
;; Rmail Summary mode is suitable only for specially formatted data.
(put 'rmail-summary-mode 'mode-class 'special)
@@ -1188,6 +1203,13 @@
(goto-char (posn-point (event-end event)))
(rmail-summary-goto-msg))
+(defun rmail-summary-msg-number ()
+ (save-excursion
+ (beginning-of-line)
+ (string-to-number
+ (buffer-substring (point)
+ (min (point-max) (+ 6 (point)))))))
+
(defun rmail-summary-goto-msg (&optional n nowarn skip-rmail)
"Go to message N in the summary buffer and the Rmail buffer.
If N is nil, use the message corresponding to point in the summary
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r116833: Make Rmail delete and undelete commands handle repeat count.,
Richard M. Stallman <=