[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f1ae277e0b: Add reverse mapping for EUDC attribute names
From: |
Thomas Fitzsimmons |
Subject: |
master f1ae277e0b: Add reverse mapping for EUDC attribute names |
Date: |
Mon, 4 Jul 2022 22:05:51 -0400 (EDT) |
branch: master
commit f1ae277e0bbb5e03bb24ff79b4544e5b12f2d361
Author: Alexander Adolf <alexander.adolf@condition-alpha.com>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Add reverse mapping for EUDC attribute names
* lisp/net/eudc.el (eudc-translate-query): new optional parameter to
reverse the mapping direction
(eudc-translate-attribute-list): new optional parameter to
reverse the mapping direction
---
lisp/net/eudc.el | 43 +++++++++++++++++++++++++++++++------------
1 file changed, 31 insertions(+), 12 deletions(-)
diff --git a/lisp/net/eudc.el b/lisp/net/eudc.el
index ca4e4c9f37..eb1342e438 100644
--- a/lisp/net/eudc.el
+++ b/lisp/net/eudc.el
@@ -383,32 +383,51 @@ accordingly. Otherwise it is set to its EUDC default
binding."
(cons protocol eudc-known-protocols))))
-(defun eudc-translate-query (query)
+(defun eudc-translate-query (query &optional reverse)
"Translate attribute names of QUERY.
The translation is done according to
-`eudc-protocol-attributes-translation-alist'."
+`eudc-protocol-attributes-translation-alist'.
+
+When REVERSE is nil or omitted, the attribute names are
+translated from EUDC generic names to protocol-specific
+names. When REVERSE is non-nil, the translation is from
+protocol-specific names back to EUDC generic names."
(if eudc-protocol-attributes-translation-alist
(mapcar (lambda (attribute)
- (let ((trans (assq (car attribute)
- (symbol-value
eudc-protocol-attributes-translation-alist))))
+ (let ((trans
+ (if reverse
+ (rassq (car attribute)
+ (symbol-value
eudc-protocol-attributes-translation-alist))
+ (assq (car attribute)
+ (symbol-value
eudc-protocol-attributes-translation-alist)))))
(if trans
- (cons (cdr trans) (cdr attribute))
+ (cons (if reverse (car trans) (cdr trans))
+ (cdr attribute))
attribute)))
query)
query))
-(defun eudc-translate-attribute-list (list)
+(defun eudc-translate-attribute-list (list &optional reverse)
"Translate a list of attribute names LIST.
The translation is done according to
-`eudc-protocol-attributes-translation-alist'."
+`eudc-protocol-attributes-translation-alist'.
+
+When REVERSE is nil or omitted, the attribute names are
+translated from EUDC generic names to protocol-specific
+names. When REVERSE is non-nil, the translation is from
+protocol-specific names back to EUDC generic names."
(if eudc-protocol-attributes-translation-alist
(let (trans)
(mapcar (lambda (attribute)
- (setq trans (assq attribute
- (symbol-value
eudc-protocol-attributes-translation-alist)))
- (if trans
- (cdr trans)
- attribute))
+ (setq trans
+ (if reverse
+ (rassq attribute
+ (symbol-value
eudc-protocol-attributes-translation-alist))
+ (assq attribute
+ (symbol-value
eudc-protocol-attributes-translation-alist))))
+ (if trans
+ (if reverse (car trans) (cdr trans))
+ attribute))
list))
list))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master f1ae277e0b: Add reverse mapping for EUDC attribute names,
Thomas Fitzsimmons <=