org-download

a fork of abo-abo's org-download
git clone https://git.trogloxene.org/org-download.git
Log | Files | Refs | README

commit 512998718e3d5ced04f15c386e6580a733bd4487
parent 81955fdb145252e86a28972ac053ddfc05536d0b
Author: Feng Shu <tumashu@163.com>
Date:   Sat,  1 Jun 2019 08:54:26 +0800

org-download-insert-link: let it work well with org-list

Before:
1. test
   I

After:
1. test
   #+DOWNLOADED: @screenshot-file @ 2019-06-01 08:52:51
   [[file:data/2f/301706-87b6-42c9-bd6b-ce0758284622/image_2019-06-01_08-52-51.png]]

Fixes #105

Diffstat:
Morg-download.el | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/org-download.el b/org-download.el @@ -420,8 +420,12 @@ It's inserted before the image link and is used to annotate it.") (const :tag "absolute" expand-file-name))) (defun org-download-insert-link (link filename) - (let ((beg (point))) - (if (looking-back "^[ \t]+" (line-beginning-position)) + (let* ((beg (point)) + (line-beg (line-beginning-position)) + (indent (- beg line-beg)) + (in-item-p (org-in-item-p)) + str) + (if (looking-back "^[ \t]+" line-beg) (delete-region (match-beginning 0) (match-end 0)) (newline)) (insert (funcall org-download-annotate-function link)) @@ -442,7 +446,10 @@ It's inserted before the image link and is used to annotate it.") (org-link-escape (funcall org-download-abbreviate-filename-function filename)))) (org-download--display-inline-images) - (buffer-substring-no-properties beg (point)))) + (setq str (buffer-substring-no-properties line-beg (point))) + (when in-item-p + (indent-region line-beg (point) indent)) + str)) (defun org-download--at-comment-p () "Check if current line begins with #+DOWLOADED:."