[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 0a22460e4f 09/14: Remove checks in front matter
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 0a22460e4f 09/14: Remove checks in front matter retrieval functions |
Date: |
Mon, 15 Aug 2022 23:57:30 -0400 (EDT) |
branch: externals/denote
commit 0a22460e4fe832d3fab187a959677d888238e53e
Author: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Commit: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Remove checks in front matter retrieval functions
---
denote.el | 77 ++++++++++++++++++++++++++-------------------------------------
1 file changed, 32 insertions(+), 45 deletions(-)
diff --git a/denote.el b/denote.el
index 1c2a3cbe7e..8563552bcb 100644
--- a/denote.el
+++ b/denote.el
@@ -802,54 +802,38 @@ contain the newline."
(defun denote--retrieve-title-value (file file-type)
"Return title value from FILE according to FILE-TYPE."
- ;; NOTE 2022-08-11: The `or' is superfluous, but I am keeping it as a
- ;; reminder. See TODO comment above `denote--only-note-p'
- (when (or (denote--writable-and-supported-p file)
- (denote--only-note-p file))
- (with-temp-buffer
- (insert-file-contents file)
- (goto-char (point-min))
- (when (re-search-forward (denote--title-key-regexp file-type) nil t 1)
- (funcall (denote--title-value-reverse-function file-type)
- (buffer-substring-no-properties (point) (point-at-eol)))))))
+ (with-temp-buffer
+ (insert-file-contents file)
+ (goto-char (point-min))
+ (when (re-search-forward (denote--title-key-regexp file-type) nil t 1)
+ (funcall (denote--title-value-reverse-function file-type)
+ (buffer-substring-no-properties (point) (point-at-eol))))))
(defun denote--retrieve-title-line (file file-type)
"Return title line from FILE according to FILE-TYPE."
- ;; NOTE 2022-08-11: The `or' is superfluous, but I am keeping it as a
- ;; reminder. See TODO comment above `denote--only-note-p'
- (when (or (denote--writable-and-supported-p file)
- (denote--only-note-p file))
- (with-temp-buffer
- (insert-file-contents file)
- (goto-char (point-min))
- (when (re-search-forward (denote--title-key-regexp file-type) nil t 1)
- (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
+ (with-temp-buffer
+ (insert-file-contents file)
+ (goto-char (point-min))
+ (when (re-search-forward (denote--title-key-regexp file-type) nil t 1)
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
(defun denote--retrieve-keywords-value (file file-type)
"Return keywords value from FILE according to FILE-TYPE.
If optional KEY is non-nil, return the key instead."
- ;; NOTE 2022-08-11: The `or' is superfluous, but I am keeping it as a
- ;; reminder. See TODO comment above `denote--only-note-p'
- (when (or (denote--writable-and-supported-p file)
- (denote--only-note-p file))
- (with-temp-buffer
- (insert-file-contents file)
- (goto-char (point-min))
- (when (re-search-forward (denote--keywords-key-regexp file-type) nil t 1)
- (funcall (denote--keywords-value-reverse-function file-type)
- (buffer-substring-no-properties (point) (point-at-eol)))))))
+ (with-temp-buffer
+ (insert-file-contents file)
+ (goto-char (point-min))
+ (when (re-search-forward (denote--keywords-key-regexp file-type) nil t 1)
+ (funcall (denote--keywords-value-reverse-function file-type)
+ (buffer-substring-no-properties (point) (point-at-eol))))))
(defun denote--retrieve-keywords-line (file file-type)
"Return keywords line from FILE according to FILE-TYPE."
- ;; NOTE 2022-08-11: The `or' is superfluous, but I am keeping it as a
- ;; reminder. See TODO comment above `denote--only-note-p'
- (when (or (denote--writable-and-supported-p file)
- (denote--only-note-p file))
- (with-temp-buffer
- (insert-file-contents file)
- (goto-char (point-min))
- (when (re-search-forward (denote--keywords-key-regexp file-type) nil t 1)
- (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
+ (with-temp-buffer
+ (insert-file-contents file)
+ (goto-char (point-min))
+ (when (re-search-forward (denote--keywords-key-regexp file-type) nil t 1)
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
(defun denote--retrieve-title-or-filename (file type)
"Return appropriate title for FILE given its TYPE."
@@ -1591,6 +1575,8 @@ typos and the like."
(interactive (list (buffer-file-name)))
(when (buffer-modified-p)
(user-error "Save buffer before proceeding"))
+ (unless (denote--writable-and-supported-p file)
+ (user-error "The file is not writable or does not have a supported file
extension"))
(if-let* ((file-type (denote--filetype-heuristics file))
(title (denote--retrieve-title-value file file-type))
(keywords (denote--retrieve-keywords-value file file-type))
@@ -2134,13 +2120,14 @@ The placement of the backlinks' buffer is controlled by
the user
option `denote-link-backlinks-display-buffer-action'. By
default, it will show up below the current window."
(interactive)
- (let* ((file (buffer-file-name))
- (id (denote--retrieve-filename-identifier file))
- (file-type (denote--filetype-heuristics file))
- (title (denote--retrieve-title-value file file-type)))
- (if-let ((files (denote--retrieve-process-grep id)))
- (denote-link--prepare-backlinks id files title)
- (user-error "No links to the current note"))))
+ (let ((file (buffer-file-name)))
+ (when (denote--writable-and-supported-p file)
+ (let* ((id (denote--retrieve-filename-identifier file))
+ (file-type (denote--filetype-heuristics file))
+ (title (denote--retrieve-title-value file file-type)))
+ (if-let ((files (denote--retrieve-process-grep id)))
+ (denote-link--prepare-backlinks id files title)
+ (user-error "No links to the current note"))))))
(defalias 'denote-link-show-backlinks-buffer (symbol-function
'denote-link-backlinks))
- [elpa] externals/denote updated (29b6ec1aad -> 4e269bf260), ELPA Syncer, 2022/08/15
- [elpa] externals/denote 11fef925c0 03/14: Rework docstring of denote--directory-files, ELPA Syncer, 2022/08/15
- [elpa] externals/denote ada6348415 02/14: Remove TODO for denote--only-note-p, ELPA Syncer, 2022/08/15
- [elpa] externals/denote c33c772fd7 05/14: Remove FIXME for denote--rewrite-front-matter, ELPA Syncer, 2022/08/15
- [elpa] externals/denote 0a22460e4f 09/14: Remove checks in front matter retrieval functions,
ELPA Syncer <=
- [elpa] externals/denote 4ef21b0217 01/14: Rename denote-backlinks-mode and denote-backlinks-mode-map, ELPA Syncer, 2022/08/15
- [elpa] externals/denote 9e28fc8a78 04/14: Fix docstring of denote--retrieve-filename-title, ELPA Syncer, 2022/08/15
- [elpa] externals/denote 0f045279e2 08/14: Remove the check for empty file from denote--edit-front-matter-p, ELPA Syncer, 2022/08/15
- [elpa] externals/denote 71008dc939 12/14: Remove check for denote--only-note-p in denote--add-front-matter, ELPA Syncer, 2022/08/15
- [elpa] externals/denote 89d1fdc1dd 11/14: Simplify denote--valid-date, ELPA Syncer, 2022/08/15
- [elpa] externals/denote c7bf701030 06/14: Remove condition in denote--edit-front-matter-p, ELPA Syncer, 2022/08/15
- [elpa] externals/denote 1aeee8410f 07/14: Remove check for writable-and-supported-p in denote--edit-front-matter-p, ELPA Syncer, 2022/08/15
- [elpa] externals/denote 4e269bf260 14/14: Merge pull request #94 from jeanphilippegg/cleanup, ELPA Syncer, 2022/08/15
- [elpa] externals/denote 02e35f7e5d 10/14: Remove denote--retrieve-files-in-output, ELPA Syncer, 2022/08/15
- [elpa] externals/denote d4d67a6118 13/14: Simplify some lambdas, ELPA Syncer, 2022/08/15