[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 6e5ddc2623 01/20: Refactor denote-file-has-ident
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 6e5ddc2623 01/20: Refactor denote-file-has-identifier-p and use it in various functions |
Date: |
Wed, 20 Dec 2023 03:58:00 -0500 (EST) |
branch: externals/denote
commit 6e5ddc262381a94372c39ee58197a5df9c85c9a4
Author: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Commit: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Refactor denote-file-has-identifier-p and use it in various functions
---
denote.el | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/denote.el b/denote.el
index 8f4cc1e677..838558047b 100644
--- a/denote.el
+++ b/denote.el
@@ -722,8 +722,7 @@ For our purposes, its path must be part of the variable
`denote-directory', it must have a Denote identifier in its name,
and use one of the extensions implied by `denote-file-type'."
(and (string-prefix-p (denote-directory) (expand-file-name filename))
- (string-match-p (concat "\\`" denote-id-regexp)
- (file-name-nondirectory filename))
+ (denote-file-has-identifier-p filename)
(denote-file-has-supported-extension-p filename)))
(defun denote-file-is-note-p (file)
@@ -736,8 +735,7 @@ For our purposes, a note must not be a directory, must
satisfy
(defun denote-file-has-identifier-p (file)
"Return non-nil if FILE has a Denote identifier."
- (string-match-p (concat "\\`" denote-id-regexp)
- (file-name-nondirectory file)))
+ (denote-retrieve-filename-identifier file :no-error))
(defun denote-file-has-signature-p (file)
"Return non-nil if FILE has a Denote identifier."
@@ -768,7 +766,7 @@ FILE must be an absolute path."
(defun denote-extract-id-from-string (string)
"Return existing Denote identifier in STRING, else nil."
(when (string-match denote-id-regexp string)
- (match-string 0 string)))
+ (match-string-no-properties 0 string)))
(define-obsolete-function-alias
'denote--default-dir-has-denote-prefix
@@ -1735,8 +1733,7 @@ It checks files in variable `denote-directory' and active
buffer files."
(denote-directory-files)))
(names (append file-names (denote--buffer-file-names))))
(dolist (name names)
- (let ((id (when (string-match (concat "\\`" denote-id-regexp) name)
- (match-string-no-properties 0 name))))
+ (let ((id (denote-retrieve-filename-identifier name :no-error)))
(puthash id t ids)))
ids))
@@ -2537,10 +2534,7 @@ the changes made to the file: perform them outright."
(declare (interactive-only t))
(interactive nil dired-mode)
(if-let ((marks (dired-get-marked-files)))
- (let ((used-ids (when (seq-some
- (lambda (m)
- (not (denote-retrieve-filename-identifier m
:no-error)))
- marks)
+ (let ((used-ids (unless (seq-every-p #'denote-file-has-identifier-p
marks)
(denote--get-all-used-ids))))
(dolist (file marks)
(let* ((file-type (denote-filetype-heuristics file))
@@ -2607,9 +2601,7 @@ Specifically, do the following:
(interactive nil dired-mode)
(if-let ((marks (dired-get-marked-files)))
(let ((keywords (denote-keywords-prompt "Rename marked files with
keywords, overwriting existing (empty to ignore/remove)"))
- (used-ids (when (seq-some
- (lambda (m) (not
(denote-retrieve-filename-identifier m :no-error)))
- marks)
+ (used-ids (unless (seq-every-p #'denote-file-has-identifier-p
marks)
(denote--get-all-used-ids))))
(dolist (file marks)
(let* ((dir (file-name-directory file))
@@ -2683,7 +2675,7 @@ cannot know if they have front matter and what that may
be."
(if-let ((marks (seq-filter
(lambda (m)
(and (denote-file-is-writable-and-supported-p m)
- (denote-retrieve-filename-identifier m :no-error)))
+ (denote-file-has-identifier-p m)))
(dired-get-marked-files))))
(progn
(dolist (file marks)
@@ -2728,7 +2720,7 @@ relevant front matter."
(denote-title-prompt)
(denote-keywords-prompt)))
(when (and (denote-file-is-writable-and-supported-p file)
- (denote-retrieve-filename-identifier file :no-error))
+ (denote-file-has-identifier-p file))
(denote--add-front-matter
file title keywords
(denote-retrieve-filename-identifier file)
- [elpa] externals/denote updated (d47ef97062 -> ee58ae014d), ELPA Syncer, 2023/12/20
- [elpa] externals/denote b996b7e6f0 02/20: Refactor denote-add-front-matter, ELPA Syncer, 2023/12/20
- [elpa] externals/denote 4261d19a88 12/20: Put Denote menu bar after "Tools", ELPA Syncer, 2023/12/20
- [elpa] externals/denote aa7bf58234 18/20: Enable Denote menu bar by default, ELPA Syncer, 2023/12/20
- [elpa] externals/denote f770346729 19/20: Merge branch 'main' of git.sr.ht:~protesilaos/denote, ELPA Syncer, 2023/12/20
- [elpa] externals/denote 667c1370ba 15/20: Remove unwind-protect from denote--command-with-default-title, ELPA Syncer, 2023/12/20
- [elpa] externals/denote 6d71d3e1d3 04/20: Refactor denote-retrieve-filename-* functions, ELPA Syncer, 2023/12/20
- [elpa] externals/denote 7ca08f2a66 07/20: Refactor denote-org-capture and remove denote-org-capture-with-prompts, ELPA Syncer, 2023/12/20
- [elpa] externals/denote f0910d3146 13/20: Add denote-menu-bar-mode, making the Denote menu bar optional, ELPA Syncer, 2023/12/20
- [elpa] externals/denote 6e5ddc2623 01/20: Refactor denote-file-has-identifier-p and use it in various functions,
ELPA Syncer <=
- [elpa] externals/denote faaf5f94ab 03/20: Use denote-rename-max-mini-window-height in denote-change-file-type-and-front-matter, ELPA Syncer, 2023/12/20
- [elpa] externals/denote e6b7ba74e6 05/20: Make denote-retrieve-filename-identifier consistent with other functions, ELPA Syncer, 2023/12/20
- [elpa] externals/denote f1730b7798 17/20: Acknowledge Ashton Wiersdorf for commit e2ba6c1, ELPA Syncer, 2023/12/20
- [elpa] externals/denote f26d8d7799 08/20: Handle nil case in denote-sort--define-lessp, ELPA Syncer, 2023/12/20
- [elpa] externals/denote 4899ca5c78 09/20: Remove separator for the last file in denote-org-dblock-add-files, ELPA Syncer, 2023/12/20
- [elpa] externals/denote 6acb25c7ec 10/20: Create aliases for denote-retrieve-front-matter-* functions, ELPA Syncer, 2023/12/20
- [elpa] externals/denote 195f0c3b7f 14/20: Acknowledge Joseph Turner for commits 4261d19, f0910d3, ELPA Syncer, 2023/12/20
- [elpa] externals/denote 3d4891b5dd 06/20: Rename denote-retrieve-title-* and denote-retrieve-keywords-* functions, ELPA Syncer, 2023/12/20
- [elpa] externals/denote e2ba6c144d 16/20: Guard sorting keywords when given an empty string, ELPA Syncer, 2023/12/20
- [elpa] externals/denote ee58ae014d 20/20: Merge pull request #199 from jeanphilippegg/refactor, ELPA Syncer, 2023/12/20