25 |
|
|
26 |
;;; Commentary: |
;;; Commentary: |
27 |
|
|
28 |
;; Iimage is a minor mode that display a images, when image-filename |
;; Iimage is a minor mode that displays images, when image-filename |
29 |
;; exists in buffer. |
;; exists in the buffer. |
30 |
;; http://www.netlaputa.ne.jp/~kose/Emacs/iimage.html |
;; http://www.netlaputa.ne.jp/~kose/Emacs/iimage.html |
31 |
;; |
;; |
32 |
;; Add to your `~/.emacs': |
;; Add to your `~/.emacs': |
33 |
;; (autoload 'iimage-mode "iimage" "SUpport Inline image minor mode." t) |
;; (autoload 'iimage-mode "iimage" "Support Inline image minor mode." t) |
34 |
|
;; (autoload 'turn-on-iimage-mode "iimage" "Turn on Inline image minor mode." t) |
35 |
;; |
;; |
36 |
;; ** Display images in *Info* buffer. |
;; ** Display images in *Info* buffer. |
37 |
;; |
;; |
51 |
(eval-when-compile |
(eval-when-compile |
52 |
(require 'image-file)) |
(require 'image-file)) |
53 |
|
|
54 |
(defconst iimage-version "1.0") |
(defconst iimage-version "1.1") |
55 |
(defvar iimage-mode nil) |
(defvar iimage-mode nil) |
56 |
(defvar iimage-mode-map nil) |
(defvar iimage-mode-map nil) |
57 |
|
|
90 |
foo.JPG |
foo.JPG |
91 |
") |
") |
92 |
|
|
93 |
|
(defvar iimage-mode-image-search-path nil |
94 |
|
"*List of directories to search for image files for iimage-mode.") |
95 |
|
|
96 |
|
;;;###autoload |
97 |
(defun turn-on-iimage-mode () |
(defun turn-on-iimage-mode () |
98 |
"Unconditionally turn on iimage mode." |
"Unconditionally turn on iimage mode." |
99 |
(interactive) |
(interactive) |
104 |
(interactive) |
(interactive) |
105 |
(iimage-mode 0)) |
(iimage-mode 0)) |
106 |
|
|
107 |
|
;; Emacs21.3 or earlier does not heve locate-file. |
108 |
|
(if (fboundp 'locate-file) |
109 |
|
(defalias 'iimage-locate-file 'locate-file) |
110 |
|
(defun iimage-locate-file (filename path) |
111 |
|
(locate-library filename t path))) |
112 |
|
|
113 |
(defun iimage-mode-buffer (arg) |
(defun iimage-mode-buffer (arg) |
114 |
"Display/Undisplay Images. |
"Display/Undisplay Images. |
115 |
With numeric ARG, display the images if and only if ARG is positive." |
With numeric ARG, display the images if and only if ARG is positive." |
124 |
(dolist (pair iimage-mode-image-regex-alist) |
(dolist (pair iimage-mode-image-regex-alist) |
125 |
(while (re-search-forward (car pair) nil t) |
(while (re-search-forward (car pair) nil t) |
126 |
(if (and (setq file (match-string (cdr pair))) |
(if (and (setq file (match-string (cdr pair))) |
127 |
(setq file (expand-file-name file default-directory)) |
(setq file (iimage-locate-file file |
128 |
(file-exists-p file)) |
(cons default-directory |
129 |
|
iimage-mode-image-search-path)))) |
130 |
(if ing |
(if ing |
131 |
(add-text-properties (match-beginning 0) (match-end 0) |
(add-text-properties (match-beginning 0) (match-end 0) |
132 |
(list 'display (create-image file))) |
(list 'display (create-image file))) |
134 |
'(display))))))) |
'(display))))))) |
135 |
(set-buffer-modified-p modp))) |
(set-buffer-modified-p modp))) |
136 |
|
|
137 |
|
;;;###autoload |
138 |
(define-minor-mode iimage-mode |
(define-minor-mode iimage-mode |
139 |
"Toggle inline image minor mode." |
"Toggle inline image minor mode." |
140 |
nil " iImg" iimage-mode-map |
nil " iImg" iimage-mode-map |