From 65bdd404cc25f169bdbda0f757c6e79cbcfd95da Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 6 Mar 2024 06:21:58 +0200 Subject: Add yeetube-iimage-mode-buffer Allow for custom thumbnail size --- yeetube.el | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'yeetube.el') diff --git a/yeetube.el b/yeetube.el index 7f0050b..50cf944 100644 --- a/yeetube.el +++ b/yeetube.el @@ -572,6 +572,29 @@ column." (< (string-to-number (nth 0 split-a)) (string-to-number (nth 0 split-b))) (> units-a units-b)))) +;; Modified from iimage.el for hardcoded width/height +(defun yeetube-iimage-mode-buffer (arg) + "Display images if ARG is non-nil, undisplay them otherwise." + (let ((image-path (cons default-directory iimage-mode-image-search-path)) + file) + (with-silent-modifications + (save-excursion + (dolist (pair iimage-mode-image-regex-alist) + (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 (car yeetube-thumbnail-size) + :max-height (cdr yeetube-thumbnail-size))) + (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." :keymap yeetube-mode-map @@ -599,7 +622,7 @@ column." (display-line-numbers-mode 0) (tabulated-list-init-header) (tabulated-list-print) - (iimage-mode t)) + (yeetube-iimage-mode-buffer t)) (provide 'yeetube) ;;; yeetube.el ends here -- cgit v1.2.3