From: irek <mail@gumen.pl>
To: emacs-devel@gnu.org
Subject: rmail-ordered-headers patch proposal
Date: Wed, 23 Feb 2022 13:36:05 +0100 [thread overview]
Message-ID: <87pmndn4ju.fsf@gumen.pl> (raw)
[-- Attachment #1: Type: text/plain, Size: 1393 bytes --]
Hello, as suggested by Jean in thread "Fixed order of headers in Rmail
messages" from help-gnu-emacs@gnu.org mailing list I'm sending an patch
proposal for Rmail.
It adds new variable `rmail-ordered-headers' that gives control over
mail message headers order. It's a list of string values being header
names. When list is not nil then `rmail-copy-headers' function will
ignore `rmail-displayed-headers' and `rmail-ignored-headers' that are
regexp based. Instead code will go over each `rmail-ordered-headers'
value searching for given header name and copy that header with
corresponding value if found, if not then it's skipped.
I have set default value for this custom variable because in my opinion
this should be a default behavior.
Motives behind all of this can be found in thread archive:
https://lists.gnu.org/archive/html/help-gnu-emacs/2022-02/msg00253.html
https://lists.gnu.org/archive/html/help-gnu-emacs/2022-02/msg00291.html
And in package commentary section that adds this behavior using advice:
https://github.com/ir33k/rmail-ordered-headers/blob/master/rmail-ordered-headers.el#L23
Basically patch does the same thing as mentioned package.
Happy to hear any comments on that, suggestions of changes etc. I'm
aware that if this is going to be merged with Emacs code base then also
info page and NEWS file have to be updated.
BTW Tested on Emacs 25.2.2 and 29.0.50.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: rmail-ordered-headers.diff --]
[-- Type: text/x-diff, Size: 1777 bytes --]
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 6b058d09f9..bac810fa25 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -377,6 +377,17 @@ rmail-nonignored-headers
:type '(choice (const nil) (regexp))
:group 'rmail-headers)
+;;;###autoload
+(defcustom rmail-ordered-headers '("Date" "From" "To" "Reply-To" "Cc" "Bcc" "Thread-Topic" "Subject")
+ "List of Header field names that Rmail should display in given order.
+Headers with empty values are omitted. Note that controlling
+headers using this variable is least performent comparing to
+`rmail-displayed-headers' and `rmail-ignored-headers' which are
+ignored when this var is not nil."
+ :type '(repeat string)
+ :group 'rmail-headers
+ :version "29.1")
+
;;;###autoload
(defcustom rmail-displayed-headers nil
"Regexp to match Header fields that Rmail should display.
@@ -2898,6 +2909,19 @@ rmail-copy-headers
(with-current-buffer rmail-view-buffer
(goto-char (1+ len)))))
+ ;; Handle case where headers are copied in order.
+ ((and rmail-ordered-headers (null ignored-headers))
+ (seq-each
+ (lambda (header)
+ (when (re-search-forward (format "^%s:" header) nil t)
+ (append-to-buffer rmail-view-buffer
+ (match-beginning 0)
+ (if (re-search-forward header-start-regexp nil t)
+ (1- (match-end 0))
+ (point-max))))
+ (goto-char (point-min)))
+ rmail-ordered-headers))
+
;; Handle the case where the headers matching the displayed
;; headers regexp should be copied.
((and rmail-displayed-headers (null ignored-headers))
next reply other threads:[~2022-02-23 12:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-23 12:36 irek [this message]
2022-02-25 5:00 ` rmail-ordered-headers patch proposal 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pmndn4ju.fsf@gumen.pl \
--to=mail@gumen.pl \
--cc=emacs-devel@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.