diff options
| author | Stefan Monnier | 2010-05-11 14:51:27 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2010-05-11 14:51:27 -0400 |
| commit | f2b9ed185adcd8e49934ebaa9247cac49dcc0d1b (patch) | |
| tree | d53799d25c3909a9e884bb8c133ee1bc37351e0c | |
| parent | fd5b9fa30285a37965192c1a5104e5bdd80fb50b (diff) | |
| download | emacs-f2b9ed185adcd8e49934ebaa9247cac49dcc0d1b.tar.gz emacs-f2b9ed185adcd8e49934ebaa9247cac49dcc0d1b.zip | |
* iimage.el: Misc cleanup.
(iimage-mode-map): Move initialization into declaration.
(iimage-mode-buffer): Use with-silent-modifications.
Simplify calling convention. Adjust callers.
(iimage-mode): Don't run hook redundantly.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/iimage.el | 73 |
2 files changed, 37 insertions, 43 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8c3883808f2..1189b7c658c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2010-05-11 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2010-05-11 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * iimage.el (iimage-mode-map): Move initialization into declaration. | ||
| 4 | (iimage-mode-buffer): Use with-silent-modifications. | ||
| 5 | Simplify calling convention. Adjust callers. | ||
| 6 | (iimage-mode): Don't run hook redundantly. | ||
| 7 | |||
| 3 | * minibuffer.el (completion-pcm--pattern->regex): | 8 | * minibuffer.el (completion-pcm--pattern->regex): |
| 4 | Fix last change (bug#6160). | 9 | Fix last change (bug#6160). |
| 5 | 10 | ||
| @@ -800,6 +805,8 @@ | |||
| 800 | 805 | ||
| 801 | 2010-04-21 Stefan Monnier <monnier@iro.umontreal.ca> | 806 | 2010-04-21 Stefan Monnier <monnier@iro.umontreal.ca> |
| 802 | 807 | ||
| 808 | Make the log-edit comments use RFC822 format throughout. | ||
| 809 | |||
| 803 | * vc.el (vc-checkin, vc-modify-change-comment): | 810 | * vc.el (vc-checkin, vc-modify-change-comment): |
| 804 | Adjust to new vc-start/finish-logentry. | 811 | Adjust to new vc-start/finish-logentry. |
| 805 | (vc-find-conflicted-file): New command. | 812 | (vc-find-conflicted-file): New command. |
diff --git a/lisp/iimage.el b/lisp/iimage.el index e52a7d37301..87591724dbb 100644 --- a/lisp/iimage.el +++ b/lisp/iimage.el | |||
| @@ -55,19 +55,17 @@ | |||
| 55 | :group 'image) | 55 | :group 'image) |
| 56 | 56 | ||
| 57 | (defconst iimage-version "1.1") | 57 | (defconst iimage-version "1.1") |
| 58 | (defvar iimage-mode nil) | ||
| 59 | (defvar iimage-mode-map nil) | ||
| 60 | 58 | ||
| 61 | ;; Set up key map. | 59 | (defvar iimage-mode-map |
| 62 | (unless iimage-mode-map | 60 | (let ((map (make-sparse-keymap))) |
| 63 | (setq iimage-mode-map (make-sparse-keymap)) | 61 | (define-key map "\C-l" 'iimage-recenter) |
| 64 | (define-key iimage-mode-map "\C-l" 'iimage-recenter)) | 62 | map)) |
| 65 | 63 | ||
| 66 | (defun iimage-recenter (&optional arg) | 64 | (defun iimage-recenter (&optional arg) |
| 67 | "Re-draw images and recenter." | 65 | "Re-draw images and recenter." |
| 68 | (interactive "P") | 66 | (interactive "P") |
| 69 | (iimage-mode-buffer 0) | 67 | (iimage-mode-buffer nil) |
| 70 | (iimage-mode-buffer 1) | 68 | (iimage-mode-buffer t) |
| 71 | (recenter arg)) | 69 | (recenter arg)) |
| 72 | 70 | ||
| 73 | (defvar iimage-mode-image-filename-regex | 71 | (defvar iimage-mode-image-filename-regex |
| @@ -81,7 +79,7 @@ | |||
| 81 | `((,(concat "\\(`?file://\\|\\[\\[\\|<\\|`\\)?" | 79 | `((,(concat "\\(`?file://\\|\\[\\[\\|<\\|`\\)?" |
| 82 | "\\(" iimage-mode-image-filename-regex "\\)" | 80 | "\\(" iimage-mode-image-filename-regex "\\)" |
| 83 | "\\(\\]\\]\\|>\\|'\\)?") . 2)) | 81 | "\\(\\]\\]\\|>\\|'\\)?") . 2)) |
| 84 | "*Alist of filename REGEXP vs NUM. | 82 | "*Alist of filename REGEXP vs NUM. |
| 85 | Each element looks like (REGEXP . NUM). | 83 | Each element looks like (REGEXP . NUM). |
| 86 | NUM specifies which parenthesized expression in the regexp. | 84 | NUM specifies which parenthesized expression in the regexp. |
| 87 | 85 | ||
| @@ -90,54 +88,43 @@ Examples of image filename regexps: | |||
| 90 | `file://foo.png' | 88 | `file://foo.png' |
| 91 | \\[\\[foo.gif]] | 89 | \\[\\[foo.gif]] |
| 92 | <foo.png> | 90 | <foo.png> |
| 93 | foo.JPG | 91 | foo.JPG") |
| 94 | ") | ||
| 95 | 92 | ||
| 96 | (defvar iimage-mode-image-search-path nil | 93 | (defvar iimage-mode-image-search-path nil |
| 97 | "*List of directories to search for image files for iimage-mode.") | 94 | "*List of directories to search for image files for `iimage-mode'.") |
| 98 | 95 | ||
| 99 | ;;;###autoload | 96 | ;;;###autoload |
| 100 | (defun turn-on-iimage-mode () | 97 | (define-obsolete-function-alias 'turn-on-iimage-mode 'iimage-mode "24.1") |
| 101 | "Unconditionally turn on iimage mode." | ||
| 102 | (interactive) | ||
| 103 | (iimage-mode 1)) | ||
| 104 | 98 | ||
| 105 | (defun turn-off-iimage-mode () | 99 | (defun turn-off-iimage-mode () |
| 106 | "Unconditionally turn off iimage mode." | 100 | "Unconditionally turn off iimage mode." |
| 107 | (interactive) | 101 | (interactive) |
| 108 | (iimage-mode 0)) | 102 | (iimage-mode 0)) |
| 109 | 103 | ||
| 110 | (defalias 'iimage-locate-file 'locate-file) | ||
| 111 | |||
| 112 | (defun iimage-mode-buffer (arg) | 104 | (defun iimage-mode-buffer (arg) |
| 113 | "Display/undisplay images. | 105 | "Display images if ARG is non-nil, undisplay them otherwise." |
| 114 | With numeric ARG, display the images if and only if ARG is positive." | 106 | (let ((image-path (cons default-directory iimage-mode-image-search-path)) |
| 115 | (interactive) | 107 | file) |
| 116 | (let ((ing (if (numberp arg) | 108 | (with-silent-modifications |
| 117 | (> arg 0) | 109 | (save-excursion |
| 118 | iimage-mode)) | 110 | (goto-char (point-min)) |
| 119 | (modp (buffer-modified-p (current-buffer))) | 111 | (dolist (pair iimage-mode-image-regex-alist) |
| 120 | file buffer-read-only) | 112 | (while (re-search-forward (car pair) nil t) |
| 121 | (save-excursion | 113 | (if (and (setq file (match-string (cdr pair))) |
| 122 | (goto-char (point-min)) | 114 | (setq file (locate-file file image-path))) |
| 123 | (dolist (pair iimage-mode-image-regex-alist) | 115 | ;; FIXME: we don't mark our images, so we can't reliably |
| 124 | (while (re-search-forward (car pair) nil t) | 116 | ;; remove them either (we may leave some of ours, and we |
| 125 | (if (and (setq file (match-string (cdr pair))) | 117 | ;; may remove other packages's display properties). |
| 126 | (setq file (iimage-locate-file file | 118 | (if arg |
| 127 | (cons default-directory | 119 | (add-text-properties (match-beginning 0) (match-end 0) |
| 128 | iimage-mode-image-search-path)))) | 120 | (list 'display (create-image file))) |
| 129 | (if ing | 121 | (remove-text-properties (match-beginning 0) (match-end 0) |
| 130 | (add-text-properties (match-beginning 0) (match-end 0) | 122 | '(display)))))))))) |
| 131 | (list 'display (create-image file))) | ||
| 132 | (remove-text-properties (match-beginning 0) (match-end 0) | ||
| 133 | '(display))))))) | ||
| 134 | (set-buffer-modified-p modp))) | ||
| 135 | 123 | ||
| 136 | ;;;###autoload | 124 | ;;;###autoload |
| 137 | (define-minor-mode iimage-mode | 125 | (define-minor-mode iimage-mode |
| 138 | "Toggle inline image minor mode." | 126 | "Toggle inline image minor mode." |
| 139 | :group 'iimage :lighter " iImg" :keymap iimage-mode-map | 127 | :group 'iimage :lighter " iImg" :keymap iimage-mode-map |
| 140 | (run-hooks 'iimage-mode-hook) | ||
| 141 | (iimage-mode-buffer iimage-mode)) | 128 | (iimage-mode-buffer iimage-mode)) |
| 142 | 129 | ||
| 143 | (provide 'iimage) | 130 | (provide 'iimage) |