(load-theme 'modus-vivendi)
#+end_src
-* Dutch to English translation with =define-word= and [[https://www.vertalen.nu/][vertalen.nu]]
-:PROPERTIES:
-:CUSTOM_ID: vertalen
-:END:
-
-#+begin_src emacs-lisp
- (defun vertalen--on-success (&rest args)
- "Process ARGS and display translation in a dedicated buffer."
- (with-current-buffer-window "*vertalen*"
- (with-selected-window (selected-window)
- (unless (eq major-mode 'vertalen-mode)
- `(nil . ((inhibit-same-window . t)))))
- #'fit-window-to-buffer
- (setq tabulated-list-entries (plist-get args :data))
- (vertalen-mode)
- (+ 2 (length tabulated-list-entries))))
-
- (defun vertalen--parse ()
- (require 'dom)
- "Parse buffer and return a list of translations."
- (let* ((dom (libxml-parse-html-region (point-min) (point-max)))
- (res (dom-by-class dom ".*result-item-translations.*"))
- (ret nil))
- (dolist (elem res)
- (setq ret
- `((nil ,(vector
- (apply #'concat
- (dom-strings
- (car (dom-by-class
- elem
- ".*result-item-source.*"))))
- (mapconcat #'identity
- (dom-strings
- (car (dom-by-class
- elem
- ".*result-item-target.*")))
- ", ")))
- . ,ret)))
- (reverse ret)))
-
- (setq vertalen--source nil)
- (setq vertalen-history nil)
-
- (with-eval-after-load 'savehist
- (add-to-list 'savehist-additional-variables
- 'vertalen-history))
-
- (defun vertalen (word)
- "Translate WORD."
- (interactive (list (read-string "Translate: " nil 'vertalen-history (thing-at-point 'word))))
- (require 'request)
- (setq vertalen--source word)
- (request "https://www.vertalen.nu/vertaal"
- :params `(("van" . "nl")
- ("naar" . "en")
- ("vertaal" . ,word))
- :parser #'vertalen--parse
- :success #'vertalen--on-success))
-
- (defun vertalen-at-point ()
- "Translate word at point."
- (interactive nil vertalen-mode)
- (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)
- (save-excursion
- (goto-char (point-min))
- (let ((inhibit-read-only t)
- (word (search-forward vertalen--source nil t)))
- (while word
- (add-face-text-property (match-beginning 0) (match-end 0) 'success)
- (setq word (search-forward vertalen--source nil t))))))
-#+end_src
-
* Package archives
:PROPERTIES:
:CUSTOM_ID: package-archives
(slack-start))
#+end_src
+* Dutch to English translation with =define-word= and [[https://www.vertalen.nu/][vertalen.nu]]
+:PROPERTIES:
+:CUSTOM_ID: vertalen
+:END:
+
+#+begin_src emacs-lisp
+ (defun vertalen--on-success (&rest args)
+ "Process ARGS and display translation in a dedicated buffer."
+ (with-current-buffer-window "*vertalen*"
+ (with-selected-window (selected-window)
+ (unless (eq major-mode 'vertalen-mode)
+ `(nil . ((inhibit-same-window . t)))))
+ #'fit-window-to-buffer
+ (setq tabulated-list-entries (plist-get args :data))
+ (vertalen-mode)
+ (+ 2 (length tabulated-list-entries))))
+
+ (defun vertalen--parse ()
+ (require 'dom)
+ "Parse buffer and return a list of translations."
+ (let* ((dom (libxml-parse-html-region (point-min) (point-max)))
+ (res (dom-by-class dom ".*result-item-translations.*"))
+ (ret nil))
+ (dolist (elem res)
+ (setq ret
+ `((nil ,(vector
+ (apply #'concat
+ (dom-strings
+ (car (dom-by-class
+ elem
+ ".*result-item-source.*"))))
+ (mapconcat #'identity
+ (dom-strings
+ (car (dom-by-class
+ elem
+ ".*result-item-target.*")))
+ ", ")))
+ . ,ret)))
+ (reverse ret)))
+
+ (setq vertalen--source nil)
+ (setq vertalen-history nil)
+
+ (with-eval-after-load 'savehist
+ (add-to-list 'savehist-additional-variables
+ 'vertalen-history))
+
+ (defun vertalen (word)
+ "Translate WORD."
+ (interactive (list (read-string "Translate: " nil 'vertalen-history (thing-at-point 'word))))
+ (require 'request)
+ (setq vertalen--source word)
+ (request "https://www.vertalen.nu/vertaal"
+ :params `(("van" . "nl")
+ ("naar" . "en")
+ ("vertaal" . ,word))
+ :parser #'vertalen--parse
+ :success #'vertalen--on-success))
+
+ (defun vertalen-at-point ()
+ "Translate word at point."
+ (interactive nil vertalen-mode)
+ (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)
+ (save-excursion
+ (goto-char (point-min))
+ (let ((inhibit-read-only t)
+ (word (search-forward vertalen--source nil t)))
+ (while word
+ (add-face-text-property (match-beginning 0) (match-end 0) 'success)
+ (setq word (search-forward vertalen--source nil t))))))
+#+end_src
+
* Display weekly agenda on startup
:PROPERTIES:
:CUSTOM_ID: agenda-on-startup