diff options
-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 |