emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ement ba1dd64f8a 2/2: Fix: (ement--format-body-mentions


From: ELPA Syncer
Subject: [elpa] externals/ement ba1dd64f8a 2/2: Fix: (ement--format-body-mentions)
Date: Sun, 16 Apr 2023 00:57:37 -0400 (EDT)

branch: externals/ement
commit ba1dd64f8a49b6fc5c26390cea962666affc8c1e
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Fix: (ement--format-body-mentions)
    
    It now works for all forms listed in the comment, which are also
    present in the test added in the previous commit.
---
 README.org   |  4 ++++
 ement-lib.el | 27 +++++++--------------------
 2 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/README.org b/README.org
index 9a8ece1dcc..6e1956847d 100644
--- a/README.org
+++ b/README.org
@@ -305,6 +305,10 @@ Note that, while ~matrix-client~ remains usable, and 
probably will for some time
 
 + Using new option ~ement-room-timestamp-header-align~, timestamp headers 
default to right-aligned.  (With default settings, this keeps them near message 
timestamps and makes for a cleaner appearance.)
 
+*Fixes*
+
++ Recognition of certain MXID or displayname forms in outgoing messages when 
linkifying (aka "pilling") them.
+
 ** 0.8.3
 
 *Fixes*
diff --git a/ement-lib.el b/ement-lib.el
index ceaee59699..06c98ab63e 100644
--- a/ement-lib.el
+++ b/ement-lib.el
@@ -981,21 +981,13 @@ period, anywhere in the body."
     (pcase-let* (((cl-struct ement-room members) room)
                  (regexp (rx (or bos bow (1+ blank))
                              (or (seq (group
-                                       ;; Group 1: full MXID or @-prefixed 
displayname.
+                                       ;; Group 1: full @-prefixed MXID.
                                        "@" (group
-                                            ;; Group 2: MXID username or 
displayname.
-                                            ;; NOTE: We special-case the 
question mark,
-                                            ;; period, and comma so they can 
be used after
-                                            ;; a displayname or MXID in a 
sentence (if
-                                            ;; they are present in a 
displayname, too
-                                            ;; bad).
-                                            (1+ (not (any blank "?.,")))))
-                                      ;; NOTE: Including punctuation in this 
terminator
-                                      ;; means that wild displaynames with 
non-word
-                                      ;; characters might not get matched, but 
it's
-                                      ;; necessary so that a mention can be 
like "What
-                                      ;; about @foobar?"
-                                      (or eow eos (syntax punctuation) (seq 
":" (1+ blank))))
+                                            ;; Group 2: displayname.  (NOTE: 
Does not work
+                                            ;; with displaynames containing 
spaces.)
+                                            (1+ (seq (optional ".") alnum)))
+                                       (optional ":" (1+ (seq (optional ".") 
alnum))))
+                                      (or ":" eow eos (syntax punctuation)))
                                  (seq (group
                                        ;; Group 3: MXID username or 
displayname.
                                        (1+ (not blank)))
@@ -1008,14 +1000,9 @@ period, anywhere in the body."
                         (setf replace-group 1)
                         (format template (match-string 1 body)
                                 (ement--xml-escape-string 
(ement--user-displayname-in room member))))
-                      (when-let* ((name (or (when (match-string 1 body)
-                                              ;; Found @-prefixed displayname: 
replace the
-                                              ;; whole thing, including the @, 
but only
-                                              ;; use the displayname for 
looking up the user.
+                      (when-let* ((name (or (when (match-string 2 body)
                                               (setf replace-group 1)
                                               (match-string 2 body))
-                                            (prog1 (match-string 2 body)
-                                              (setf replace-group 2))
                                             (prog1 (match-string 3 body)
                                               (setf replace-group 3))))
                                   (members (members-having-displayname name 
members))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]