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

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

[elpa] externals/hiddenquote 1afa4bc748: Support searching words inside


From: ELPA Syncer
Subject: [elpa] externals/hiddenquote 1afa4bc748: Support searching words inside definitions
Date: Sat, 5 Nov 2022 07:57:43 -0400 (EDT)

branch: externals/hiddenquote
commit 1afa4bc748aaaec35dca13e650bd524abbdbfc29
Author: Mauro Aranda <maurooaranda@gmail.com>
Commit: Mauro Aranda <maurooaranda@gmail.com>

    Support searching words inside definitions
    
    * hiddenquote.el (hiddenquote-search-word): New command.
    (hiddenquote-mode-map): Bind it.
    (hiddenquote-syllable-notify): Print a message when the user completes
    the puzzle.
---
 hiddenquote.el | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/hiddenquote.el b/hiddenquote.el
index ed22d637b0..4382c9cf1b 100644
--- a/hiddenquote.el
+++ b/hiddenquote.el
@@ -286,6 +286,7 @@ to the syllables buffer."
     (define-key map "\C-p" #'hiddenquote-prev)
     (define-key map [up] #'hiddenquote-prev)
     (define-key map [(meta ?g) (meta ?g)] #'hiddenquote-goto-word)
+    (define-key map [(meta ?g) (control ?s)] #'hiddenquote-search-word)
     ;; Done.
     (define-key map [(control ?x) (control ?s)] #'hiddenquote-save)
     (define-key map [(control ?x) ?!] #'hiddenquote-give-up)
@@ -1114,7 +1115,8 @@ Return `hiddenquote-used-syllable' if WIDGET's value is 
non-nil,
 (defun hiddenquote-syllable-notify (_widget _child &optional _event)
   "Check if all syllables are marked as used."
   (when (hiddenquote-puzzle-complete-p)
-    (hiddenquote-timer-stop-timer)))
+    (hiddenquote-timer-stop-timer)
+    (message "Congratulations, you won!")))
 
 ;; Functions.
 (defun hiddenquote--get-quote-length ()
@@ -1562,6 +1564,17 @@ every word."
                               (widget-get (widget-get parent :parent)
                                           :buttons)))))
 
+(defun hiddenquote-search-word (word)
+  "Search for presence of the string WORD in a definition and go to that word."
+  (interactive (list (read-string "Word: ")))
+  (let* ((clues (oref (widget-get hiddenquote-current :hiddenquote) clues))
+         (re (concat "\\<" (regexp-quote word) "\\>"))
+         (def (seq-position clues word (lambda (clue _word)
+                                         (string-match re (cadr clue))))))
+    (if def
+        (hiddenquote-goto-word (1+ def))
+      (message "No definition contains that word"))))
+
 (defun hiddenquote-toggle-automatic-check ()
   "Toggle the `hiddenquote-automatic-check' variable."
   (interactive)



reply via email to

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