Mercurial > emacs
annotate lisp/iimage.el @ 112453:06719a229a46 default tip
* calc/calc.el (calc-default-power-reference-level)
(calc-default-field-reference-level): New variables.
* calc/calc-units.el (math-standard-units): Add dB and Np.
(math-logunits): New variable.
(math-extract-logunits, math-logcombine, calcFunc-luplus)
(calcFunc-luminus, calc-luplus, calc-luminus, math-logunit-level)
(calcFunc-fieldlevel, calcFunc-powerlevel, calc-level): New
functions.
(math-find-base-units-rec): Add entry for ln(10).
* calc/calc-help.el (calc-u-prefix-help): Add logarithmic help.
(calc-ul-prefix-help): New function.
* calc/calc-ext.el (calc-init-extensions): Autoload new units
functions. Add keybindings for new units functions.
| author | Jay Belanger <jay.p.belanger@gmail.com> |
|---|---|
| date | Sun, 23 Jan 2011 23:08:04 -0600 |
| parents | 61f7601898b1 |
| children |
| rev | line source |
|---|---|
| 55525 | 1 ;;; iimage.el --- Inline image minor mode. |
| 2 | |
|
112284
61f7601898b1
Refill some copyright headers.
Glenn Morris <rgm@gnu.org>
parents:
112228
diff
changeset
|
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
|
61f7601898b1
Refill some copyright headers.
Glenn Morris <rgm@gnu.org>
parents:
112228
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
| 55525 | 5 |
| 6 ;; Author: KOSEKI Yoshinori <kose@meadowy.org> | |
| 7 ;; Maintainer: KOSEKI Yoshinori <kose@meadowy.org> | |
| 8 ;; Keywords: multimedia | |
| 9 | |
| 10 ;; This file is part of GNU Emacs. | |
| 11 | |
|
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
| 55525 | 13 ;; it under the terms of the GNU General Public License as published by |
|
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
|
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; (at your option) any later version. |
| 55525 | 16 |
| 17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 ;; GNU General Public License for more details. | |
| 21 | |
| 22 ;; You should have received a copy of the GNU General Public License | |
|
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
| 55525 | 24 |
| 25 ;;; Commentary: | |
| 26 | |
|
56331
401149ed59c0
(turn-on-iimage-mode, iimage-mode): Add autoload cookies.
Eli Zaretskii <eliz@gnu.org>
parents:
55532
diff
changeset
|
27 ;; Iimage is a minor mode that displays images, when image-filename |
|
401149ed59c0
(turn-on-iimage-mode, iimage-mode): Add autoload cookies.
Eli Zaretskii <eliz@gnu.org>
parents:
55532
diff
changeset
|
28 ;; exists in the buffer. |
| 55525 | 29 ;; http://www.netlaputa.ne.jp/~kose/Emacs/iimage.html |
| 30 ;; | |
| 31 ;; ** Display images in *Info* buffer. | |
| 32 ;; | |
| 110796 | 33 ;; (add-hook 'info-mode-hook 'iimage-mode) |
| 55525 | 34 ;; |
| 35 ;; .texinfo: @file{file://foo.png} | |
| 36 ;; .info: `file://foo.png' | |
| 37 ;; | |
| 38 ;; ** Display images in Wiki buffer. | |
| 39 ;; | |
| 110796 | 40 ;; (add-hook 'wiki-mode-hook 'iimage-mode) |
| 55525 | 41 ;; |
| 42 ;; wiki-file: [[foo.png]] | |
| 43 | |
| 44 ;;; Code: | |
| 45 | |
| 46 (eval-when-compile | |
| 47 (require 'image-file)) | |
| 48 | |
|
61272
3933597e185e
(iimage): New customization group.
Lute Kamstra <lute@gnu.org>
parents:
56331
diff
changeset
|
49 (defgroup iimage nil |
|
3933597e185e
(iimage): New customization group.
Lute Kamstra <lute@gnu.org>
parents:
56331
diff
changeset
|
50 "Support for inline images." |
|
3933597e185e
(iimage): New customization group.
Lute Kamstra <lute@gnu.org>
parents:
56331
diff
changeset
|
51 :version "22.1" |
|
3933597e185e
(iimage): New customization group.
Lute Kamstra <lute@gnu.org>
parents:
56331
diff
changeset
|
52 :group 'image) |
|
3933597e185e
(iimage): New customization group.
Lute Kamstra <lute@gnu.org>
parents:
56331
diff
changeset
|
53 |
| 110796 | 54 (defcustom iimage-mode-image-search-path nil |
| 55 "List of directories to search for image files for iimage-mode." | |
| 56 :type '(choice (const nil) (repeat directory)) | |
| 57 :group 'iimage) | |
| 55525 | 58 |
| 59 (defvar iimage-mode-image-filename-regex | |
| 60 (concat "[-+./_0-9a-zA-Z]+\\." | |
| 61 (regexp-opt (nconc (mapcar #'upcase | |
| 62 image-file-name-extensions) | |
| 63 image-file-name-extensions) | |
| 64 t))) | |
| 65 | |
| 110796 | 66 (defcustom iimage-mode-image-regex-alist |
| 55525 | 67 `((,(concat "\\(`?file://\\|\\[\\[\\|<\\|`\\)?" |
| 68 "\\(" iimage-mode-image-filename-regex "\\)" | |
| 69 "\\(\\]\\]\\|>\\|'\\)?") . 2)) | |
| 110796 | 70 "Alist of filename REGEXP vs NUM. |
| 55525 | 71 Each element looks like (REGEXP . NUM). |
| 72 NUM specifies which parenthesized expression in the regexp. | |
| 73 | |
| 110796 | 74 Examples of image filename patterns to match: |
| 55525 | 75 file://foo.png |
| 76 `file://foo.png' | |
| 77 \\[\\[foo.gif]] | |
| 78 <foo.png> | |
| 79 foo.JPG | |
| 110796 | 80 " |
| 81 :type '(alist :key-type regexp :value-type integer) | |
| 82 :group 'iimage) | |
| 55525 | 83 |
| 110796 | 84 (defvar iimage-mode-map |
| 85 (let ((map (make-sparse-keymap))) | |
| 86 (define-key map "\C-l" 'iimage-recenter) | |
| 87 map) | |
| 88 "Keymap used in `iimage-mode'.") | |
| 89 | |
| 90 (defun iimage-recenter (&optional arg) | |
| 91 "Re-draw images and recenter." | |
| 92 (interactive "P") | |
| 93 (iimage-mode-buffer nil) | |
| 94 (iimage-mode-buffer t) | |
| 95 (recenter arg)) | |
|
56331
401149ed59c0
(turn-on-iimage-mode, iimage-mode): Add autoload cookies.
Eli Zaretskii <eliz@gnu.org>
parents:
55532
diff
changeset
|
96 |
|
401149ed59c0
(turn-on-iimage-mode, iimage-mode): Add autoload cookies.
Eli Zaretskii <eliz@gnu.org>
parents:
55532
diff
changeset
|
97 ;;;###autoload |
|
108488
925f002ec4ab
* iimage.el: Misc cleanup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
98 (define-obsolete-function-alias 'turn-on-iimage-mode 'iimage-mode "24.1") |
| 55525 | 99 |
| 100 (defun turn-off-iimage-mode () | |
|
108488
925f002ec4ab
* iimage.el: Misc cleanup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
101 "Unconditionally turn off iimage mode." |
| 55525 | 102 (interactive) |
| 103 (iimage-mode 0)) | |
| 104 | |
|
108903
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
105 (defun iimage-modification-hook (beg end) |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
106 "Remove display property if a display region is modified." |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
107 ;;(debug-print "ii1 begin %d, end %d\n" beg end) |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
108 (let ((inhibit-modification-hooks t) |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
109 (beg (previous-single-property-change end 'display |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
110 nil (line-beginning-position))) |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
111 (end (next-single-property-change beg 'display |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
112 nil (line-end-position)))) |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
113 (when (and beg end (plist-get (text-properties-at beg) 'display)) |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
114 ;;(debug-print "ii2 begin %d, end %d\n" beg end) |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
115 (remove-text-properties beg end |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
116 '(display nil modification-hooks nil))))) |
|
56331
401149ed59c0
(turn-on-iimage-mode, iimage-mode): Add autoload cookies.
Eli Zaretskii <eliz@gnu.org>
parents:
55532
diff
changeset
|
117 |
| 55525 | 118 (defun iimage-mode-buffer (arg) |
|
108488
925f002ec4ab
* iimage.el: Misc cleanup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
119 "Display images if ARG is non-nil, undisplay them otherwise." |
|
925f002ec4ab
* iimage.el: Misc cleanup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
120 (let ((image-path (cons default-directory iimage-mode-image-search-path)) |
|
925f002ec4ab
* iimage.el: Misc cleanup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
121 file) |
|
925f002ec4ab
* iimage.el: Misc cleanup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
122 (with-silent-modifications |
|
925f002ec4ab
* iimage.el: Misc cleanup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
123 (save-excursion |
|
925f002ec4ab
* iimage.el: Misc cleanup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
124 (goto-char (point-min)) |
|
925f002ec4ab
* iimage.el: Misc cleanup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
125 (dolist (pair iimage-mode-image-regex-alist) |
|
925f002ec4ab
* iimage.el: Misc cleanup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
126 (while (re-search-forward (car pair) nil t) |
|
108903
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
127 (when (and (setq file (match-string (cdr pair))) |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
128 (setq file (locate-file file image-path))) |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
129 ;; FIXME: we don't mark our images, so we can't reliably |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
130 ;; remove them either (we may leave some of ours, and we |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
131 ;; may remove other packages's display properties). |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
132 (if arg |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
133 (add-text-properties (match-beginning 0) (match-end 0) |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
134 `(display ,(create-image file) |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
135 modification-hooks |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
136 (iimage-modification-hook))) |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
137 (remove-text-properties (match-beginning 0) (match-end 0) |
|
bbdc76e1b06c
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108488
diff
changeset
|
138 '(display modification-hooks)))))))))) |
| 55525 | 139 |
|
56331
401149ed59c0
(turn-on-iimage-mode, iimage-mode): Add autoload cookies.
Eli Zaretskii <eliz@gnu.org>
parents:
55532
diff
changeset
|
140 ;;;###autoload |
| 55525 | 141 (define-minor-mode iimage-mode |
| 142 "Toggle inline image minor mode." | |
|
61272
3933597e185e
(iimage): New customization group.
Lute Kamstra <lute@gnu.org>
parents:
56331
diff
changeset
|
143 :group 'iimage :lighter " iImg" :keymap iimage-mode-map |
| 55525 | 144 (iimage-mode-buffer iimage-mode)) |
| 145 | |
| 146 (provide 'iimage) | |
| 147 | |
| 148 ;;; iimage.el ends here |
