unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: Andrea Monaco <andrea.monaco@autistici.org>
Cc: rms@gnu.org,  eliz@gnu.org,  emacs-devel@gnu.org
Subject: Re: [PATCH v3] Allow applying filters to summary consecutively
Date: Wed, 19 Oct 2022 16:55:21 +0200	[thread overview]
Message-ID: <87zgdruali.fsf@gmail.com> (raw)
In-Reply-To: <87k04vj3ji.fsf@autistici.org> (Andrea Monaco's message of "Wed,  19 Oct 2022 16:23:13 +0200")


Hi Andrea, some comments below

>>>>> On Wed, 19 Oct 2022 16:23:13 +0200, Andrea Monaco <andrea.monaco@autistici.org> said:

    Andrea> +(defcustom rmail-summary-apply-filters-consecutively nil
    Andrea> +  "Non-nil means that commands rmail-summary-by-* works
    Andrea> on the

Iʼd call it `rmail-summary-stack-filters' and say

"Whether rmail-summary-by-* commands stack on each other."

    Andrea> +current summary and so can be stacked one after the other."
    Andrea> +  :type 'boolean
    Andrea> +  :group 'rmail-summary)

This needs a :version "29.1"

    Andrea> +(defvar rmail-summary-currently-displayed-msgs nil
    Andrea> +  "String made of 'y' and 'n'.  At index i it tells
    Andrea> wether

"whether"

    Andrea> +message i is shown on the summary or not.  First character is
    Andrea> +ignored.  Used when applying rmail-summary-by-* commands
    Andrea> +consecutively.  Filled by
    Andrea> +rmail-summary-fill-displayed-messages.")
    Andrea> +(put 'rmail-summary-currently-displayed-msgs 'permanent-local t)
    Andrea> +

Itʼs a string that you treat as a vector, so why not just make it a
vector? Also 'fill' in Emacs normally means wrapping paragraphs of
text, so perhaps `rmail-summary-populate-displayed-messages' or
similar is better.

    Andrea>  (defvar rmail-summary-font-lock-keywords
    Andrea>    '(("^ *[0-9]+D.*" . font-lock-string-face)			; Deleted.
    Andrea>      ("^ *[0-9]+-.*" . font-lock-type-face)			; Unread.
    Andrea> @@ -267,6 +281,35 @@ rmail-summary-mode-map
    Andrea>  (defun rmail-update-summary (&rest _)
    Andrea>    (apply (car rmail-summary-redo) (cdr rmail-summary-redo)))
 
    Andrea> +(defun rmail-summary-fill-displayed-messages ()
    Andrea> +  "Fill the rmail-summary-currently-displayed-msgs string."
    Andrea> +  (with-current-buffer rmail-buffer
    Andrea> +    (with-current-buffer rmail-summary-buffer
    Andrea> +      (setq rmail-summary-currently-displayed-msgs
    Andrea> +	    (make-string (1+ rmail-total-messages) ?n))
    Andrea> +      (goto-char (point-min))
    Andrea> +      (while (not (eobp))
    Andrea> +	(aset rmail-summary-currently-displayed-msgs
    Andrea> +	      (string-to-number (thing-at-point 'line))
    Andrea> +	      ?y)
    Andrea> +	(forward-line 1)))))

I donʼt remember the details of rmailʼs summary line format, but I
think youʼd be better served with

(thing-at-point 'number)

(that also avoids the `string-to-number')

    Andrea> +
    Andrea> +(defun rmail-summary-negate ()
    Andrea> +  "Negate the current summary.  That is, show the messages that
    Andrea> +are not displayed, and vice versa."

The first line of the docstring should be a single complete sentence
on a single line.

    Andrea> +  (interactive)
    Andrea> +  (rmail-summary-fill-displayed-messages)
    Andrea> +  (rmail-new-summary "Negate"
    Andrea> +		     '(rmail-summary-by-regexp ".*")
    Andrea> +		     (lambda (msg)
    Andrea> +		       (if
    Andrea> +			   (= (aref rmail-summary-currently-displayed-msgs msg)
    Andrea> +			      ?n)
    Andrea> +			   (progn
    Andrea> +			     (aset rmail-summary-currently-displayed-msgs msg ?y) t)
    Andrea> +			 (progn
    Andrea> +			   (aset rmail-summary-currently-displayed-msgs msg ?n) nil)))))
    Andrea> +

If you switch `rmail-summary-currently-displayed-msgs' to a vector,
you can store `nil' and `t' there directly and avoid the prognʼs (aset
returns the new value)

    Andrea>  ;;;###autoload
    Andrea>  (defun rmail-summary ()
    Andrea>    "Display a summary of all messages, one line per message."
    Andrea> @@ -282,9 +325,16 @@ rmail-summary-by-labels
    Andrea>        (setq labels (or rmail-last-multi-labels
    Andrea>  		       (error "No label specified"))))
    Andrea>    (setq rmail-last-multi-labels labels)
    Andrea> +  (if rmail-summary-apply-filters-consecutively
    Andrea> +      (rmail-summary-fill-displayed-messages))
    Andrea>    (rmail-new-summary (concat "labels " labels)
    Andrea>  		     (list 'rmail-summary-by-labels labels)
    Andrea> -		     'rmail-message-labels-p
    Andrea> +		     (if rmail-summary-apply-filters-consecutively
    Andrea> +			 (lambda (msg l)
    Andrea> +			   (and (= (aref rmail-summary-currently-displayed-msgs msg)
    Andrea> +				   ?y)
    Andrea> +				(rmail-message-labels-p msg l)))
    Andrea> +		       'rmail-message-labels-p)
    Andrea>  		     (concat " \\("
    Andrea>  			     (mail-comma-list-regexp labels)
    Andrea>  			     "\\)\\(,\\|\\'\\)")))

I think you have this same lambda about 4 times in the code, perhaps
`defun' it (using "rmail-summary--" as a prefix to indicate that itʼs
intended for internal usage)

Robert
-- 



  reply	other threads:[~2022-10-19 14:55 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 18:31 Summary by thread in rmail Andrea Monaco
2022-10-05 18:49 ` Eli Zaretskii
2022-10-05 23:40 ` Emanuel Berg
2022-10-06 22:04 ` Richard Stallman
2022-10-07 10:17   ` Andrea Monaco
2022-10-07 11:24     ` Emanuel Berg
2022-10-09 20:33   ` [PATCH] Allow applying filters to summary consecutively (was: Summary by thread in rmail) Andrea Monaco
2022-10-10  7:31     ` Eli Zaretskii
2022-10-10  8:38       ` Andrea Monaco
2022-10-10  8:57         ` Eli Zaretskii
2022-10-11  7:16           ` [PATCH v2] " Andrea Monaco
2022-10-11  8:13             ` [PATCH v2] Allow applying filters to summary consecutively Robert Pluim
2022-10-12  9:35               ` Andrea Monaco
2022-10-12 11:03                 ` Robert Pluim
2022-10-12 12:56                 ` Eli Zaretskii
2022-10-12 18:13                   ` Andrea Monaco
2022-10-12 18:22                     ` Eli Zaretskii
2022-10-12 22:02                 ` Richard Stallman
2022-10-19 14:23                   ` [PATCH v3] " Andrea Monaco
2022-10-19 14:55                     ` Robert Pluim [this message]
2022-10-20 15:45                       ` Andrea Monaco
2022-10-20 16:02                         ` Robert Pluim
2022-10-20 19:00                           ` Andrea Monaco
2022-10-21 19:42                             ` Richard Stallman
2022-10-21 19:38                     ` Richard Stallman
2022-10-27 14:27                     ` Eli Zaretskii
2022-10-27 15:22                       ` Andrea Monaco
2022-10-28 13:26                       ` Andrea Monaco
2022-11-06  7:34                         ` Eli Zaretskii
2022-11-07 14:13                           ` Andrea Monaco
2022-11-08  5:02                             ` Richard Stallman
2022-11-08  8:04                               ` Andrea Monaco
2022-11-14  3:13                                 ` Richard Stallman
2022-11-10  4:04                             ` Richard Stallman
2022-11-10  8:06                               ` Eli Zaretskii
2022-11-10  8:53                                 ` Robert Pluim
2022-11-11  4:36                                 ` Richard Stallman
2022-11-11  8:06                                   ` Eli Zaretskii
2022-11-11 14:59                                     ` Juanma Barranquero
2022-11-11 17:23                                       ` Eli Zaretskii
2022-11-11 17:32                                       ` [External] : " Drew Adams
2022-11-11 18:00                                     ` Gregory Heytings
2022-11-11 18:19                                       ` Eli Zaretskii
2022-11-11 18:52                                         ` Gregory Heytings
2022-11-11 18:54                                           ` Gregory Heytings
2022-11-11 19:34                                             ` Eli Zaretskii
2022-11-11 19:33                                           ` Eli Zaretskii
2022-11-11 20:50                                             ` Gregory Heytings
2022-11-12  3:37                                               ` Richard Stallman
2022-11-12  7:52                                                 ` Eli Zaretskii
2022-11-12  6:57                                               ` Eli Zaretskii
2022-11-12 16:30                                                 ` Gregory Heytings
2022-11-12 17:44                                                   ` Andrea Monaco
2022-11-12 18:13                                                     ` Gregory Heytings
2022-11-14  3:13                                                       ` Richard Stallman
2022-11-14  8:39                                                         ` Gregory Heytings
2022-11-15  4:18                                                           ` Richard Stallman
2022-11-15  9:56                                                             ` Gregory Heytings
2022-11-16  3:15                                                               ` Richard Stallman
2022-11-16  3:15                                                               ` Richard Stallman
2022-11-24 18:25                                                                 ` Andrea Monaco
2022-11-28 21:38                                                                   ` Richard Stallman
2022-11-15 17:00                                                             ` [External] : " Drew Adams
2022-11-14  3:13                                                     ` Richard Stallman
2022-11-15  9:35                                                       ` Gregory Heytings
2022-11-16  3:15                                                         ` Richard Stallman
2022-11-19 14:47                                                           ` Gregory Heytings
2022-11-20 17:37                                                             ` Richard Stallman
2022-11-20 19:36                                                               ` Gregory Heytings
2022-11-22 12:14                                                                 ` Richard Stallman
2022-11-22 12:58                                                                   ` Gregory Heytings
2022-11-28 21:38                                                                     ` Richard Stallman
2022-11-23 20:57                                                               ` chad
2022-11-24  6:39                                                                 ` Eli Zaretskii
2022-11-28 21:38                                                                   ` Richard Stallman
2022-11-26  0:51                                                                 ` Richard Stallman
2022-11-11 18:22                                       ` [External] : " Drew Adams
2022-11-12  3:35                                     ` Richard Stallman
2022-11-12  7:47                                       ` Eli Zaretskii
2022-11-14  3:13                                         ` Richard Stallman
2022-11-17 13:34                             ` Eli Zaretskii
2022-10-27 13:58             ` [PATCH v2] Allow applying filters to summary consecutively (was: Summary by thread in rmail) Eli Zaretskii
2022-10-10 22:03     ` [PATCH] " Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zgdruali.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=andrea.monaco@autistici.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).