From 989de3b824e5d999c2b63f3067f2628da6034d8c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Stelmach?= Date: Sat, 19 Jun 2021 15:07:13 +0200 Subject: [PATCH] Allow `message-replace-header' to take a list of AFTERs * lisp/gnus/message.el (message-replace-header): Facilitate capability of message-position-on-field to accept multiple headers as AFTERS argument and make possible to mimic behavioir of message-goto-* functions with message-replace-header in case the header does not exist (bug#49070). --- lisp/gnus/message.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 02db38725a9..0c027ca2905 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -8722,16 +8722,19 @@ Header and body are separated by `mail-header-separator'." (defun message-replace-header (header new-value &optional after force) "Remove HEADER and insert the NEW-VALUE. -If AFTER, insert after this header. If FORCE, insert new field -even if NEW-VALUE is empty." +If AFTER, insert after this header. AFTER may be a list of +headers. If FORCE, insert new field even if NEW-VALUE is empty." ;; Similar to `nnheader-replace-header' but for message buffers. (save-excursion (save-restriction (message-narrow-to-headers) (message-remove-header header)) (when (or force (> (length new-value) 0)) - (if after - (message-position-on-field header after) + (when after + (if (listp after) + (apply #'message-position-on-field + (append (list header) after)) + (message-position-on-field header after)) (message-position-on-field header)) (insert new-value)))) -- 2.39.2