]> git.eshelyaron.com Git - dotfiles.git/commitdiff
Tweak esy/eww to use crm
authorEshel Yaron <eshel@dazz.io>
Tue, 14 Jun 2022 11:55:41 +0000 (14:55 +0300)
committerEshel Yaron <eshel@dazz.io>
Tue, 14 Jun 2022 11:55:41 +0000 (14:55 +0300)
.emacs.d/esy.org

index 8486b01462bb9b56894d364f5ea4d25c21000464..c646091c7510b8a94bb8d502af58b1416d75fdb2 100644 (file)
@@ -130,22 +130,7 @@ For further information about Elisp headers, see [[info:elisp#Library
 * Dutch to English translation with =define-word= and [[https://www.vertalen.nu/][vertalen.nu]]
 
 #+begin_src emacs-lisp
-  (define-derived-mode vertalen-mode tabulated-list-mode "Vertalen"
-    "Major mode for listing Dutch to English translations."
-    (setq tabulated-list-format [("Source Language" 64 t)
-                                 ("Target Language" 32 t)])
-    (tabulated-list-init-header)
-    (tabulated-list-print))
-
-  (defun vertalen-define-word-at-point ()
-    (interactive)
-    (define-word-at-point nil 'vertalen))
-
-  (define-key vertalen-mode-map (kbd "C-m") #'vertalen-define-word-at-point)
-  ; (define-key vertalen-mode-map (kbd "l") #'vertalen-previous-word)
-  ; (define-key vertalen-mode-map (kbd "r") #'vertalen-next-word)
-
-  (defun vertalen-handle-response ()
+  (defun vertalen--parse-vertalen ()
     "Populate `tabulated-list-entries' and display the results."
     (let* ((dom (libxml-parse-html-region (point-min) (point-max)))
            (res (dom-by-class dom ".*result-item-translations.*"))
@@ -179,7 +164,28 @@ For further information about Elisp headers, see [[info:elisp#Library
     (add-to-list 'define-word-services
                  '(vertalen
                    "https://www.vertalen.nu/vertaal?van=nl&naar=en&vertaal=%s"
-                   vertalen-handle-response)))
+                   vertalen--parse-vertalen)))
+
+  (defun vertalen (word)
+    "Translate WORD."
+    (interactive "M")
+    (define-word word 'vertalen))
+
+  (defun vertalen-at-point ()
+    "Translate word at point."
+    (interactive)
+    (vertalen (thing-at-point 'word t)))
+
+  (defvar-keymap vertalen-mode-map
+    :doc "Keymap for `vertalen-mode' buffers."
+    "RET" #'vertalen-at-point)
+
+  (define-derived-mode vertalen-mode tabulated-list-mode "Vertalen"
+    "Major mode for listing Dutch to English translations."
+    (setq tabulated-list-format [("Source Language" 64 t)
+                                 ("Target Language" 32 t)])
+    (tabulated-list-init-header)
+    (tabulated-list-print))
 #+end_src
 * Package archives
 :PROPERTIES:
@@ -834,7 +840,7 @@ refiling directly into deeper headings as well.
     (keymap-set ctl-x-map "c" #'org-capture)
     (keymap-set ctl-x-map "o" #'ace-window)
     (keymap-set ctl-x-map "w" #'esy/eww)
-    (keymap-set ctl-x-map "V" #'vertalen-define-word-at-point)
+    (keymap-set ctl-x-map "V" #'vertalen-at-point)
     (keymap-set ctl-x-map "G" #'gnus)
     (keymap-set ctl-x-map "E" #'elfeed)
     (keymap-set ctl-x-map "j" #'org-agenda)
@@ -927,11 +933,13 @@ the prior submitted URLs and web search keywords.
     "Prompt for a URL or keywords to search the web for."
     (interactive)
     (require 'eww)
-    (eww (completing-read "Browse or search: "
-                          eww-prompt-history
-                          nil nil nil
-                          'eww-prompt-history
-                          (car (eww-suggested-uris)))))
+    (eww (mapconcat #'identity
+                    (completing-read-multiple "Browse or search: "
+                                              eww-prompt-history
+                                              nil nil nil
+                                              'eww-prompt-history
+                                              (car (eww-suggested-uris)))
+                    " ")))
 #+end_src
 
 *** Use =eww= as the default web browser
@@ -1067,7 +1075,6 @@ does in the shell.
     (global-corfu-mode)
     (marginalia-mode)
     (add-to-list 'completion-at-point-functions #'cape-file)
-;    (add-to-list 'completion-at-point-functions #'cape-dabbrev)
     (add-hook 'marginalia-mode-hook #'all-the-icons-completion-marginalia-setup)
     (add-to-list 'display-buffer-alist
                  '("*Completions*"