My user is marked as mentioned when a word contains my username
bug
### OS/platform
debian testing
### Emacs version and provenance
apt install emacs
### Emacs command
emacs
### Emacs frame type
both
### Ement package version and provenance
straight, using ement from git commit 57ac20036e6b3574512188dfd10f0a9432348a5c
### Actions taken
No action per se, I simply get messages that supposedly mention me when words containing my username are used.
### Observed results
My username is sam, so it matches a words like same, sample etc
<img width="576" height="87" alt="Image" src="https://github.com/user-attachments/assets/22b59557-c16d-4788-8354-400872950fcd" />
### Expected results
I would expect only the message with my username to be matched as a mention
### Backtrace
```elisp
```
### Etc.
I worked around this in [my fork](https://github.com/Konubinix/ement.el/commit/d96a760ecd85fec134bb38d72f7fea346cc9157e) by adding \b around the regexp in `ement-room--event-mentions-user-p`
```lisp
(when body
(cl-macrolet ((matches-body-p
(form) `(when-let ((string ,form))
(string-match-p (format "\\b%s\\b" (regexp-quote string)) body))))
(or (matches-body-p (ement-user-username user))
(matches-body-p (ement--user-displayname-in room user))
(matches-body-p (ement-user-id user)))))))
```
Now I get the appropriate behavior
<img width="570" height="45" alt="Image" src="https://github.com/user-attachments/assets/c95512e6-baf5-4975-bc9f-8396a01423f6" />
关闭于 2025-07-30 2 条评论