summaryrefslogtreecommitdiff
path: root/lisp/net/eudc-vars.el
diff options
context:
space:
mode:
authorAlexander Adolf <alexander.adolf@condition-alpha.com>2022-03-14 21:23:18 +0100
committerThomas Fitzsimmons <fitzsim@fitzsim.org>2022-03-22 18:15:47 -0400
commit8dc85d1db4564f0d9df847b7884c920a0f8d7fe9 (patch)
tree2b42bf212964eeb409648e88fe7e11088f838a33 /lisp/net/eudc-vars.el
parentc8bde5b0a3c7ac6c1d71c404977f83e2b4e94092 (diff)
downloademacs-8dc85d1db4564f0d9df847b7884c920a0f8d7fe9.tar.gz
emacs-8dc85d1db4564f0d9df847b7884c920a0f8d7fe9.tar.bz2
emacs-8dc85d1db4564f0d9df847b7884c920a0f8d7fe9.zip
Enable Better Alignment of EUDC Inline Expansion With RFC5322
The format of EUDC inline expansion results is formatted according to the variable eudc-inline-expansion-format, which previously defaulted to '("%s %s <%s>" firstname name email). Since email address specifications need to comply with RFC 5322 in order to be useful in messages, there was little headroom for users to change this format anyway. Plus, if an EUDC back-end returned an empty first and last name, the result was the email address in angle brackets. Whilst this was standard with RFC 822, it is marked as obsolete syntax by its successor RFC 5322. Also, the first and last name part was never enclosed in double quotes, potentially producing invalid address specifications, which may be rejected by a receiving MTA. This commit updates the variable eudc-inline-expansion-format, so that it can, in addition to the current ("format" attributes) list, now alternatively be set to nil, or a formatting function. In both cases the resulting email address is formatted using the new function eudc-rfc5322-make-address, whose results fully comply with RFC 5322. If the value is nil (the new default value), eudc-rfc5322-make-address will be called to produce any of the default formats ADDRESS FIRST <ADDRESS> LAST <ADDRESS> FIRST LAST <ADDRESS> depending on whether a first and/or last name are returned by the query, or not. If the value is a formatting function, that will be called to allow the user to supply content for the phrase and comment parts of the address (cf. RFC 5322). Thus one can produce any of the formats: ADDRESS PHRASE <ADDRESS> ADDRESS (COMMENT) PHRASE <ADDRESS> (COMMENT) This can for example be used to get "last, first <address>" instead of the default "first last <address>". In any case when using nil, or the formatting function, the phrase part of the result will be enclosed in double quotes if needed, and the comment part will be omitted if it contains characters not allowed by RFC 5322. When eudc-inline-expansion-format remains set to a list as previously, the old behaviour is fully retained.
Diffstat (limited to 'lisp/net/eudc-vars.el')
-rw-r--r--lisp/net/eudc-vars.el64
1 files changed, 45 insertions, 19 deletions
diff --git a/lisp/net/eudc-vars.el b/lisp/net/eudc-vars.el
index 997b9e30fd4..d58fab896ed 100644
--- a/lisp/net/eudc-vars.el
+++ b/lisp/net/eudc-vars.el
@@ -191,25 +191,51 @@ must be set in a protocol/server-local fashion, see `eudc-server-set' and
:type 'boolean
:version "25.1")
-(defcustom eudc-inline-expansion-format '("%s %s <%s>" firstname name email)
- "A list specifying the format of the expansion of inline queries.
-This variable controls what `eudc-expand-inline' actually inserts in
-the buffer. First element is a string passed to `format'. Remaining
-elements are symbols indicating attribute names; the corresponding values
-are passed as additional arguments to `format'."
- :type '(list
- (string :tag "Format String")
- (repeat :inline t
- :tag "Attributes"
- (choice
- :tag "Attribute"
- (const :menu-tag "First Name" :tag "First Name" firstname)
- (const :menu-tag "Surname" :tag "Surname" name)
- (const :menu-tag "Email Address" :tag "Email Address" email)
- (const :menu-tag "Phone" :tag "Phone" phone)
- (symbol :menu-tag "Other")
- (symbol :tag "Attribute name"))))
- :version "25.1")
+(defcustom eudc-inline-expansion-format nil
+ "Specify the format of the expansion of inline queries.
+This variable controls what `eudc-expand-inline' actually inserts
+in the buffer. It is either a list, or a function.
+
+When set to a list, the expansion result will be formatted
+according to the first element of the list, a string, which is
+passed as the first argument to `format'. The remaining elements
+of the list are symbols indicating attribute names; the
+corresponding values are passed as additional arguments to
+`format'.
+
+When set to nil, the expansion result will be formatted using
+`eudc-rfc5322-make-address', and the PHRASE part will be
+formatted according to \"firstname name\", quoting the result if
+necessary. No COMMENT will be added in this case.
+
+When set to a function, the expansion result will be formatted
+using `eudc-rfc5322-make-address', and the referenced function is
+used to format the PHRASE, and COMMENT parts, respectively. It
+receives a single argument, which is an alist of
+protocol-specific attributes describing the recipient. To access
+the alist elements using generic EUDC attribute names, such as
+for example name, or email, use `eudc-translate-attribute-list'.
+The function should return a list, which should contain two
+elements. If the first element is a string, it will be used as
+the PHRASE part, quoting it if necessary. If the second element
+is a string, it will be used as the COMMENT part, unless it
+contains characters not allowed in the COMMENT part by RFC 5322,
+in which case the COMMENT part will be omitted."
+ :type '(choice (const :tag "RFC 5322 formatted \"first last <address>\"" nil)
+ (function :tag "RFC 5322 phrase/comment formatting function")
+ (list :tag "Format string (deprecated)"
+ (string :tag "Format String")
+ (repeat :inline t
+ :tag "Attributes"
+ (choice
+ :tag "Attribute"
+ (const :menu-tag "First Name" :tag "First Name" firstname)
+ (const :menu-tag "Surname" :tag "Surname" name)
+ (const :menu-tag "Email Address" :tag "Email Address" email)
+ (const :menu-tag "Phone" :tag "Phone" phone)
+ (symbol :menu-tag "Other")
+ (symbol :tag "Attribute name")))))
+ :version "29.1")
(defcustom eudc-inline-expansion-servers 'server-then-hotlist
"Which servers to contact for the expansion of inline queries.