aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/lisp/my/infobox.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/.emacs.d/lisp/my/infobox.el')
-rw-r--r--emacs/.emacs.d/lisp/my/infobox.el27
1 files changed, 26 insertions, 1 deletions
diff --git a/emacs/.emacs.d/lisp/my/infobox.el b/emacs/.emacs.d/lisp/my/infobox.el
index 518c7db..5698042 100644
--- a/emacs/.emacs.d/lisp/my/infobox.el
+++ b/emacs/.emacs.d/lisp/my/infobox.el
@@ -27,6 +27,13 @@
;;; Code:
+(defun infobox-transform-field-value (v)
+ (cond ((stringp v) v)
+ ((eq v t) "YES")
+ ((eq v :json-false) "NO")
+ ((seqp v) (mapconcat #'identity v ", "))
+ (t (format "%s" v))))
+
(defun infobox-default-specs (info)
(seq-map
(lambda (pair)
@@ -47,7 +54,7 @@ something like
(lambda (pair)
(when-let ((val (alist-get (car pair) info)))
(if (or (stringp (cdr pair)) (symbolp (cdr pair)))
- (cons (cdr pair) val)
+ (cons (cdr pair) (infobox-transform-field-value val))
(cons (cadr pair) (funcall (cddr pair) val)))))
specs))
@@ -56,6 +63,17 @@ something like
(with-help-window "*infobox*"
(with-current-buffer standard-output
(let ((n-rows 0))
+ ;; TODO: use a more standard function than
+ ;; `my-make-filename-from-url'
+ (when-let* ((thumb-url (alist-get "Thumbnail" info nil nil 'equal))
+ (file-name (file-name-concat
+ "/tmp"
+ (my-make-filename-from-url thumb-url))))
+ (url-copy-file (message thumb-url) file-name t)
+ (insert-image (create-image file-name nil nil
+ :max-width (window-width nil t)))
+ (insert "\n")
+ (setq n-rows (1+ n-rows)))
(seq-do
(lambda (pair)
(when pair
@@ -90,6 +108,13 @@ something like
(infobox-render-string
(with-temp-buffer
(call-process "exiftool" nil t nil filename)
+ (goto-char (point-min))
+ (flush-lines "ExifTool Version")
+ (end-of-line)
+ (insert " -- " (buttonize
+ "xdg-open"
+ (lambda (_)
+ (call-process "xdg-open" nil 0 nil filename))))
(buffer-string))
`(infobox-exiftool ,filename)
(called-interactively-p 'interactive)