Added separate history support for gadict Emacs mode.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sat, 14 Nov 2020 14:57:50 +0200
changeset 1267 2fd7afb6a12e
parent 1266 a4657a3d08fe
child 1268 4a25c5222f78
Added separate history support for gadict Emacs mode.
misc/gadict.el
--- a/misc/gadict.el	Mon Nov 09 19:49:48 2020 +0200
+++ b/misc/gadict.el	Sat Nov 14 14:57:50 2020 +0200
@@ -310,10 +310,15 @@
           (throw 'exit nil))
         (setq prev curr)) )))
 
+(defvar gadict--headword-history nil
+  "History for gadict's headwords.")
+(defvar gadict--pos-history nil
+  "History for gadict's POS.")
+
 (defun gadict-search (headword)
   "Move to HEADWORD definition or place on posiiton for new corresponding
 definition. Check for headwords ordering during search."
-  (interactive (list (read-string "Headword: ")))
+  (interactive (list (read-string "Headword: " nil 'gadict--headword-history)))
   (gadict-search-floor headword)
   (recenter))
 
@@ -321,9 +326,9 @@
   "Insert new article template with respect of headword order."
   (interactive)
   (let (headword pos)
-    (setq headword (read-string "Headword: "))
+    (setq headword (read-string "Headword: " nil 'gadict--headword-history))
     (unless (gadict-search-floor headword)
-      (setq pos (completing-read "POS: " gadict--pos nil t))
+      (setq pos (completing-read "POS: " gadict--pos nil t nil 'gadict--pos-history))
       (gadict-insert-article headword pos)
       (recenter))))
 
@@ -338,7 +343,7 @@
 
 (defun gadict-insert-translation (pos)
   "Insert translation template using value of `gadict-tr'."
-  (interactive (list (completing-read "POS: " gadict--pos nil t)))
+  (interactive (list (completing-read "POS: " gadict--pos nil t nil 'gadict--pos-history)))
   (let ( (headword-end (gadict--find-headword-end)) )
     (if (< (point) headword-end)
         (goto-char headword-end)