diff options
author | Thanos Apollo <[email protected]> | 2024-02-25 04:33:07 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-02-25 04:33:07 +0200 |
commit | d563a5645febaa122a749ebbf48c3a8e25ab7121 (patch) | |
tree | 3b1fb7c9e8c74bf166679fecb785194e016550e4 | |
parent | 9d91bc23ce9599ca89921c0f2b11be039da49887 (diff) |
Add yeetube-iimage-mode-buffer
-rw-r--r-- | yeetube.el | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -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." |