branch: externals/jinx
commit 4e00518d5b1d4c1350e2201c1affbc5429826f35
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>

    Actions can be triggered via digit keys
---
 CHANGELOG.org |  4 ++++
 jinx.el       | 45 +++++++++++++++++++++------------------------
 2 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 6882c3bc19..e84751250a 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -2,6 +2,10 @@
 #+author: Daniel Mendler
 #+language: en
 
+* Development
+
+- Actions can be triggered via digit keys now.
+
 * Version 2.4 (2025-10-13)
 
 - =jinx-exclude-properties=: New variable to exclude propertized text from
diff --git a/jinx.el b/jinx.el
index fac85bf2c4..c2f5fbd64d 100644
--- a/jinx.el
+++ b/jinx.el
@@ -713,26 +713,26 @@ See `isearch-open-necessary-overlays' and 
`isearch-open-overlay-temporary'."
   (use-local-map
    (make-composed-keymap (list jinx-correct-map) (current-local-map))))
 
-(defun jinx--add-suggestion (list ht word group)
+(defun jinx--add-suggestion (list ht word group &optional suffix)
   "Add suggestion WORD to LIST and HT.
-The word will be associated with GROUP and get a prefix key."
+The suggestion will get a prefix key.  A GROUP and a SUFFIX property are
+optionally added."
   (unless (gethash word ht)
     (add-text-properties
      0 (length word)
-     (list 'jinx--group group
-           'jinx--prefix
-           (let ((idx (1+ (hash-table-count ht))))
-             (cond
-              ((< idx 10)
-               (format #("%d " 0 3 (face jinx-key))
-                       idx))
-              ((< (- idx 10) (length jinx--select-keys))
-               (format #("0%c " 0 4 (face jinx-key))
-                       (aref jinx--select-keys (- idx 10)))))))
+     `( jinx--group ,group
+        jinx--prefix ,(let ((idx (1+ (hash-table-count ht))))
+                        (cond
+                         ((< idx 10)
+                          (format #("%d " 0 3 (face jinx-key))
+                                  idx))
+                         ((< (- idx 10) (length jinx--select-keys))
+                          (format #("0%c " 0 4 (face jinx-key))
+                                  (aref jinx--select-keys (- idx 10))))))
+        jinx--suffix ,suffix)
      word)
-    (push word list)
-    (puthash word t ht))
-  list)
+    (push word (car list))
+    (puthash word t ht)))
 
 (defun jinx--session-suggestions (word)
   "Retrieve suggestions for WORD from session."
@@ -746,15 +746,15 @@ The word will be associated with GROUP and get a prefix 
key."
 (defun jinx--correct-suggestions (word)
   "Retrieve suggestions for WORD from all dictionaries."
   (let ((ht (make-hash-table :test #'equal))
-        (list nil))
+        (list (cons nil nil)))
     (dolist (dict jinx--dicts)
       (let* ((desc (jinx--mod-describe dict))
              (group (format "Suggestions from dictionary ā€˜%s’ - %s"
                             (car desc) (cdr desc))))
         (dolist (w (jinx--mod-suggest dict word))
-          (setq list (jinx--add-suggestion list ht w group)))))
+          (jinx--add-suggestion list ht w group))))
     (dolist (w (jinx--session-suggestions word))
-      (setq list (jinx--add-suggestion list ht w "Suggestions from session")))
+      (jinx--add-suggestion list ht w "Suggestions from session"))
     (cl-loop
      for (key . fun) in jinx--save-keys
      for actions = (funcall fun nil key word) do
@@ -766,12 +766,9 @@ The word will be associated with GROUP and get a prefix 
key."
                            'face 'jinx-save 'rear-nonsticky t)
       for a2 = (format #(" [%s]" 0 5 (face jinx-annotation)) a)
       do (cl-loop
-          for w2 in (delete-consecutive-dups (list w (downcase w))) do
-          (push (propertize (concat k2 w2)
-                            'jinx--group "Accept and save"
-                            'jinx--suffix a2)
-                list))))
-    (nreverse list)))
+          for w2 in (list w (downcase w)) do
+          (jinx--add-suggestion list ht (concat k2 w2) "Accept and save" a2))))
+    (nreverse (car list))))
 
 (defun jinx--correct-affixation (cands)
   "Affixate CANDS during completion."

Reply via email to