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.el32
1 files changed, 18 insertions, 14 deletions
diff --git a/emacs/.emacs.d/lisp/my/infobox.el b/emacs/.emacs.d/lisp/my/infobox.el
index 5698042..ff4adb6 100644
--- a/emacs/.emacs.d/lisp/my/infobox.el
+++ b/emacs/.emacs.d/lisp/my/infobox.el
@@ -31,7 +31,11 @@
(cond ((stringp v) v)
((eq v t) "YES")
((eq v :json-false) "NO")
- ((seqp v) (mapconcat #'identity v ", "))
+ ((seqp v)
+ (mapconcat
+ (lambda (x) (if (stringp x) x (prin1-to-string x)))
+ v
+ ", "))
(t (format "%s" v))))
(defun infobox-default-specs (info)
@@ -66,14 +70,19 @@ something like
;; 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)
+ (file-name
+ (if (string-prefix-p "file://" thumb-url)
+ (string-remove-prefix "file://" thumb-url)
+ (make-temp-name "/tmp/infobox-"))))
+ (unless (string-prefix-p "file://" thumb-url)
+ (url-copy-file thumb-url file-name t))
(insert-image (create-image file-name nil nil
- :max-width (window-width nil t)))
+ :max-width (window-pixel-width)
+ :max-height (/ (window-pixel-height) 2)))
(insert "\n")
- (setq n-rows (1+ n-rows)))
+ (setq n-rows (1+ n-rows))
+ (setq info (assoc-delete-all "Thumbnail" info))
+ )
(seq-do
(lambda (pair)
(when pair
@@ -113,8 +122,8 @@ something like
(end-of-line)
(insert " -- " (buttonize
"xdg-open"
- (lambda (_)
- (call-process "xdg-open" nil 0 nil filename))))
+ (lambda (_) (call-process "xdg-open" nil 0 nil filename)))
+ " " (buttonize "find-file" (lambda (_) (find-file filename))))
(buffer-string))
`(infobox-exiftool ,filename)
(called-interactively-p 'interactive)
@@ -162,9 +171,4 @@ something like
(lambda (line) (string-match-p "^[0-9]" line))
(split-string (buffer-string) "\n"))))
-(defun my-call-process-out (command &rest args)
- (with-temp-buffer
- (apply 'call-process (append (list command nil t nil) args))
- (buffer-string)))
-
(provide 'infobox)