[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote d6543cfa0d 333/355: Add support for org-id
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote d6543cfa0d 333/355: Add support for org-id |
Date: |
Sun, 26 Jun 2022 23:58:37 -0400 (EDT) |
branch: externals/denote
commit d6543cfa0d698ee601527ca45c5e24e1ecf6f635
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Kaushal Modi <kaushal.modi@gmail.com>
Add support for org-id
For a discussion, read issue 8 on the GitHub mirror:
<https://github.com/protesilaos/denote/issues/8>.
---
denote-link.el | 14 ++++++++++----
denote-retrieve.el | 2 +-
denote.el | 38 ++++++++++++++++++++++++++++++++++++--
3 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/denote-link.el b/denote-link.el
index 975eff3893..408a0c53da 100644
--- a/denote-link.el
+++ b/denote-link.el
@@ -196,6 +196,9 @@ and/or the documentation string of `display-buffer'."
(defconst denote-link--format-org "[[denote:%s][%s]]"
"Format of Org link to note.")
+(defconst denote-link--format-org-with-id "[[id:%s][%s]]"
+ "Format of Org link to note for `denote-use-org-id'.")
+
(defconst denote-link--format-markdown "[%2$s](denote:%1$s)"
"Format of Markdown link to note.")
@@ -203,7 +206,7 @@ and/or the documentation string of `display-buffer'."
"Format of identifier-only link to note.")
(defconst denote-link--regexp-org
- (concat "\\[\\[" "denote:" "\\(?1:" denote--id-regexp "\\)" "]" "\\[.*?]]"))
+ (concat "\\[\\[" "\\(denote\\|[Ii][Dd]\\):" "\\(?1:" denote--id-regexp
"\\)" "]" "\\[.*?]]"))
(defconst denote-link--regexp-markdown
(concat "\\[.*?]" "(denote:" "\\(?1:" denote--id-regexp "\\)" ")"))
@@ -213,9 +216,12 @@ and/or the documentation string of `display-buffer'."
(defun denote-link--file-type-format (file)
"Return link format based on FILE format."
- (pcase (file-name-extension file)
- ("md" denote-link--format-markdown)
- (_ denote-link--format-org))) ; Includes backup files. Maybe we can
remove them?
+ (let ((org-format (if denote-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-regexp (file)
"Return link regexp based on FILE format."
diff --git a/denote-retrieve.el b/denote-retrieve.el
index 07e3655e0f..94d3a9fd9b 100644
--- a/denote-retrieve.el
+++ b/denote-retrieve.el
@@ -39,7 +39,7 @@ The match that needs to be extracted is explicityly marked as
group 1.")
(defconst denote-retrieve--identifier-regexp
- "^.?.?\\b\\(?:identifier\\|ID\\)\\s-*[:=]\\s-*[\"']?\\(?1:[0-9T]+\\)[\"']?"
+
"^.?.?\\b\\(?:identifier\\|[Ii][Dd]\\)\\s-*[:=]\\s-*[\"']?\\(?1:[0-9T]+\\)[\"']?"
"Regular expression for identifier key and value.
The match that needs to be extracted is explicityly marked as
group 1.")
diff --git a/denote.el b/denote.el
index 0953685f3a..3391796539 100644
--- a/denote.el
+++ b/denote.el
@@ -211,6 +211,25 @@ is suspended: we use whatever the user wants."
(string :tag "Custom format for `format-time-string'"))
:group 'denote)
+(defcustom denote-use-org-id nil
+ "When non-nil use the ID property and link type in Org files.
+To use the ID property, a PROPERTIES drawer is added to the top
+of newly created notes. Furthermore, newly created links will
+use the standard 'id:' hyperlink type instead of the custom
+'denote:' type.
+
+In practical terms, the ID ensures maximum compatibility with the
+Org ecosystem.
+
+When the value is nil, Denote uses a generic front matter for new
+notes and links rely on the custom 'denote:' type (which should
+behave the same as the standard 'file:' type).
+
+Other files types beside Org always use the 'denote:' links and
+keep their generic front matter."
+ :type 'boolean
+ :group 'denote)
+
;;;; Main variables
(defconst denote--id-format "%Y%m%dT%H%M%S"
@@ -246,6 +265,8 @@ We consider those characters illigal for our purposes.")
`(metadata (category . ,category))
(complete-with-action action candidates string pred))))
+(defvar org-id-extra-files)
+
(defun denote-directory ()
"Return path of variable `denote-directory' as a proper directory."
(let* ((val (or (buffer-local-value 'denote-directory (current-buffer))
@@ -253,6 +274,8 @@ We consider those characters illigal for our purposes.")
(path (if (or (eq val 'default-directory) (eq val 'local))
default-directory val)))
(unless (file-directory-p path)
(make-directory path t))
+ (when (and denote-use-org-id (require 'org-id nil t))
+ (setq org-id-extra-files (directory-files path nil "\.org$")))
(file-name-as-directory path)))
(defun denote--extract (regexp str &optional group)
@@ -508,6 +531,16 @@ and do not use any empty line before it.
These help ensure consistency and might prove useful if we need
to operate on the front matter as a whole.")
+(defvar denote-org-with-id-front-matter
+ ":PROPERTIES:
+:ID: %4$s
+:END:
+#+title: %1$s
+#+date: %2$s
+#+filetags: %3$s
+\n"
+ "Like `denote-org-front-matter' but for `denote-use-org-id'.")
+
(defun denote--file-meta-header (title date keywords id &optional filetype)
"Front matter for new notes.
@@ -517,12 +550,13 @@ TITLE, DATE, KEYWORDS, FILENAME, ID are all strings which
are
Optional FILETYPE is one of the values of `denote-file-type',
else that variable is used."
(let ((kw-space (denote--file-meta-keywords keywords))
- (kw-toml (denote--file-meta-keywords keywords 'toml)))
+ (kw-toml (denote--file-meta-keywords keywords 'toml))
+ (org-front (if denote-use-org-id denote-org-with-id-front-matter
denote-org-front-matter)))
(pcase (or filetype denote-file-type)
('markdown-toml (format denote-toml-front-matter title date kw-toml id))
('markdown-yaml (format denote-yaml-front-matter title date kw-space id))
('text (format denote-text-front-matter title date kw-space id
denote-text-front-matter-delimiter))
- (_ (format denote-org-front-matter title date kw-space id)))))
+ (_ (format org-front title date kw-space id)))))
(defun denote--path (title keywords &optional dir id)
"Return path to new file with TITLE and KEYWORDS.
- [elpa] externals/denote 0cc0e609ed 276/355: Add minor clarification, (continued)
- [elpa] externals/denote 0cc0e609ed 276/355: Add minor clarification, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 66bb8083ec 323/355: Tweak indentation of function, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 2fdd20dc0f 311/355: Tweak spacing in denote-org-capture.el Commentary, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 8c7808eab8 328/355: Remove completed to-do about links, backlinks, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 1b71e736c8 336/355: Fix format for denote-org-front-matter, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 5a1b05d6c7 310/355: Update denote.el Commentary, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 047b396f16 314/355: Remove superfluous word, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 6b200b31ef 308/355: Simplify denote-dired--rename-buffer, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 1b5634ba1c 324/355: Clarify that xrefs are returned as an alist, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 6985217de6 350/355: Set denote-link-use-org-id to t in sample config, ELPA Syncer, 2022/06/27
- [elpa] externals/denote d6543cfa0d 333/355: Add support for org-id,
ELPA Syncer <=
- [elpa] externals/denote 72f77178af 344/355: Refine denote-link-use-org-id doc string, ELPA Syncer, 2022/06/27
- [elpa] externals/denote f307e32693 011/355: Expand the README, ELPA Syncer, 2022/06/27
- [elpa] externals/denote bfb2cdefd7 195/355: Rewrite manual on links (getting closer to v0.1.0), ELPA Syncer, 2022/06/27
- [elpa] externals/denote e37e429844 198/355: Add possible to-do for using xref, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 2327b5beb6 212/355: Add helper FNs to return title and date values, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 98113698a7 202/355: Expand sample configuration, ELPA Syncer, 2022/06/27
- [elpa] externals/denote cbaab43170 240/355: Update Acknowledgement: svnsbck => Sven Seebeck, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 9be3cfab99 215/355: Relocate defcustom where it belongs, ELPA Syncer, 2022/06/27
- [elpa] externals/denote b25704e041 211/355: Make denote-retrieve--value pass optional group, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 24997c6bc5 226/355: Remove "work-in-progress" from backlinks' section, ELPA Syncer, 2022/06/27