aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2022-10-27 17:15:51 +0300
committerEli Zaretskii2022-10-27 17:15:51 +0300
commit582eaadde7d1cdbea4f8c813d6932a9caec482c7 (patch)
tree6ff215d5d2495e92d5792d4d9ff95465997ddf9c
parentc8b9ba5fa1bf3a20b9b08a553ad088ca33f3d1ba (diff)
downloademacs-582eaadde7d1cdbea4f8c813d6932a9caec482c7.tar.gz
emacs-582eaadde7d1cdbea4f8c813d6932a9caec482c7.zip
Revert "Allow applying filters to summary consecutively"
This reverts commit c8b9ba5fa1bf3a20b9b08a553ad088ca33f3d1ba.
-rw-r--r--etc/NEWS12
-rw-r--r--lisp/mail/rmailsum.el134
2 files changed, 24 insertions, 122 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 21907c7ffba..cbbf90fde67 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2051,18 +2051,6 @@ Formerly it was a pair of numbers '(A B)' that represented 65536*A + B,
2051to cater to older Emacs implementations that lacked bignums. 2051to cater to older Emacs implementations that lacked bignums.
2052The older form still works but is undocumented. 2052The older form still works but is undocumented.
2053 2053
2054** Rmail
2055
2056---
2057*** Rmail partial summaries can now be applied one on top of the other.
2058You can now narrow the filtering of messages by the summary's criteria
2059(recipients, topic, senders, etc.) by making a summary of the already
2060summarized messages. For example, invoking 'rmail-summary-by-senders',
2061followed by 'rmail-summary-by-topic' will produce a summary where both
2062the senders and the topic are according to your selection. Most Rmail
2063summary commands can be told to filter the existing summary by
2064invoking them with the prefix argument.
2065
2066** EIEIO 2054** EIEIO
2067 2055
2068+++ 2056+++
diff --git a/lisp/mail/rmailsum.el b/lisp/mail/rmailsum.el
index 4e5b3d0904d..b959f45250e 100644
--- a/lisp/mail/rmailsum.el
+++ b/lisp/mail/rmailsum.el
@@ -50,13 +50,6 @@ Setting this option to nil might speed up the generation of summaries."
50 :type 'boolean 50 :type 'boolean
51 :group 'rmail-summary) 51 :group 'rmail-summary)
52 52
53(defvar rmail-summary-currently-displayed-msgs nil
54 "String made of `y' and `n'.
55At position i it tells wether message i is shown on the summary or not.
56First character is ignored. Used when applying rmail-summary-by-* commands
57consecutively.")
58(put 'rmail-summary-currently-displayed-msgs 'permanent-local t)
59
60(defvar rmail-summary-font-lock-keywords 53(defvar rmail-summary-font-lock-keywords
61 '(("^ *[0-9]+D.*" . font-lock-string-face) ; Deleted. 54 '(("^ *[0-9]+D.*" . font-lock-string-face) ; Deleted.
62 ("^ *[0-9]+-.*" . font-lock-type-face) ; Unread. 55 ("^ *[0-9]+-.*" . font-lock-type-face) ; Unread.
@@ -274,34 +267,6 @@ consecutively.")
274(defun rmail-update-summary (&rest _) 267(defun rmail-update-summary (&rest _)
275 (apply (car rmail-summary-redo) (cdr rmail-summary-redo))) 268 (apply (car rmail-summary-redo) (cdr rmail-summary-redo)))
276 269
277(defun rmail-summary-fill-displayed-messages ()
278 "Fill the `rmail-summary-currently-displayed-msgs' string."
279 (with-current-buffer rmail-buffer
280 (with-current-buffer rmail-summary-buffer
281 (setq rmail-summary-currently-displayed-msgs
282 (make-string (1+ rmail-total-messages) ?n))
283 (goto-char (point-min))
284 (while (not (eobp))
285 (aset rmail-summary-currently-displayed-msgs
286 (string-to-number (thing-at-point 'line))
287 ?y)
288 (forward-line 1)))))
289
290(defun rmail-summary-negate ()
291 "Toggle showing messages that match/don't match the current summary."
292 (interactive)
293 (rmail-summary-fill-displayed-messages)
294 (rmail-new-summary "Negate"
295 '(rmail-summary-by-regexp ".*" t)
296 (lambda (msg)
297 (if
298 (= (aref rmail-summary-currently-displayed-msgs msg)
299 ?n)
300 (progn
301 (aset rmail-summary-currently-displayed-msgs msg ?y) t)
302 (progn
303 (aset rmail-summary-currently-displayed-msgs msg ?n) nil)))))
304
305;;;###autoload 270;;;###autoload
306(defun rmail-summary () 271(defun rmail-summary ()
307 "Display a summary of all messages, one line per message." 272 "Display a summary of all messages, one line per message."
@@ -309,52 +274,33 @@ consecutively.")
309 (rmail-new-summary "All" '(rmail-summary) nil)) 274 (rmail-new-summary "All" '(rmail-summary) nil))
310 275
311;;;###autoload 276;;;###autoload
312(defun rmail-summary-by-labels (labels &optional keep-filtering) 277(defun rmail-summary-by-labels (labels)
313 "Display a summary of all messages with one or more LABELS. 278 "Display a summary of all messages with one or more LABELS.
314LABELS should be a string containing the desired labels, separated by commas. 279LABELS should be a string containing the desired labels, separated by commas."
315If KEEP-FILTERING is non-nil (interactively, the prefix argument), operate 280 (interactive "sLabels to summarize by: ")
316on the current summary instead of all mail messages."
317 (interactive "sLabels to summarize by: \nP")
318 (if (string= labels "") 281 (if (string= labels "")
319 (setq labels (or rmail-last-multi-labels 282 (setq labels (or rmail-last-multi-labels
320 (error "No label specified")))) 283 (error "No label specified"))))
321 (setq rmail-last-multi-labels labels) 284 (setq rmail-last-multi-labels labels)
322 (if keep-filtering
323 (rmail-summary-fill-displayed-messages))
324 (rmail-new-summary (concat "labels " labels) 285 (rmail-new-summary (concat "labels " labels)
325 (list 'rmail-summary-by-labels labels keep-filtering) 286 (list 'rmail-summary-by-labels labels)
326 (if keep-filtering 287 'rmail-message-labels-p
327 (lambda (msg l)
328 (and (= (aref rmail-summary-currently-displayed-msgs msg)
329 ?y)
330 (rmail-message-labels-p msg l)))
331 'rmail-message-labels-p)
332 (concat " \\(" 288 (concat " \\("
333 (mail-comma-list-regexp labels) 289 (mail-comma-list-regexp labels)
334 "\\)\\(,\\|\\'\\)"))) 290 "\\)\\(,\\|\\'\\)")))
335 291
336;;;###autoload 292;;;###autoload
337(defun rmail-summary-by-recipients (recipients &optional primary-only keep-filtering) 293(defun rmail-summary-by-recipients (recipients &optional primary-only)
338 "Display a summary of all messages with the given RECIPIENTS. 294 "Display a summary of all messages with the given RECIPIENTS.
339Normally checks the To, From and Cc fields of headers; 295Normally checks the To, From and Cc fields of headers;
340but if PRIMARY-ONLY is non-nil (prefix arg given), 296but if PRIMARY-ONLY is non-nil (prefix arg given),
341 only look in the To and From fields. 297 only look in the To and From fields.
342RECIPIENTS is a regular expression. 298RECIPIENTS is a regular expression."
343If KEEP-FILTERING is non-nil, operate on the current summary
344instead of all mail messages."
345 (interactive "sRecipients to summarize by: \nP") 299 (interactive "sRecipients to summarize by: \nP")
346 (if keep-filtering
347 (rmail-summary-fill-displayed-messages))
348 (rmail-new-summary 300 (rmail-new-summary
349 (concat "recipients " recipients) 301 (concat "recipients " recipients)
350 (list 'rmail-summary-by-recipients recipients primary-only keep-filtering) 302 (list 'rmail-summary-by-recipients recipients primary-only)
351 (if keep-filtering 303 'rmail-message-recipients-p recipients primary-only))
352 (lambda (msg r)
353 (and (= (aref rmail-summary-currently-displayed-msgs msg)
354 ?y)
355 (rmail-message-recipients-p msg r)))
356 'rmail-message-recipients-p)
357 recipients primary-only))
358 304
359(defun rmail-message-recipients-p (msg recipients &optional primary-only) 305(defun rmail-message-recipients-p (msg recipients &optional primary-only)
360 (rmail-apply-in-message msg 'rmail-message-recipients-p-1 306 (rmail-apply-in-message msg 'rmail-message-recipients-p-1
@@ -372,28 +318,19 @@ instead of all mail messages."
372;; Also, the optional WHOLE-MESSAGE argument of r-s-by-topic would 318;; Also, the optional WHOLE-MESSAGE argument of r-s-by-topic would
373;; seem more natural here. 319;; seem more natural here.
374;;;###autoload 320;;;###autoload
375(defun rmail-summary-by-regexp (regexp &optional keep-filtering) 321(defun rmail-summary-by-regexp (regexp)
376 "Display a summary of all messages according to regexp REGEXP. 322 "Display a summary of all messages according to regexp REGEXP.
377If the regular expression is found in the header of the message 323If the regular expression is found in the header of the message
378\(including in the date and other lines, as well as the subject line), 324\(including in the date and other lines, as well as the subject line),
379Emacs will list the message in the summary. 325Emacs will list the message in the summary."
380If KEEP-FILTERING is non-nil (interactively, the prefix argument), operate 326 (interactive "sRegexp to summarize by: ")
381on the current summary instead of all mail messages."
382 (interactive "sRegexp to summarize by: \nP")
383 (if (string= regexp "") 327 (if (string= regexp "")
384 (setq regexp (or rmail-last-regexp 328 (setq regexp (or rmail-last-regexp
385 (error "No regexp specified")))) 329 (error "No regexp specified"))))
386 (setq rmail-last-regexp regexp) 330 (setq rmail-last-regexp regexp)
387 (if keep-filtering
388 (rmail-summary-fill-displayed-messages))
389 (rmail-new-summary (concat "regexp " regexp) 331 (rmail-new-summary (concat "regexp " regexp)
390 (list 'rmail-summary-by-regexp regexp keep-filtering) 332 (list 'rmail-summary-by-regexp regexp)
391 (if keep-filtering 333 'rmail-message-regexp-p
392 (lambda (msg r)
393 (and (= (aref rmail-summary-currently-displayed-msgs msg)
394 ?y)
395 (rmail-message-regexp-p msg r)))
396 'rmail-message-regexp-p)
397 regexp)) 334 regexp))
398 335
399(defun rmail-message-regexp-p (msg regexp) 336(defun rmail-message-regexp-p (msg regexp)
@@ -426,14 +363,11 @@ on the current summary instead of all mail messages."
426 (rmail--decode-and-apply 're-search-forward regexp nil t))) 363 (rmail--decode-and-apply 're-search-forward regexp nil t)))
427 364
428;;;###autoload 365;;;###autoload
429(defun rmail-summary-by-topic (subject &optional whole-message keep-filtering) 366(defun rmail-summary-by-topic (subject &optional whole-message)
430 "Display a summary of all messages with the given SUBJECT. 367 "Display a summary of all messages with the given SUBJECT.
431Normally checks just the Subject field of headers; but when 368Normally checks just the Subject field of headers; but with prefix
432WHOLE-MESSAGE is non-nil (interactively, prefix argument), 369argument WHOLE-MESSAGE is non-nil, looks in the whole message.
433looks in the whole message. 370SUBJECT is a regular expression."
434SUBJECT is a regular expression.
435If KEEP-FILTERING is non-nil, operate on the current summary instead
436of all mail messages."
437 (interactive 371 (interactive
438 ;; We quote the default subject, because if it contains regexp 372 ;; We quote the default subject, because if it contains regexp
439 ;; special characters (eg "?"), it can fail to match itself. (Bug#2333) 373 ;; special characters (eg "?"), it can fail to match itself. (Bug#2333)
@@ -442,18 +376,10 @@ of all mail messages."
442 (if subject ", default current subject" "") 376 (if subject ", default current subject" "")
443 "): "))) 377 "): ")))
444 (list (read-string prompt nil nil subject) current-prefix-arg))) 378 (list (read-string prompt nil nil subject) current-prefix-arg)))
445 (if keep-filtering
446 (rmail-summary-fill-displayed-messages))
447 (rmail-new-summary 379 (rmail-new-summary
448 (concat "about " subject) 380 (concat "about " subject)
449 (list 'rmail-summary-by-topic subject whole-message keep-filtering) 381 (list 'rmail-summary-by-topic subject whole-message)
450 (if keep-filtering 382 'rmail-message-subject-p subject whole-message))
451 (lambda (msg s wo)
452 (and (= (aref rmail-summary-currently-displayed-msgs msg)
453 ?y)
454 (rmail-message-subject-p msg s wo)))
455 'rmail-message-subject-p)
456 subject whole-message))
457 383
458(defun rmail-message-subject-p (msg subject &optional whole-message) 384(defun rmail-message-subject-p (msg subject &optional whole-message)
459 (if whole-message 385 (if whole-message
@@ -463,12 +389,10 @@ of all mail messages."
463 (string-match subject (rmail-simplified-subject msg)))) 389 (string-match subject (rmail-simplified-subject msg))))
464 390
465;;;###autoload 391;;;###autoload
466(defun rmail-summary-by-senders (senders &optional keep-filtering) 392(defun rmail-summary-by-senders (senders)
467 "Display a summary of all messages whose \"From\" field matches SENDERS. 393 "Display a summary of all messages whose \"From\" field matches SENDERS.
468SENDERS is a regular expression. The default for SENDERS matches the 394SENDERS is a regular expression. The default for SENDERS matches the
469sender of the current message. 395sender of the current message."
470If KEEP-FILTERING is non-nil (interactively, the prefix argument), operate
471on the current summary instead of all mail messages."
472 (interactive 396 (interactive
473 (let* ((def (rmail-get-header "From")) 397 (let* ((def (rmail-get-header "From"))
474 ;; We quote the default argument, because if it contains regexp 398 ;; We quote the default argument, because if it contains regexp
@@ -477,20 +401,10 @@ on the current summary instead of all mail messages."
477 (prompt (concat "Senders to summarize by (regexp" 401 (prompt (concat "Senders to summarize by (regexp"
478 (if sender ", default this message's sender" "") 402 (if sender ", default this message's sender" "")
479 "): "))) 403 "): ")))
480 (list (read-string prompt nil nil sender) 404 (list (read-string prompt nil nil sender))))
481 current-prefix-arg)))
482 (if keep-filtering
483 (rmail-summary-fill-displayed-messages))
484 (rmail-new-summary 405 (rmail-new-summary
485 (concat "senders " senders) 406 (concat "senders " senders)
486 (list 'rmail-summary-by-senders senders keep-filtering) 407 (list 'rmail-summary-by-senders senders) 'rmail-message-senders-p senders))
487 (if keep-filtering
488 (lambda (msg s)
489 (and (= (aref rmail-summary-currently-displayed-msgs msg)
490 ?y)
491 (rmail-message-senders-p msg s)))
492 'rmail-message-senders-p)
493 senders))
494 408
495(defun rmail-message-senders-p (msg senders) 409(defun rmail-message-senders-p (msg senders)
496 (string-match senders (or (rmail-get-header "From" msg) ""))) 410 (string-match senders (or (rmail-get-header "From" msg) "")))