diff --git a/doc/ChangeLog b/doc/ChangeLog index 4b8389beb..c14fc00e2 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2010-05-08 Carsten Dominik + + * orgcard.tex: Document inline image toggling. + + * org.texi (Handling links): Document inline image toggling. + 2010-05-07 Carsten Dominik * org.texi (Updating the table): Document new buffer-wide diff --git a/doc/org.texi b/doc/org.texi index 5fac58afd..1635611ec 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 4440ab586..0b13217c7 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 3e635d316..137df5538 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2010-05-08 Carsten Dominik + + * 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 * org-wl.el (org-wl-message-field): New function. Return diff --git a/lisp/org.el b/lisp/org.el index b6a085432..f4e8e03c2 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