branch: externals/greader
commit 863097824f88637c73389c7f7628f7b9ae3d237f
Author: Michelangelo Rodriguez <[email protected]>
Commit: Michelangelo Rodriguez <[email protected]>
greader-dict.el (greader-dict-add-entry): Prohibit punctuation in
replacements
The validation for dictionary replacements was overly restrictive. It used
the "\\W" regexp class, which disallows any character that is not a
word constituent. This could prevent legitimate replacements.
The check is now more specific, using the "[[:punct:]]" character class
to only forbid punctuation marks. This aligns better with the intended
behavior. The user
error message has been updated accordingly.
---
greader-dict.el | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/greader-dict.el b/greader-dict.el
index e6fbb90c72..2c38da0a03 100644
--- a/greader-dict.el
+++ b/greader-dict.el
@@ -662,8 +662,8 @@ modify: "
" with: ")
(gethash key
greader-dictionary)))
- (when (string-match "\\W" value)
- (user-error "Replacement cannot contain non-word constituents.
+ (when (string-match "[[:punct:]]" value)
+ (user-error "Replacement cannot contain punctuation signs.
If you want to listen a sign, please include it literally \(wrote by
letters\) in the replacement"))
(greader-dict-add key value))
@@ -672,6 +672,10 @@ letters\) in the replacement"))
(setq value (read-string (concat "substitute " key " with: ")
nil nil
(gethash key greader-dictionary)))
+ (when (string-match "[[:punct:]]" value)
+ (user-error "Replacement cannot contain punctuation signs.
+If you want to listen a sign, please include it literally \(wrote by
+letters\) in the replacement"))
(greader-dict-add key value)))))
(deactivate-mark t))