[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote af2e6a33a3 1/9: Add denote--retrieve-front-matte
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote af2e6a33a3 1/9: Add denote--retrieve-front-matter-*-from-content functions |
Date: |
Sun, 3 Nov 2024 03:57:44 -0500 (EST) |
branch: externals/denote
commit af2e6a33a32211aa8c8e0021d90aff39fa21a6d1
Author: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Commit: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Add denote--retrieve-front-matter-*-from-content functions
---
denote.el | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/denote.el b/denote.el
index a46a0b978a..943890b4f3 100644
--- a/denote.el
+++ b/denote.el
@@ -1933,6 +1933,8 @@ Subroutine of `denote--file-with-temp-buffer'."
(goto-char (point-min))
,@body)))
+;; These are public front matter retrieval functions, working with a FILE
argument
+
(defmacro denote--define-retrieve-front-matter (component scope)
"Define a function to retrieve front matter for COMPONENT given SCOPE.
The COMPONENT is one of the file name components that has a
@@ -1962,6 +1964,39 @@ or `line', referring to what the function should
retrieve."
(denote--define-retrieve-front-matter date value)
(denote--define-retrieve-front-matter date line)
+;; These are private front matter retrieval functions, working with a content
parameter
+
+(defmacro denote--define-retrieve-front-matter-from-content (component scope)
+ "Define a function to retrieve front matter for COMPONENT given SCOPE.
+The COMPONENT is one of the file name components that has a
+corresponding front matter entry. SCOPE is a symbol of either `value'
+or `line', referring to what the function should retrieve."
+ (declare (indent 1))
+ `(defun ,(intern (format "denote--retrieve-front-matter-%s-%s-from-content"
component scope)) (content file-type)
+ (when file-type
+ (with-temp-buffer
+ (insert content)
+ (goto-char (point-min))
+ (when (re-search-forward (,(intern (format "denote--%s-key-regexp"
component)) file-type) nil t 1)
+ ,(cond
+ ((eq scope 'value)
+ `(funcall (,(intern (format "denote--%s-value-reverse-function"
component)) file-type)
+ (buffer-substring-no-properties (point)
(line-end-position))))
+ ((eq scope 'line)
+ '(buffer-substring-no-properties (line-beginning-position)
(line-end-position)))
+ (t (error "`%s' is not a known scope" scope))))))))
+
+(denote--define-retrieve-front-matter-from-content title value)
+(denote--define-retrieve-front-matter-from-content title line)
+(denote--define-retrieve-front-matter-from-content keywords value)
+(denote--define-retrieve-front-matter-from-content keywords line)
+(denote--define-retrieve-front-matter-from-content signature value)
+(denote--define-retrieve-front-matter-from-content signature line)
+(denote--define-retrieve-front-matter-from-content identifier value)
+(denote--define-retrieve-front-matter-from-content identifier line)
+(denote--define-retrieve-front-matter-from-content date value)
+(denote--define-retrieve-front-matter-from-content date line)
+
(defalias 'denote-retrieve-title-value
'denote-retrieve-front-matter-title-value
"Alias for `denote-retrieve-front-matter-title-value'.")
- [elpa] externals/denote updated (f3ac69fcd3 -> 0ea4d88a59), ELPA Syncer, 2024/11/03
- [elpa] externals/denote af2e6a33a3 1/9: Add denote--retrieve-front-matter-*-from-content functions,
ELPA Syncer <=
- [elpa] externals/denote 6446650c36 3/9: Make date parameter a date object in denote--format-front-matter, ELPA Syncer, 2024/11/03
- [elpa] externals/denote bd50fbba94 5/9: Remove denote--front-matter-{title/keywords} functions, ELPA Syncer, 2024/11/03
- [elpa] externals/denote 0ea4d88a59 9/9: Merge pull request #472 from jeanphilippegg/front-matter-functions, ELPA Syncer, 2024/11/03
- [elpa] externals/denote f0908dbcc1 2/9: Remove denote--get-{title/keywords}-line-from-front-matter functions, ELPA Syncer, 2024/11/03
- [elpa] externals/denote 4cd24c9730 4/9: Format identifier in denote--format-front-matter, ELPA Syncer, 2024/11/03
- [elpa] externals/denote 7ccddb5837 6/9: Add signature parameter to denote--format-front-matter, ELPA Syncer, 2024/11/03
- [elpa] externals/denote 4fdae80128 8/9: Refactor denote-rename-file-using-front-matter, ELPA Syncer, 2024/11/03
- [elpa] externals/denote 512672e173 7/9: Add signature parameter to denote--add-front-matter, ELPA Syncer, 2024/11/03