diff options
| author | Richard M. Stallman | 2014-03-21 19:09:02 -0400 |
|---|---|---|
| committer | Richard M. Stallman | 2014-03-21 19:09:02 -0400 |
| commit | 59271b3e862eb611ae670c9f4d7db00e12f7fcbf (patch) | |
| tree | 91098d3548e742fa7a7351b32a340aae15a9163c | |
| parent | 0d8ac93e1cb206efbc76c213ac8d45d69d150de2 (diff) | |
| download | emacs-59271b3e862eb611ae670c9f4d7db00e12f7fcbf.tar.gz emacs-59271b3e862eb611ae670c9f4d7db00e12f7fcbf.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 14 | ||||
| -rw-r--r-- | lisp/mail/rmail.el | 81 | ||||
| -rw-r--r-- | lisp/mail/rmailsum.el | 80 |
3 files changed, 114 insertions, 61 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bac68960570..7e26346418a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2014-03-21 Richard Stallman <rms@gnu.org> | ||
| 2 | |||
| 3 | * mail/rmailsum.el (rmail-summary-delete-forward): | ||
| 4 | Optimize case of reaching end and handling count. | ||
| 5 | (rmail-summary-mark-deleted): Optimize when N is current msg. | ||
| 6 | Don't create new summary line. | ||
| 7 | (rmail-summary-undelete): Pass arg to rmail-undelete-previous-message. | ||
| 8 | (rmail-summary-undelete-many): Rewrite for speed. | ||
| 9 | (rmail-summary-msg-number): New function. | ||
| 10 | |||
| 11 | * mail/rmail.el (rmail-delete-message): Update summary. | ||
| 12 | (rmail-undelete-previous-message): Handle repeat count arg. | ||
| 13 | (rmail-delete-backward, rmail-delete-forward): Likewise. | ||
| 14 | |||
| 1 | 2014-03-21 Daniel Colascione <dancol@dancol.org> | 15 | 2014-03-21 Daniel Colascione <dancol@dancol.org> |
| 2 | 16 | ||
| 3 | * mail/emacsbug.el (report-emacs-bug): Include memory usage | 17 | * mail/emacsbug.el (report-emacs-bug): Include memory usage |
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 1a016199757..1e444819ed6 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el | |||
| @@ -3449,47 +3449,64 @@ STATE non-nil means mark as deleted." | |||
| 3449 | "Delete this message and stay on it." | 3449 | "Delete this message and stay on it." |
| 3450 | (interactive) | 3450 | (interactive) |
| 3451 | (rmail-set-attribute rmail-deleted-attr-index t) | 3451 | (rmail-set-attribute rmail-deleted-attr-index t) |
| 3452 | (run-hooks 'rmail-delete-message-hook)) | 3452 | (run-hooks 'rmail-delete-message-hook) |
| 3453 | (let ((del-msg rmail-current-message)) | ||
| 3454 | (if (rmail-summary-exists) | ||
| 3455 | (rmail-select-summary | ||
| 3456 | (rmail-summary-mark-deleted del-msg))))) | ||
| 3453 | 3457 | ||
| 3454 | (defun rmail-undelete-previous-message () | 3458 | (defun rmail-undelete-previous-message (count) |
| 3455 | "Back up to deleted message, select it, and undelete it." | 3459 | "Back up to deleted message, select it, and undelete it." |
| 3456 | (interactive) | 3460 | (interactive "p") |
| 3457 | (set-buffer rmail-buffer) | 3461 | (set-buffer rmail-buffer) |
| 3458 | (let ((msg rmail-current-message)) | 3462 | (let (value) |
| 3459 | (while (and (> msg 0) | 3463 | (dotimes (i count) |
| 3460 | (not (rmail-message-deleted-p msg))) | 3464 | (let ((msg rmail-current-message)) |
| 3461 | (setq msg (1- msg))) | 3465 | (while (and (> msg 0) |
| 3462 | (if (= msg 0) | 3466 | (not (rmail-message-deleted-p msg))) |
| 3463 | (error "No previous deleted message") | 3467 | (setq msg (1- msg))) |
| 3464 | (if (/= msg rmail-current-message) | 3468 | (if (= msg 0) |
| 3465 | (rmail-show-message msg)) | 3469 | (error "No previous deleted message") |
| 3466 | (rmail-set-attribute rmail-deleted-attr-index nil) | 3470 | (if (/= msg rmail-current-message) |
| 3467 | (if (rmail-summary-exists) | 3471 | (rmail-show-message msg)) |
| 3468 | (with-current-buffer rmail-summary-buffer | 3472 | (rmail-set-attribute rmail-deleted-attr-index nil) |
| 3469 | (rmail-summary-mark-undeleted msg))) | 3473 | (if (rmail-summary-exists) |
| 3470 | (rmail-maybe-display-summary)))) | 3474 | (with-current-buffer rmail-summary-buffer |
| 3471 | 3475 | (rmail-summary-mark-undeleted msg)))))) | |
| 3472 | (defun rmail-delete-forward (&optional backward) | 3476 | (rmail-maybe-display-summary))) |
| 3477 | |||
| 3478 | (defun rmail-delete-forward (&optional count) | ||
| 3473 | "Delete this message and move to next nondeleted one. | 3479 | "Delete this message and move to next nondeleted one. |
| 3474 | Deleted messages stay in the file until the \\[rmail-expunge] command is given. | 3480 | Deleted messages stay in the file until the \\[rmail-expunge] command is given. |
| 3475 | With prefix argument, delete and move backward. | 3481 | A prefix argument is a repeat count; |
| 3482 | negative argument means move backwards instead of forwards. | ||
| 3476 | 3483 | ||
| 3477 | Returns t if a new message is displayed after the delete, or nil otherwise." | 3484 | Returns t if a new message is displayed after the delete, or nil otherwise." |
| 3478 | (interactive "P") | 3485 | (interactive "p") |
| 3479 | (rmail-set-attribute rmail-deleted-attr-index t) | 3486 | (let (value backward) |
| 3480 | (run-hooks 'rmail-delete-message-hook) | 3487 | (if (< count 0) |
| 3481 | (let ((del-msg rmail-current-message)) | 3488 | (setq count (- count) backward t)) |
| 3482 | (if (rmail-summary-exists) | 3489 | (dotimes (i count) |
| 3483 | (rmail-select-summary | 3490 | (rmail-set-attribute rmail-deleted-attr-index t) |
| 3484 | (rmail-summary-mark-deleted del-msg))) | 3491 | (run-hooks 'rmail-delete-message-hook) |
| 3485 | (prog1 (rmail-next-undeleted-message (if backward -1 1)) | 3492 | (let ((del-msg rmail-current-message)) |
| 3486 | (rmail-maybe-display-summary)))) | 3493 | (if (rmail-summary-exists) |
| 3494 | (rmail-select-summary | ||
| 3495 | (rmail-summary-mark-deleted del-msg))) | ||
| 3496 | (setq value (rmail-next-undeleted-message (if backward -1 1))))) | ||
| 3497 | (rmail-maybe-display-summary) | ||
| 3498 | value)) | ||
| 3487 | 3499 | ||
| 3488 | (defun rmail-delete-backward () | 3500 | (defun rmail-delete-backward (count) |
| 3489 | "Delete this message and move to previous nondeleted one. | 3501 | "Delete this message and move to previous nondeleted one. |
| 3490 | Deleted messages stay in the file until the \\[rmail-expunge] command is given." | 3502 | Deleted messages stay in the file until the \\[rmail-expunge] command is given. |
| 3491 | (interactive) | 3503 | A prefix argument is a repeat count; |
| 3492 | (rmail-delete-forward t)) | 3504 | negative argument means move forwards instead of backwards. |
| 3505 | |||
| 3506 | Returns t if a new message is displayed after the delete, or nil otherwise." | ||
| 3507 | |||
| 3508 | (interactive "p") | ||
| 3509 | (rmail-delete-forward (- count))) | ||
| 3493 | 3510 | ||
| 3494 | ;; Expunging. | 3511 | ;; Expunging. |
| 3495 | 3512 | ||
diff --git a/lisp/mail/rmailsum.el b/lisp/mail/rmailsum.el index cbffb18f69f..2243cf29a87 100644 --- a/lisp/mail/rmailsum.el +++ b/lisp/mail/rmailsum.el | |||
| @@ -914,7 +914,10 @@ a negative argument means to delete and move backward." | |||
| 914 | (unless (numberp count) (setq count 1)) | 914 | (unless (numberp count) (setq count 1)) |
| 915 | (let (end del-msg | 915 | (let (end del-msg |
| 916 | (backward (< count 0))) | 916 | (backward (< count 0))) |
| 917 | (while (/= count 0) | 917 | (while (and (/= count 0) |
| 918 | ;; Don't waste time if we are at the beginning | ||
| 919 | ;; and trying to go backward. | ||
| 920 | (not (and backward (bobp)))) | ||
| 918 | (rmail-summary-goto-msg) | 921 | (rmail-summary-goto-msg) |
| 919 | (with-current-buffer rmail-buffer | 922 | (with-current-buffer rmail-buffer |
| 920 | (rmail-delete-message) | 923 | (rmail-delete-message) |
| @@ -924,11 +927,13 @@ a negative argument means to delete and move backward." | |||
| 924 | (save-excursion (beginning-of-line) | 927 | (save-excursion (beginning-of-line) |
| 925 | (looking-at " *[0-9]+D"))) | 928 | (looking-at " *[0-9]+D"))) |
| 926 | (forward-line (if backward -1 1))) | 929 | (forward-line (if backward -1 1))) |
| 930 | (setq count | ||
| 931 | (if (> count 0) (1- count) (1+ count))) | ||
| 927 | ;; It looks ugly to move to the empty line at end of buffer. | 932 | ;; It looks ugly to move to the empty line at end of buffer. |
| 933 | ;; And don't waste time after hitting the end. | ||
| 928 | (and (eobp) (not backward) | 934 | (and (eobp) (not backward) |
| 929 | (forward-line -1)) | 935 | (progn (setq count 0) |
| 930 | (setq count | 936 | (forward-line -1)))))) |
| 931 | (if (> count 0) (1- count) (1+ count)))))) | ||
| 932 | 937 | ||
| 933 | (defun rmail-summary-delete-backward (&optional count) | 938 | (defun rmail-summary-delete-backward (&optional count) |
| 934 | "Delete this message and move to previous nondeleted one. | 939 | "Delete this message and move to previous nondeleted one. |
| @@ -939,8 +944,9 @@ a negative argument means to delete and move forward." | |||
| 939 | (rmail-summary-delete-forward (- count))) | 944 | (rmail-summary-delete-forward (- count))) |
| 940 | 945 | ||
| 941 | (defun rmail-summary-mark-deleted (&optional n undel) | 946 | (defun rmail-summary-mark-deleted (&optional n undel) |
| 942 | ;; Since third arg is t, this only alters the summary, not the Rmail buf. | 947 | (and n (not (eq n (rmail-summary-msg-number))) |
| 943 | (and n (rmail-summary-goto-msg n t t)) | 948 | ;; Since third arg is t, this only alters summary, not the Rmail buf. |
| 949 | (rmail-summary-goto-msg n t t)) | ||
| 944 | (or (eobp) | 950 | (or (eobp) |
| 945 | (not (overlay-get rmail-summary-overlay 'face)) | 951 | (not (overlay-get rmail-summary-overlay 'face)) |
| 946 | (let ((buffer-read-only nil)) | 952 | (let ((buffer-read-only nil)) |
| @@ -951,9 +957,9 @@ a negative argument means to delete and move forward." | |||
| 951 | (progn (delete-char 1) (insert " "))) | 957 | (progn (delete-char 1) (insert " "))) |
| 952 | (delete-char 1) | 958 | (delete-char 1) |
| 953 | (insert "D")) | 959 | (insert "D")) |
| 954 | ;; Register a new summary line. | 960 | ;; Discard cached new summary line. |
| 955 | (with-current-buffer rmail-buffer | 961 | (with-current-buffer rmail-buffer |
| 956 | (aset rmail-summary-vector (1- n) (rmail-create-summary-line n))))) | 962 | (aset rmail-summary-vector (1- n) nil)))) |
| 957 | (beginning-of-line)) | 963 | (beginning-of-line)) |
| 958 | 964 | ||
| 959 | (defun rmail-summary-update-line (n) | 965 | (defun rmail-summary-update-line (n) |
| @@ -1002,7 +1008,7 @@ Optional prefix ARG means undelete ARG previous messages." | |||
| 1002 | (set-buffer rmail-buffer) | 1008 | (set-buffer rmail-buffer) |
| 1003 | (rmail-pop-to-buffer rmail-buffer)) | 1009 | (rmail-pop-to-buffer rmail-buffer)) |
| 1004 | (and (rmail-message-deleted-p rmail-current-message) | 1010 | (and (rmail-message-deleted-p rmail-current-message) |
| 1005 | (rmail-undelete-previous-message)) | 1011 | (rmail-undelete-previous-message 1)) |
| 1006 | (if rmail-enable-mime | 1012 | (if rmail-enable-mime |
| 1007 | (rmail-pop-to-buffer rmail-buffer)) | 1013 | (rmail-pop-to-buffer rmail-buffer)) |
| 1008 | (rmail-pop-to-buffer rmail-summary-buffer)) | 1014 | (rmail-pop-to-buffer rmail-summary-buffer)) |
| @@ -1011,26 +1017,35 @@ Optional prefix ARG means undelete ARG previous messages." | |||
| 1011 | (defun rmail-summary-undelete-many (&optional n) | 1017 | (defun rmail-summary-undelete-many (&optional n) |
| 1012 | "Undelete all deleted msgs, optional prefix arg N means undelete N prev msgs." | 1018 | "Undelete all deleted msgs, optional prefix arg N means undelete N prev msgs." |
| 1013 | (interactive "P") | 1019 | (interactive "P") |
| 1014 | (with-current-buffer rmail-buffer | 1020 | (if n |
| 1015 | (let* ((init-msg (if n rmail-current-message rmail-total-messages)) | 1021 | (while (and (> n 0) (not (eobp))) |
| 1016 | (rmail-current-message init-msg) | 1022 | (rmail-summary-goto-msg) |
| 1017 | (n (or n rmail-total-messages)) | 1023 | (let (del-msg) |
| 1018 | (msgs-undeled 0)) | 1024 | (when (rmail-summary-deleted-p) |
| 1019 | (while (and (> rmail-current-message 0) | 1025 | (with-current-buffer rmail-buffer |
| 1020 | (< msgs-undeled n)) | 1026 | (rmail-undelete-previous-message 1) |
| 1021 | (if (rmail-message-deleted-p rmail-current-message) | 1027 | (setq del-msg rmail-current-message)) |
| 1022 | (progn (rmail-set-attribute rmail-deleted-attr-index nil) | 1028 | (rmail-summary-mark-undeleted del-msg))) |
| 1023 | (setq msgs-undeled (1+ msgs-undeled)))) | 1029 | (while (and (not (eobp)) |
| 1024 | (setq rmail-current-message (1- rmail-current-message))) | 1030 | (save-excursion (beginning-of-line) |
| 1025 | (set-buffer rmail-summary-buffer) | 1031 | (looking-at " *[0-9]+ "))) |
| 1026 | (setq rmail-current-message init-msg msgs-undeled 0) | 1032 | (forward-line 1)) |
| 1027 | (while (and (> rmail-current-message 0) | 1033 | (setq n (1- n))) |
| 1028 | (< msgs-undeled n)) | 1034 | (rmail-summary-goto-msg 1) |
| 1029 | (if (rmail-summary-deleted-p rmail-current-message) | 1035 | (dotimes (i rmail-total-messages) |
| 1030 | (progn (rmail-summary-mark-undeleted rmail-current-message) | 1036 | (rmail-summary-goto-msg) |
| 1031 | (setq msgs-undeled (1+ msgs-undeled)))) | 1037 | (let (del-msg) |
| 1032 | (setq rmail-current-message (1- rmail-current-message)))) | 1038 | (when (rmail-summary-deleted-p) |
| 1033 | (rmail-summary-goto-msg))) | 1039 | (with-current-buffer rmail-buffer |
| 1040 | (rmail-undelete-previous-message 1) | ||
| 1041 | (setq del-msg rmail-current-message)) | ||
| 1042 | (rmail-summary-mark-undeleted del-msg))) | ||
| 1043 | (if (not (eobp)) | ||
| 1044 | (forward-line 1)))) | ||
| 1045 | |||
| 1046 | ;; It looks ugly to move to the empty line at end of buffer. | ||
| 1047 | (and (eobp) | ||
| 1048 | (forward-line -1))) | ||
| 1034 | 1049 | ||
| 1035 | ;; Rmail Summary mode is suitable only for specially formatted data. | 1050 | ;; Rmail Summary mode is suitable only for specially formatted data. |
| 1036 | (put 'rmail-summary-mode 'mode-class 'special) | 1051 | (put 'rmail-summary-mode 'mode-class 'special) |
| @@ -1188,6 +1203,13 @@ Search, the `unseen' attribute is restored.") | |||
| 1188 | (goto-char (posn-point (event-end event))) | 1203 | (goto-char (posn-point (event-end event))) |
| 1189 | (rmail-summary-goto-msg)) | 1204 | (rmail-summary-goto-msg)) |
| 1190 | 1205 | ||
| 1206 | (defun rmail-summary-msg-number () | ||
| 1207 | (save-excursion | ||
| 1208 | (beginning-of-line) | ||
| 1209 | (string-to-number | ||
| 1210 | (buffer-substring (point) | ||
| 1211 | (min (point-max) (+ 6 (point))))))) | ||
| 1212 | |||
| 1191 | (defun rmail-summary-goto-msg (&optional n nowarn skip-rmail) | 1213 | (defun rmail-summary-goto-msg (&optional n nowarn skip-rmail) |
| 1192 | "Go to message N in the summary buffer and the Rmail buffer. | 1214 | "Go to message N in the summary buffer and the Rmail buffer. |
| 1193 | If N is nil, use the message corresponding to point in the summary | 1215 | If N is nil, use the message corresponding to point in the summary |