org/org: new command +org/remove-link, bound to C-c C-S-l

This commit is contained in:
Henrik Lissner 2017-10-05 01:23:56 +02:00
parent 0b5a833638
commit 3b9e67746d
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 16 additions and 0 deletions

View file

@ -282,3 +282,18 @@ with `org-cycle'). Also:
(let ((window-beg (window-start)))
(org-cycle)
(set-window-start nil window-beg))))))
;;;###autoload
(defun +org/remove-link ()
"Unlink the text at point."
(interactive)
(unless (org-in-regexp org-bracket-link-regexp 1)
(user-error "No link at point"))
(save-excursion
(let ((remove (list (match-beginning 0) (match-end 0)))
(description (if (match-end 3)
(org-match-string-no-properties 3)
(org-match-string-no-properties 1))))
(apply #'delete-region remove)
(insert description))))

View file

@ -148,6 +148,7 @@
between the two."
(map! (:map org-mode-map
"RET" #'org-return-indent
"C-c C-S-l" #'+org/remove-link
:n "j" "gj"
:n "k" "gk")