From 3b9e67746d098c18cf2c7ae57e3a7bc24e174a8f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 5 Oct 2017 01:23:56 +0200 Subject: [PATCH] org/org: new command +org/remove-link, bound to C-c C-S-l --- modules/org/org/autoload/org.el | 15 +++++++++++++++ modules/org/org/config.el | 1 + 2 files changed, 16 insertions(+) diff --git a/modules/org/org/autoload/org.el b/modules/org/org/autoload/org.el index 71927441a..9c293b075 100644 --- a/modules/org/org/autoload/org.el +++ b/modules/org/org/autoload/org.el @@ -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)))) + diff --git a/modules/org/org/config.el b/modules/org/org/config.el index 50f27ec8d..32b106788 100644 --- a/modules/org/org/config.el +++ b/modules/org/org/config.el @@ -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")