[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote a70b4cd32d 114/355: Refine backlinks' heading pe
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote a70b4cd32d 114/355: Refine backlinks' heading per file type |
Date: |
Sun, 26 Jun 2022 23:58:10 -0400 (EDT) |
branch: externals/denote
commit a70b4cd32dafb220165398835beb99640d3bf500
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Refine backlinks' heading per file type
---
denote-link.el | 40 ++++++++++++++++++++++++++++++++++------
1 file changed, 34 insertions(+), 6 deletions(-)
diff --git a/denote-link.el b/denote-link.el
index e2d86a6196..c019bde3e0 100644
--- a/denote-link.el
+++ b/denote-link.el
@@ -164,15 +164,43 @@ Run `denote-link-insert-functions' afterwards."
"String of the backlink's heading.
This heading is appended to a file when another links to it.")
+(defvar denote-link-backlink-warning
+ "Do not edit past this line; this is for denote.el and related."
+ "String that warns about not editing the backlinks' section.")
+
+(defvar denote-link--markdown-comment "<!-- %s -->"
+ "Specifier for Markdown comments passed to `format'.")
+
+(defvar denote-link--org-comment "# %s"
+ "Specifier for Markdown comments passed to `format'.")
+
+(defun denote-link--format-comment (comment filetype)
+ "Use appropriate COMMENT for FILETYPE."
+ (pcase filetype
+ ("md" (format denote-link--markdown-comment comment))
+ (_ (format denote-link--org-comment comment))))
+
+(defvar denote-link--markdown-heading "%s\n# %s\n\n"
+ "Specifier for Markdown heading passed to `format'.")
+
+(defvar denote-link--org-heading "%s\n* %s\n\n"
+ "Specifier for Org heading passed to `format'.")
+
+(defvar denote-link--text-heading "%s\n%s\n%s\n\n"
+ "Specifier for plain text heading passed to `format'.")
+
+(defun denote-link--format-heading (heading filetype comment)
+ "Use appropriate HEADING for FILETYPE, while prepending COMMENT."
+ (pcase filetype
+ ("md" (format denote-link--markdown-heading comment heading))
+ ("org" (format denote-link--org-heading comment heading))
+ (_ (format denote-link--text-heading comment heading (make-string 16
?=)))))
+
(defun denote-link--format-backlinks-heading (heading)
"Format HEADING for backlinks."
(let* ((ext (file-name-extension (buffer-file-name)))
- (markup (if (string= ext "org") "*" "#"))
- (warning "Do not edit past this line; this is for denote.el and
related.")
- (comment (if (string= ext "org")
- (format "# %s" warning)
- (format "<!-- %s -->" warning))))
- (format "%s\n%s %s\n\n" comment markup heading)))
+ (comment (denote-link--format-comment denote-link-backlink-warning
ext)))
+ (denote-link--format-heading heading ext comment)))
(defun denote-link-backlink (target backlink)
"Insert BACKLINK to TARGET file."
- [elpa] externals/denote a6303a6101 074/355: Update doc string of variable 'denote-directory', (continued)
- [elpa] externals/denote a6303a6101 074/355: Update doc string of variable 'denote-directory', ELPA Syncer, 2022/06/26
- [elpa] externals/denote e2c49771f7 078/355: Placate the compiler about symbol disambiguation, ELPA Syncer, 2022/06/26
- [elpa] externals/denote e8c1e31dec 084/355: Expand gitignore, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 739d485600 079/355: Fix bug about missing point in link de-duplication, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 3df88a05d0 096/355: Make linking aware of file types (extends 299b897), ELPA Syncer, 2022/06/26
- [elpa] externals/denote e1bd4c9cb8 094/355: BREAKING Put keywords after the title, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 7366004e91 106/355: Fix markdown-toml front matter format, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 5fd4e97dad 105/355: Add support for markdown-toml, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 1a8b57a9a8 104/355: Fix const in denote-file-type (extends 2bc5df6), ELPA Syncer, 2022/06/26
- [elpa] externals/denote c225201c49 124/355: Use appropriate name for internal variable, ELPA Syncer, 2022/06/26
- [elpa] externals/denote a70b4cd32d 114/355: Refine backlinks' heading per file type,
ELPA Syncer <=
- [elpa] externals/denote 7cba33e08e 119/355: LAST BREAKING CHANGE to file-naming scheme, ELPA Syncer, 2022/06/26
- [elpa] externals/denote c5a5748594 116/355: Abstract plain text front matter delimiter, ELPA Syncer, 2022/06/26
- [elpa] externals/denote e394057985 134/355: Document how to store multiple types of notes, ELPA Syncer, 2022/06/26
- [elpa] externals/denote d90695213c 151/355: Add minor clarifications in the manual, ELPA Syncer, 2022/06/26
- [elpa] externals/denote ce41b421ef 147/355: Update denote-retrieve symbols in denote-link, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 0e75e46b32 138/355: Improve denote-dired-rename-file, ELPA Syncer, 2022/06/26
- [elpa] externals/denote cdb7f554f2 160/355: Remove extra parenthesis from sample configuration, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 88e64be2cb 176/355: Fix plain text link format, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 7fab21926d 183/355: Process 'find' output in denote-retrieve, ELPA Syncer, 2022/06/26
- [elpa] externals/denote ecc7922a77 169/355: BREAKING remove support for hardcoded backlinks, ELPA Syncer, 2022/06/26