aboutsummaryrefslogtreecommitdiff
path: root/org-link-edit.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2019-01-24 19:59:26 -0500
committerKyle Meyer <kyle@kyleam.com>2019-01-24 20:01:42 -0500
commit9f0209543318c331c5a4051750ea817370d234f6 (patch)
treeaacc6eafc5442388bc11a4565666bcfcf8230da6 /org-link-edit.el
parentd6019ec351d123b4b4f499d18068b72a187fafe6 (diff)
downloadorg-link-edit-9f0209543318c331c5a4051750ea817370d234f6.tar.gz
transport: Let caller overwrite previous description
The existing description may not be of interest to the caller, especially if it was automatically generated by org-store-link.
Diffstat (limited to 'org-link-edit.el')
-rw-r--r--org-link-edit.el21
1 files changed, 15 insertions, 6 deletions
diff --git a/org-link-edit.el b/org-link-edit.el
index 00cc109..200ddb9 100644
--- a/org-link-edit.el
+++ b/org-link-edit.el
@@ -338,7 +338,7 @@ If N is negative, barf trailing blobs instead of leading blobs."
(user-error "No %s link found" (if previous "previous" "next")))))
;;;###autoload
-(defun org-link-edit-transport-next-link (&optional previous beg end)
+(defun org-link-edit-transport-next-link (&optional previous beg end overwrite)
"Move the next link to point.
If the region is active, use the selected text as the link's
@@ -349,10 +349,15 @@ the next link.
Non-interactively, use the text between BEG and END as the
description, moving the next (or previous) link relative to BEG
-and END."
- (interactive (cons current-prefix-arg
- (and (use-region-p)
- (list (region-beginning) (region-end)))))
+and END. By default, refuse to overwrite an existing
+description. If OVERWRITE is `ask', prompt for confirmation
+before overwriting; for any other non-nil value, overwrite
+without asking."
+ (interactive `(,current-prefix-arg
+ ,@(if (use-region-p)
+ (list (region-beginning) (region-end))
+ (list nil nil))
+ ask))
(let ((pt (point))
(desc-bounds (cond
((and beg end)
@@ -376,7 +381,11 @@ and END."
(goto-char (or (car desc-bounds) pt))
(cl-multiple-value-bind (link-beg link-end link orig-desc)
(org-link-edit--next-link-data previous)
- (unless (or (not desc-bounds) (= (length orig-desc) 0))
+ (unless (or (not desc-bounds)
+ (= (length orig-desc) 0)
+ (if (eq overwrite 'ask)
+ (y-or-n-p "Overwrite existing description?")
+ overwrite))
(user-error "Link already has a description"))
(delete-region link-beg link-end)
(insert (org-make-link-string