aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2021-08-27 11:06:25 +0200
committerYann Herklotz <git@yannherklotz.com>2021-08-27 11:06:25 +0200
commitecc0918fc88e4ca818bd5da79b412053df1815b8 (patch)
tree4832ffaf08bd16cc2b38f5a453a71b5c73c91459
parentb4507498aa666de83b1c1840aff9b4ff5f55e5f9 (diff)
parent05cd7ac701b113cef86449cb1a4cd9fc4ad9d720 (diff)
downloademacs-zettelkasten-ecc0918fc88e4ca818bd5da79b412053df1815b8.tar.gz
emacs-zettelkasten-ecc0918fc88e4ca818bd5da79b412053df1815b8.zip
Merge remote-tracking branch 'origin/master'
-rw-r--r--zettelkasten.el13
1 files changed, 9 insertions, 4 deletions
diff --git a/zettelkasten.el b/zettelkasten.el
index d9b2a37..c2d5bdf 100644
--- a/zettelkasten.el
+++ b/zettelkasten.el
@@ -93,10 +93,10 @@ aims to remove."
(string-match "[^0-9]*\\([0-9]+\\)" note)
(match-string 1 note))
-(defun zettelkasten--format-link (note)
+(defun zettelkasten--format-link (note &optional link-text)
"Format a link to a NOTE."
(format zettelkasten-link-format
- (zettelkasten--get-note-title note)
+ (or link-text (zettelkasten--get-note-title note))
(zettelkasten--get-id note)
zettelkasten-extension))
@@ -378,11 +378,16 @@ publishing."
;;; ---------------------
(defun zettelkasten-insert-link (note)
- "Insert a link to another NOTE in the current note."
+ "Insert a link to another NOTE in the current note.
+if region is active use that as link text"
(interactive
(list (completing-read "Notes: "
(zettelkasten--list-notes) nil 'match)))
- (insert (zettelkasten--format-link (zettelkasten--get-id note))))
+ (let ((region-text (when (use-region-p)
+ (prog1 (buffer-substring-no-properties (region-beginning)
+ (region-end))
+ (delete-region (region-beginning) (region-end))))))
+ (insert (zettelkasten--format-link (zettelkasten--get-id note) region-text))))
(defun zettelkasten-create-new-note (prefix)
"Create a new zettelkasten.