[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 0e83bee5b7 141/355: Add denote-retrieve for inte
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 0e83bee5b7 141/355: Add denote-retrieve for internal purposes |
Date: |
Sun, 26 Jun 2022 23:58:15 -0400 (EDT) |
branch: externals/denote
commit 0e83bee5b75349288c68bbd83f6f2af82e1a8e0a
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Add denote-retrieve for internal purposes
Basicallly we shall use it to extract data from a file.
---
denote-retrieve.el | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/denote-retrieve.el b/denote-retrieve.el
new file mode 100644
index 0000000000..8ee9037b75
--- /dev/null
+++ b/denote-retrieve.el
@@ -0,0 +1,74 @@
+;;; denote-retrieve.el --- Link facility for Denote -*- lexical-binding: t -*-
+
+;; Copyright (C) 2022 Free Software Foundation, Inc.
+
+;; Author: Protesilaos Stavrou <info@protesilaos.com>
+;; URL: https://git.sr.ht/~protesilaos/denote
+;; Version: 0.1.0
+;; Package-Requires: ((emacs "27.1"))
+
+;; This file is NOT part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; Used internally by commands that operate on file contents.
+
+;;; Code:
+
+(require 'denote)
+
+(defconst denote-retrieve--title-regexp
+ "^\\(?:#\\+\\)?\\(?:title:\\)[\s\t]+\\(?1:.*\\)"
+ "Regular expression for title key and value.
+
+The match that needs to be extracted is explicityly marked as
+group 1. `denote-retrieve--find-value' uses the group 1 sting.")
+
+(defconst denote-retrieve--identifier-regexp
+ "^.?.?\\b\\(?:identifier\\|ID\\)\\s-*[:=]\\s-*\"?\\(?1:[0-9T]+\\)"
+ "Regular expression for filename key and value.
+
+The match that needs to be extracted is explicityly marked as
+group 1. `denote-retrieve--find-value' uses the group 1 sting.")
+
+(defun denote-retrieve--search (regexp)
+ "Search for REGEXP in the current buffer."
+ (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (re-search-forward regexp nil t 1)
+ (match-string-no-properties 1))))
+
+(defun denote-retrieve--find-value (regexp)
+ "Return value from REGEXP by searching the file."
+ (or (denote-retrieve--search regexp)
+ (user-error "Cannot retrieve %s" regexp)))
+
+(defun denote-retrieve--retrieve-value (file regexp)
+ "Return REGEXP value from FILE.
+FILE is a note in the variable `denote-directory'."
+ (let ((default-directory (denote-directory)))
+ (with-temp-buffer
+ (insert-file-contents-literally file)
+ (denote-retrieve--find-value regexp))))
+
+(defun denote-retrieve--read-file-prompt ()
+ "Prompt for regular file in variable `denote-directory'."
+ (read-file-name "Select note: " (denote-directory) nil t nil
#'file-regular-p))
+
+(provide 'denote-retrieve)
+;;; denote-retrieve.el ends here
- [elpa] externals/denote f9b86149fc 102/355: Rephrase package overview, (continued)
- [elpa] externals/denote f9b86149fc 102/355: Rephrase package overview, ELPA Syncer, 2022/06/26
- [elpa] externals/denote d8b2903fa9 077/355: Acknowledge Jack Baty for commit dfc3a8f, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 142b628c2e 127/355: Apply distinct face to keyword delimiter, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 86e437da43 150/355: Document .dir-locals.el for multi-type notes, ELPA Syncer, 2022/06/27
- [elpa] externals/denote e92137a548 148/355: Use file attribute for mod time while renaming, ELPA Syncer, 2022/06/27
- [elpa] externals/denote c9926a528e 133/355: perf: Stop searching for the title or identifier after the 1st match, ELPA Syncer, 2022/06/27
- [elpa] externals/denote f55dee06b1 143/355: Add documentation about our minibuffer histories, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 97e8c30bcf 153/355: Rewrite the package Overview, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 171b873cb5 142/355: Require denote-retrieve (0e83bee) in denote-link, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 6a286c97f8 154/355: Rephrase statement for clarity, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 0e83bee5b7 141/355: Add denote-retrieve for internal purposes,
ELPA Syncer <=
- [elpa] externals/denote b42f68c8e8 156/355: Add denote-type command, ELPA Syncer, 2022/06/27
- [elpa] externals/denote e841a51ca7 155/355: Fix typo, ELPA Syncer, 2022/06/27
- [elpa] externals/denote bc93a8ecda 137/355: Update the manual on the matter of backlinks, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 45bea4166a 158/355: Update Acknowledgements, ELPA Syncer, 2022/06/27
- [elpa] externals/denote d4cbb974a5 157/355: Rewrite node on multi file types (due to b42f68c), ELPA Syncer, 2022/06/27
- [elpa] externals/denote 479899d973 162/355: Clarify wording about journal/diary extras, ELPA Syncer, 2022/06/27
- [elpa] externals/denote e9bc790675 167/355: Clarify that auto-backlinks may be removed, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 4bc7aa4dfd 166/355: Remove outdated doc string from private function, ELPA Syncer, 2022/06/27
- [elpa] externals/denote d9f439e47f 173/355: Add helper function to prepare completion table, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 91090d42c6 180/355: Fix regexp match for backlinks, ELPA Syncer, 2022/06/27