Navigation Menu

Skip to content

Commit

Permalink
Let user customize if image display is refreshed after insertion.
Browse files Browse the repository at this point in the history
Possible options are: always, never, ask
  • Loading branch information
Wolfgang Ramos committed Apr 18, 2018
1 parent 5eeb2ee commit d153375
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.org
Expand Up @@ -77,6 +77,14 @@
make sure that you specify absolute directory names for the attachment
directories.

If =org-attach-screenshot-auto-refresh= is set to =always= the buffers
inline images will be automatically refreshed to display every
inserted image immediately. Set this to =never= if you prefere to
manually refresh inline images. In this case =org-attach-screenshot=
will always just insert the link to the image file. Set this to =ask=
if you want =org-attach-screenshot= to ask you after every insertion
if you would like to refresh the buffer's inline images.

* Motivation
Org with its Babel functionality is a great tool for producing technical
documentation. One can directly use code snippets to produce graphics and
Expand Down
18 changes: 17 additions & 1 deletion org-attach-screenshot.el
Expand Up @@ -71,6 +71,19 @@ always be relative filenames. If nil, the links will just be the
concatenation of the attachment dir and the filename"
:type 'boolean :group 'org-attach-screenshot)

(defcustom org-attach-screenshot-auto-refresh 'always
"Refresh inline image display after inserting an image.
Set this to `always' if you want to see every new image
immediately after calling `org-attach-screenshot'. Set this to
`never' if you prefere to manually refresh inline image display.
In this case `org-attach-screenshot' will always just insert the
link to the image file. Set this to `ask' if you want
`org-attach-screenshot' to ask you after every insertion if you
would like to refresh the buffer's inline images."
:type 'symbol
:options (list 'always 'never 'ask)
:group 'org-attach-screenshot)

;;;###autoload
(defun org-attach-screenshot (prfx filename)
"Take an area screenshot and place it in the entry's attachment directory.
Expand Down Expand Up @@ -138,7 +151,10 @@ the links being already placed inside the text."
(error "screenshot command exited with status %d: %s" status
(mapconcat 'identity (cons cmd args) " ")) )
(message "wrote screenshot to %s" scrpath))
(org-display-inline-images nil t))))
(when (or (eq org-attach-screenshot-auto-refresh 'always)
(and (eq org-attach-screenshot-auto-refresh 'ask)
(y-or-n-p "Refresh inline images?")))
(org-display-inline-images nil t)))))

(defun org-attach-screenshot-get-attach-dir ()
"Return or create the current entry's attachment directory.
Expand Down

0 comments on commit d153375

Please sign in to comment.