summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-02-25 04:33:07 +0200
committerThanos Apollo <[email protected]>2024-02-25 04:33:07 +0200
commitd563a5645febaa122a749ebbf48c3a8e25ab7121 (patch)
tree3b1fb7c9e8c74bf166679fecb785194e016550e4
parent9d91bc23ce9599ca89921c0f2b11be039da49887 (diff)
Add yeetube-iimage-mode-buffer
-rw-r--r--yeetube.el30
1 files changed, 29 insertions, 1 deletions
diff --git a/yeetube.el b/yeetube.el
index 2ea8262..fa111a4 100644
--- a/yeetube.el
+++ b/yeetube.el
@@ -567,7 +567,35 @@ column."
(units-b (length (member (nth 1 split-b) intervals))))
(if (= units-a units-b)
(< (string-to-number (nth 0 split-a)) (string-to-number (nth 0 split-b)))
- (> units-a units-b))))
+ (> units-a units-b))))
+
+(defun yeetube-iimage-mode-buffer (arg)
+ "Display images if ARG is non-nil, undisplay them otherwise.
+
+Modified version of `iimage-mode-buffer' to specify height & width and
+image-path."
+ (let ((image-path (list (expand-file-name temporary-file-directory)))
+ file)
+ (with-silent-modifications
+ (save-excursion
+ (cl-loop for pair in iimage-mode-image-regex-alist do
+ (goto-char (point-min))
+ (while (re-search-forward (car pair) nil t)
+ (when (and (setq file (match-string (cdr pair)))
+ (setq file (locate-file file image-path)))
+ (if arg
+ (add-text-properties
+ (match-beginning 0) (match-end 0)
+ `(display
+ ,(create-image file nil nil
+ :max-width yeetube-thumbnail-width
+ :max-height yeetube-thumbnail-height)
+ keymap ,image-map
+ modification-hooks
+ (iimage-modification-hook)))
+ (remove-list-of-text-properties
+ (match-beginning 0) (match-end 0)
+ '(display modification-hooks))))))))))
(define-derived-mode yeetube-mode tabulated-list-mode "Yeetube"
"Yeetube mode."