emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote 4a10683036 5/8: Make stylistic tweaks to denote-


From: ELPA Syncer
Subject: [elpa] externals/denote 4a10683036 5/8: Make stylistic tweaks to denote-link
Date: Sat, 8 Oct 2022 20:57:32 -0400 (EDT)

branch: externals/denote
commit 4a1068303608e67cf2d0bad486e18134854ed51f
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Make stylistic tweaks to denote-link
    
    This builds on the commits b350035, fe66333 by Charanjit Singh:
    <https://github.com/protesilaos/denote/pull/109>.
---
 denote.el | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/denote.el b/denote.el
index e807b97f98..9182690375 100644
--- a/denote.el
+++ b/denote.el
@@ -2241,8 +2241,8 @@ title."
 
 (defun denote-link--format-link (file pattern &optional description)
   "Prepare link to FILE using PATTERN.
-If DESCRIPTION is non-nil, it is used as link description instead
-of FILE's title."
+If DESCRIPTION is non-nil, use it as link description instead of
+FILE's title."
   (let* ((file-id (denote-retrieve-filename-identifier file))
          (file-type (denote-filetype-heuristics file))
          (file-title (unless (string= pattern denote-link--format-id-only)
@@ -2255,20 +2255,23 @@ of FILE's title."
 With optional ID-ONLY, such as a universal prefix
 argument (\\[universal-argument]), insert links with just the
 identifier and no further description. In this case, the link
-format is always [[denote:IDENTIFIER]]. If region is active,
-region is replaced with the link while using the region as link
-title."
+format is always [[denote:IDENTIFIER]].
+
+If region is active, use its text as the link's description
+instead of TARGET's title."
   (interactive (list (denote-file-prompt) current-prefix-arg))
   (let* ((beg (point))
-         (description (when-let (((region-active-p))
-                                 (selected-text 
(buffer-substring-no-properties (region-beginning) (region-end))))
-                        (delete-region (region-beginning) (region-end))
-                        selected-text))
-         (link (denote-link--format-link
-                target
-                (denote-link--file-type-format (buffer-file-name) id-only)
-                description)))
-    (insert link)
+         (description (when-let* (((region-active-p))
+                                  (beg (region-beginning))
+                                  (end (region-end))
+                                  (selected-text 
(buffer-substring-no-properties beg end)))
+                        (delete-region beg end)
+                        selected-text)))
+    (insert
+     (denote-link--format-link
+      target
+      (denote-link--file-type-format (buffer-file-name) id-only)
+      description))
     (unless (derived-mode-p 'org-mode)
       (make-button beg (point) 'type 'denote-link-button))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]