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

[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'.")
 



reply via email to

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