summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2010-05-07 09:58:27 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2010-05-08 09:20:32 +0200
commit7147508d8137edf2d8efca29c847a3e1358c99f3 (patch)
tree3f788c4d61b307206418bd73ba6793726c947711
parentac40bde6c6ec1823d873de73fe642f1eabd03f5f (diff)
downloadorg-mode-7147508d8137edf2d8efca29c847a3e1358c99f3.tar.gz
Implement inline display of linked images
-rw-r--r--doc/ChangeLog6
-rw-r--r--doc/org.texi14
-rw-r--r--doc/orgcard.tex1
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/org.el51
5 files changed, 73 insertions, 6 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 4b8389b..c14fc00 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,9 @@
+2010-05-08 Carsten Dominik <carsten.dominik@gmail.com>
+
+ * orgcard.tex: Document inline image toggling.
+
+ * org.texi (Handling links): Document inline image toggling.
+
2010-05-07 Carsten Dominik <carsten.dominik@gmail.com>
* org.texi (Updating the table): Document new buffer-wide
diff --git a/doc/org.texi b/doc/org.texi
index 5fac58a..1635611 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -2983,14 +2983,14 @@ to the current directory using @samp{../}. Otherwise an absolute path
is used, if possible with @samp{~/} for your home directory. You can
force an absolute path with two @kbd{C-u} prefixes.
@c
-@item C-c C-l @r{(with cursor on existing link)}
+@item C-c C-l @ @r{(with cursor on existing link)}
When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
link and description parts of the link.
@c
@cindex following links
@kindex C-c C-o
-@kindex RET
-@item C-c C-o @r{or} @key{RET}
+@kindex @key{RET}
+@item C-c C-o @ @r{(or, if @code{org-return-follows-link} is set, also} @key{RET}
@vindex org-file-apps
Open link at point. This will launch a web browser for URLs (using
@command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
@@ -3021,6 +3021,14 @@ Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
internal links to be displayed in another window@footnote{See the
variable @code{org-display-internal-link-with-indirect-buffer}}.
@c
+@cindex inlining images
+@cindex images, inlining
+@kindex C-c C-x C-v
+@item C-c C-x C-v
+Toggle the inline display of linked images. Normally this will only inline
+images that have no description part in the link, i.e. images that will also
+be inlined during export. When called with a prefix argument, also display
+images that do have a link description.
@cindex mark ring
@kindex C-c %
@item C-c %
diff --git a/doc/orgcard.tex b/doc/orgcard.tex
index 4440ab5..0b13217 100644
--- a/doc/orgcard.tex
+++ b/doc/orgcard.tex
@@ -442,6 +442,7 @@ formula, \kbd{:=} a field formula.
\key{find next link}{C-c C-x C-n}
\key{find previous link}{C-c C-x C-p}
\key{edit code snippet of file at point}{C-c '}
+\key{toggle inline display of linked images}{C-c C-x C-v}
{\bf Internal Links}
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3e635d3..137df55 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2010-05-08 Carsten Dominik <carsten.dominik@gmail.com>
+
+ * org.el (org-inline-image-overlays): New variable.
+ (org-toggle-inline-images, org-display-inline-images)
+ (org-remove-inline-images): New commands.
+ (org-mode-map): Define a key for `org-toggle-inline-images'.
+
2010-05-08 David Maus <dmaus@ictsoc.de>
* org-wl.el (org-wl-message-field): New function. Return
diff --git a/lisp/org.el b/lisp/org.el
index b6a0854..f4e8e03 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1295,8 +1295,7 @@ implementation is bad."
:type 'boolean)
(defcustom org-return-follows-link nil
- "Non-nil means on links RET will follow the link.
-Needs to be set before org.el is loaded."
+ "Non-nil means on links RET will follow the link."
:group 'org-link-follow
:type 'boolean)
@@ -15463,6 +15462,52 @@ SNIPPETS-P indicates if this is run to create snippet images for HTML."
"Return string to be used as color value for an RGB component."
(format "%g" (/ value 65535.0)))
+;; Image display
+
+
+(defvar org-inline-image-overlays nil)
+(make-variable-buffer-local 'org-inline-image-overlays)
+
+(defun org-toggle-inline-images (&optional include-linked)
+ "Toggle the display of inline images.
+INCLUDE-LINKED is passed to `org-display-inline-images'."
+ (interactive "P")
+ (if org-inline-image-overlays
+ (progn
+ (org-remove-inline-images)
+ (message "Inline image display turned off"))
+ (org-display-inline-images arg)
+ (if org-inline-image-overlays
+ (message "%d images displayed inline"
+ (length org-inline-image-overlays))
+ (message "No images to display inline"))))
+
+(defun org-display-inline-images (&optional include-linked)
+ "Display inline images.
+Normally only links without a description part are inlined, because this
+is how it will work for export. When INCLUDE-LINKED is set, also links
+with a description part will be inlined."
+ (interactive "P")
+ (org-remove-inline-images)
+ (goto-char (point-min))
+ (let ((re (concat "\\[\\[\\(file:\\|\\./\\)\\(~?" "[-+./_0-9a-zA-Z]+"
+ (substring (org-image-file-name-regexp) 0 -2)
+ "\\)\\]" (if include-linked "" "\\]")))
+ file ov)
+ (while (re-search-forward re nil t)
+ (setq file (expand-file-name (match-string 2)))
+ (when (file-exists-p file)
+ (setq ov (make-overlay (match-beginning 0) (match-end 0)))
+ (overlay-put ov 'display (create-image file))
+ (overlay-put ov 'face 'default)
+ (push ov org-inline-image-overlays)))))
+
+(defun org-remove-inline-images ()
+ "Remove inline display of images."
+ (interactive)
+ (mapc 'delete-overlay org-inline-image-overlays)
+ (setq org-inline-image-overlays nil))
+
;;;; Key bindings
;; Make `C-c C-x' a prefix key
@@ -15632,6 +15677,7 @@ SNIPPETS-P indicates if this is run to create snippet images for HTML."
(org-defkey org-mode-map "\C-c\C-x\C-r" 'org-clock-report)
(org-defkey org-mode-map "\C-c\C-x\C-u" 'org-dblock-update)
(org-defkey org-mode-map "\C-c\C-x\C-l" 'org-preview-latex-fragment)
+(org-defkey org-mode-map "\C-c\C-x\C-v" 'org-toggle-inline-images)
(org-defkey org-mode-map "\C-c\C-x\C-b" 'org-toggle-checkbox)
(org-defkey org-mode-map "\C-c\C-xp" 'org-set-property)
(org-defkey org-mode-map "\C-c\C-xe" 'org-set-effort)
@@ -18636,7 +18682,6 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
(add-hook 'speedbar-visiting-tag-hook
(lambda () (and (org-mode-p) (org-show-context 'org-goto))))))
-
;;; Fixes and Hacks for problems with other packages
;; Make flyspell not check words in links, to not mess up our keymap