unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Facilitate Customisation of Message-Mode Header Completion Behaviour
@ 2022-03-09 15:00 Alexander Adolf
  2022-03-09 17:12 ` Alexander Adolf
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Adolf @ 2022-03-09 15:00 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 498 bytes --]

Hello,

I am moving from 3rd party completion frameworks to use
completion-at-point- only. In the process, I discovered that I want to
override message-expand-name, which is listed in
message-completion-alist. This patch adds a new defcustom for the email
header regular expression, so as to allow users (a) to customise the
regular expression, and (b) to use alist functions for manipulating
message-completion-alist, effectively making programmatic customisation
easier.

Cheers,

  --alexander


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Facilitate-Customisation-of-Message-Mode-Header-Comp.patch --]
[-- Type: text/x-patch, Size: 2377 bytes --]

From 54e6bcf64bdc8d6526071692d778bca3a453fb5f Mon Sep 17 00:00:00 2001
From: Alexander Adolf <alexander.adolf@condition-alpha.com>
Date: Wed, 9 Mar 2022 15:26:55 +0100
Subject: [PATCH] Facilitate Customisation of Message-Mode Header Completion
 Behaviour

This commit refactors the regular expression used for recognising
message headers containing email addresses into a new defcustom. This
brings it on par with the regular expression for recognising headers
containing newsgroup names. At the same time, the regular expression
for email address headers is extended to match additional headers.

For one, this allows users to customise the regular expression for
email headers, which was not possible before. On the other hand it
facilitates customising the value of message-completion-alist, since
having the regular expression (which is the car of the conses in
message-completion-alist) in a variable makes changing the function to
be called (which is the cdr of the conses in message-completion-alist)
easier.
---
 lisp/gnus/message.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index a5b3d40467..fd2176a10f 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -8265,17 +8265,23 @@ When FORCE, rebuild the tool bar."
 				    'message-mode-map))))
   message-tool-bar-map)
 
-;;; Group name completion.
+;;; Group name and email address completion.
 
 (defcustom message-newgroups-header-regexp
   "^\\(Newsgroups\\|Followup-To\\|Posted-To\\|Gcc\\):"
-  "Regexp that match headers that lists groups."
+  "Regexp matching headers that list groups."
+  :group 'message
+  :type 'regexp)
+
+(defcustom message-email-recipient-header-regexp
+  "^\\([^ :]*-\\)?\\(To\\|B?Cc\\|From\\|Reply-to\\|Mail-Followup-To\\|Mail-Copies-To\\):.*? *\\([^,;]*\\)"
+  "Regexp matching headers that list email addresses."
   :group 'message
   :type 'regexp)
 
 (defcustom message-completion-alist
   `((,message-newgroups-header-regexp . ,#'message-expand-group)
-    ("^\\([^ :]*-\\)?\\(To\\|B?Cc\\|From\\):" . ,#'message-expand-name))
+    (,message-email-recipient-header-regexp . ,#'message-expand-name))
   "Alist of (RE . FUN).  Use FUN for completion on header lines matching RE.
 FUN should be a function that obeys the same rules as those
 of `completion-at-point-functions'."
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Facilitate Customisation of Message-Mode Header Completion Behaviour
  2022-03-09 15:00 Facilitate Customisation of Message-Mode Header Completion Behaviour Alexander Adolf
@ 2022-03-09 17:12 ` Alexander Adolf
  2022-03-09 18:27   ` Alexander Adolf
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Adolf @ 2022-03-09 17:12 UTC (permalink / raw)
  To: emacs-devel

Alexander Adolf <alexander.adolf@condition-alpha.com> writes:

> [...]
> +(defcustom message-email-recipient-header-regexp
> +  "^\\([^ :]*-\\)?\\(To\\|B?Cc\\|From\\|Reply-to\\|Mail-Followup-To\\|Mail-Copies-To\\):.*? *\\([^,;]*\\)"
> +  "Regexp matching headers that list email addresses."
>    :group 'message
>    :type 'regexp)
> [...]

The regular expression should have ended with the colon (':'), that is

      "^\\([^ :]*-\\)?\\(To\\|B?Cc\\|From\\|Reply-to\\|Mail-Followup-To\\|Mail-Copies-To\\):"

Apologies for the slip. My bad!

  --alexander



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Facilitate Customisation of Message-Mode Header Completion Behaviour
  2022-03-09 17:12 ` Alexander Adolf
@ 2022-03-09 18:27   ` Alexander Adolf
  2022-03-12 17:16     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Adolf @ 2022-03-09 18:27 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 639 bytes --]

Alexander Adolf <alexander.adolf@condition-alpha.com> writes:

> Alexander Adolf <alexander.adolf@condition-alpha.com> writes:
>
>> [...]
>> +(defcustom message-email-recipient-header-regexp
>> +  "^\\([^ :]*-\\)?\\(To\\|B?Cc\\|From\\|Reply-to\\|Mail-Followup-To\\|Mail-Copies-To\\):.*? *\\([^,;]*\\)"
>> +  "Regexp matching headers that list email addresses."
>>    :group 'message
>>    :type 'regexp)
>> [...]
>
> The regular expression should have ended with the colon (':'), that is
>
>       "^\\([^ :]*-\\)?\\(To\\|B?Cc\\|From\\|Reply-to\\|Mail-Followup-To\\|Mail-Copies-To\\):"
>
> Apologies for the slip. My bad!

Updated patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Facilitate-Customisation-of-Message-Mode-Header-Comp.patch --]
[-- Type: text/x-patch, Size: 2360 bytes --]

From d40a6d084b975a36173909a33b6da0adfe7a2698 Mon Sep 17 00:00:00 2001
From: Alexander Adolf <alexander.adolf@condition-alpha.com>
Date: Wed, 9 Mar 2022 15:26:55 +0100
Subject: [PATCH] Facilitate Customisation of Message-Mode Header Completion
 Behaviour

This commit refactors the regular expression used for recognising
message headers containing email addresses into a new defcustom. This
brings it on par with the regular expression for recognising headers
containing newsgroup names. At the same time, the regular expression
for email address headers is extended to match additional headers.

For one, this allows users to customise the regular expression for
email headers, which was not possible before. On the other hand it
facilitates customising the value of message-completion-alist, since
having the regular expression (which is the car of the conses in
message-completion-alist) in a variable makes changing the function to
be called (which is the cdr of the conses in message-completion-alist)
easier.
---
 lisp/gnus/message.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index a5b3d40467..9e7dc3a6e0 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -8265,17 +8265,23 @@ When FORCE, rebuild the tool bar."
 				    'message-mode-map))))
   message-tool-bar-map)
 
-;;; Group name completion.
+;;; Group name and email address completion.
 
 (defcustom message-newgroups-header-regexp
   "^\\(Newsgroups\\|Followup-To\\|Posted-To\\|Gcc\\):"
-  "Regexp that match headers that lists groups."
+  "Regexp matching headers that list groups."
+  :group 'message
+  :type 'regexp)
+
+(defcustom message-email-recipient-header-regexp
+  "^\\([^ :]*-\\)?\\(To\\|B?Cc\\|From\\|Reply-to\\|Mail-Followup-To\\|Mail-Copies-To\\):"
+  "Regexp matching headers that list email addresses."
   :group 'message
   :type 'regexp)
 
 (defcustom message-completion-alist
   `((,message-newgroups-header-regexp . ,#'message-expand-group)
-    ("^\\([^ :]*-\\)?\\(To\\|B?Cc\\|From\\):" . ,#'message-expand-name))
+    (,message-email-recipient-header-regexp . ,#'message-expand-name))
   "Alist of (RE . FUN).  Use FUN for completion on header lines matching RE.
 FUN should be a function that obeys the same rules as those
 of `completion-at-point-functions'."
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Facilitate Customisation of Message-Mode Header Completion Behaviour
  2022-03-09 18:27   ` Alexander Adolf
@ 2022-03-12 17:16     ` Lars Ingebrigtsen
  2022-03-14 16:12       ` Alexander Adolf
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-12 17:16 UTC (permalink / raw)
  To: Alexander Adolf; +Cc: emacs-devel

Alexander Adolf <alexander.adolf@condition-alpha.com> writes:

> Subject: [PATCH] Facilitate Customisation of Message-Mode Header Completion
>  Behaviour

Makes sense to me; pushed to Emacs 29 now.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Facilitate Customisation of Message-Mode Header Completion Behaviour
  2022-03-12 17:16     ` Lars Ingebrigtsen
@ 2022-03-14 16:12       ` Alexander Adolf
  0 siblings, 0 replies; 5+ messages in thread
From: Alexander Adolf @ 2022-03-14 16:12 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

Lars Ingebrigtsen <larsi@gnus.org> writes:

>> Subject: [PATCH] Facilitate Customisation of Message-Mode Header Completion
>>  Behaviour
>
> Makes sense to me; pushed to Emacs 29 now.

Many Thanks!!!



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-14 16:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-09 15:00 Facilitate Customisation of Message-Mode Header Completion Behaviour Alexander Adolf
2022-03-09 17:12 ` Alexander Adolf
2022-03-09 18:27   ` Alexander Adolf
2022-03-12 17:16     ` Lars Ingebrigtsen
2022-03-14 16:12       ` Alexander Adolf

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).