diff options
author | Thanos Apollo <[email protected]> | 2024-04-24 15:57:09 +0300 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-04-24 15:57:09 +0300 |
commit | df13f9ffe0bdf565ce6793e62be6dd3dc6e4bf72 (patch) | |
tree | e91295103f5521c67ce8322a6e0eb7aa8bac51fc /.emacs.d | |
parent | 28dbf641ba36b0e31558e90568462483ac3f7dbb (diff) |
emacs:(commands) Add thanos/iimage
Diffstat (limited to '.emacs.d')
-rw-r--r-- | .emacs.d/modules/thanos-commands.el | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/.emacs.d/modules/thanos-commands.el b/.emacs.d/modules/thanos-commands.el index 5911e5e..af9603f 100644 --- a/.emacs.d/modules/thanos-commands.el +++ b/.emacs.d/modules/thanos-commands.el @@ -104,6 +104,7 @@ (defun thanos/load-theme (&optional theme) "Disable current theme and load a new THEME." + (interactive) (let ((theme (or theme (intern (completing-read "Theme: " (custom-available-themes)))))) (disable-theme (car custom-enabled-themes)) (load-theme theme t))) @@ -260,6 +261,35 @@ :password (password-store-get "znc/admin"))) +(defun thanos/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)) + (edges (window-inside-pixel-edges (get-buffer-window))) + 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 120 + :max-height 120) + keymap ,image-map + modification-hooks + (iimage-modification-hook))) + (remove-list-of-text-properties + (match-beginning 0) (match-end 0) + '(display modification-hooks)))))))))) + +(define-minor-mode thanos/iimage-mode nil + :group 'iimage :lighter " iImg" + (thanos/iimage-mode-buffer thanos/iimage-mode)) (provide 'thanos-commands) ;;; thanos-commands.el ends here |