[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote fe8042e302 337/355: Account for target file when
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote fe8042e302 337/355: Account for target file when formatting link |
Date: |
Sun, 26 Jun 2022 23:58:37 -0400 (EDT) |
branch: externals/denote
commit fe8042e30212062ef274707158260fc97eb6cb6c
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Account for target file when formatting link
We need this so that in Org we do not set an 'id:' type link to a
non-org file: those will use the 'denote:' type.
---
denote-link.el | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/denote-link.el b/denote-link.el
index 0ff570bc20..5eaaebbb80 100644
--- a/denote-link.el
+++ b/denote-link.el
@@ -231,14 +231,17 @@ Other files types beside Org always use the `denote:'
links."
(defconst denote-link--regexp-plain
(concat "\\[\\[" "denote:" "\\(?1:" denote--id-regexp "\\)" "]]"))
-(defun denote-link--file-type-format (file)
- "Return link format based on FILE format."
- (let ((org-format (if denote-link-use-org-id
- denote-link--format-org-with-id
- denote-link--format-org)))
- (pcase (file-name-extension file)
- ("md" denote-link--format-markdown)
- (_ org-format)))) ; Includes backup files. Maybe we can remove them?
+(defun denote-link--file-type-format (current-file target-file)
+ "Return link format based on CURRENT-FILE format.
+Account for TARGET-FILE format"
+ ;; Includes backup files. Maybe we can remove them?
+ (pcase (file-name-extension current-file)
+ ("md" denote-link--format-markdown)
+ ("txt" denote-link--format-org)
+ (_ (if (and denote-link-use-org-id
+ (string= (file-name-extension target-file) "org"))
+ denote-link--format-org-with-id
+ denote-link--format-org))))
(defun denote-link--file-type-regexp (file)
"Return link regexp based on FILE format."
@@ -253,13 +256,16 @@ Other files types beside Org always use the `denote:'
links."
(denote-retrieve--value-title file))))
(format pattern file-id file-title)))
-(defun denote-link--extension-format-or-id (id-only)
+(defun denote-link--extension-format-or-id (id-only &optional target-file)
"Determine format for link.
If ID-ONLY is non-nil, use `denote-link--format-id-only', else
-delegate to `denote-link--file-type-format'."
+delegate to `denote-link--file-type-format'.
+
+Optional TARGET-FILE is passed to `denote-link--format-id-only'
+to determine if the id: link format will be used in Org."
(if id-only
denote-link--format-id-only
- (denote-link--file-type-format (buffer-file-name))))
+ (denote-link--file-type-format (buffer-file-name) target-file)))
;;;###autoload
(defun denote-link (target &optional id-only)
@@ -273,7 +279,7 @@ format is always [[denote:IDENTIFIER]]."
(insert
(denote-link--format-link
target
- (denote-link--extension-format-or-id id-only)))
+ (denote-link--extension-format-or-id id-only target)))
(unless (derived-mode-p 'org-mode)
(make-button beg (point) 'type 'denote-link-button))))
- [elpa] externals/denote 75cf3d31d0 288/355: Accept optional BEG and END for buttonization, (continued)
- [elpa] externals/denote 75cf3d31d0 288/355: Accept optional BEG and END for buttonization, ELPA Syncer, 2022/06/26
- [elpa] externals/denote b651200fdf 236/355: Include "hackability" in the manual's overview, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 55140b83f4 275/355: Clarify point about org-roam database, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 6a254238f9 296/355: Mark buttonization task as done, ELPA Syncer, 2022/06/26
- [elpa] externals/denote aab484d617 258/355: Sort grep output with string-lessp, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 5be48c4186 286/355: Expand the FAQ section, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 1b9a6a12a0 290/355: Add autoload cookie for buttonization function, ELPA Syncer, 2022/06/26
- [elpa] externals/denote bb296d35a1 254/355: Tweak some statements in the manual, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 85b5290e8b 229/355: Fix bug where Unicode chars are not encoded, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 1f87a456c5 353/355: denote--punctuation-regexp: Forbid usage of slash in filenames, ELPA Syncer, 2022/06/26
- [elpa] externals/denote fe8042e302 337/355: Account for target file when formatting link,
ELPA Syncer <=
- [elpa] externals/denote d304e3556f 281/355: Add regexp for plain link format, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 987854d96c 298/355: Add missing findex directive for denote-dired-mode, ELPA Syncer, 2022/06/26
- [elpa] externals/denote ddbbe549b6 283/355: Use function to test if file likely is a note, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 62e7adfbdb 269/355: Replace superfluous 'let*' with 'let', ELPA Syncer, 2022/06/26
- [elpa] externals/denote 618eff9807 312/355: Make a couple of minor tweaks to the manual, ELPA Syncer, 2022/06/26
- [elpa] externals/denote a5986742be 315/355: Note the features of filenames for search/filter, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 9888c7087f 348/355: Add check mark to task of using id: links, ELPA Syncer, 2022/06/26
- [elpa] externals/denote d56913b055 349/355: Clarify wording of FAQ entries, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 31e5eb3af8 346/355: Update documentation about links, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 019cccfb1f 015/355: Create denote-directory if absent, ELPA Syncer, 2022/06/26