[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote b936bbdf4e 08/17: Make signature parameter non o
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote b936bbdf4e 08/17: Make signature parameter non optional for some functions |
Date: |
Thu, 23 Nov 2023 00:58:00 -0500 (EST) |
branch: externals/denote
commit b936bbdf4ed528aa0dc5f51efd034a3743e3ce7b
Author: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Commit: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Make signature parameter non optional for some functions
---
README.org | 11 ++++++-----
denote.el | 41 +++++++++++++++++++++--------------------
2 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/README.org b/README.org
index 3a09781932..ef1a6d2512 100644
--- a/README.org
+++ b/README.org
@@ -3156,8 +3156,9 @@ invoke this command."
(id (denote-retrieve-filename-identifier file))
(file-type (denote-filetype-heuristics file))
(title (denote--retrieve-title-or-filename file file-type))
+ (signature (denote-retrieve-filename-signature file))
(extension (file-name-extension file t))
- (new-name (denote-format-file-name dir id keywords title
extension))
+ (new-name (denote-format-file-name dir id keywords title
extension signature))
(default-directory dir))
(denote-rename-file-and-buffer file new-name))))
#+end_src
@@ -3746,10 +3747,10 @@ might change them without further notice.
file type is assumed to be the first of ~denote-file-types~.
#+findex: denote-format-file-name
-+ Function ~denote-format-file-name~ :: Format file name. =PATH=,
- =ID=, =KEYWORDS=, =TITLE-SLUG= are expected to be supplied by
- ~denote~ or equivalent: they will all be converted into a single
- string. =EXTENSION= is the file type extension, as a string.
++ Function ~denote-format-file-name~ :: Format file name. =PATH=, =ID=,
+ =KEYWORDS=, =TITLE-SLUG=, and =SIGNATURE-SLUG= are expected to be
+ supplied by ~denote~ or equivalent: they will all be converted into a
+ single string. =EXTENSION= is the file type extension, as a string.
#+findex: denote-extract-keywords-from-path
+ Function ~denote-extract-keywords-from-path~ :: Extract keywords
diff --git a/denote.el b/denote.el
index 25cc867ab4..e7bcfa8471 100644
--- a/denote.el
+++ b/denote.el
@@ -1376,10 +1376,11 @@ To only return an existing identifier, refer to the
function
"2.1.0")
(defun denote-retrieve-filename-signature (file)
- "Extract signature from FILE name, if present, else return nil."
- (when (denote-file-has-signature-p file)
- (string-match denote-signature-regexp file)
- (match-string 1 file)))
+ "Extract signature from FILE name, if present, else return an empty string."
+ (let ((filename (file-name-nondirectory file)))
+ (if (string-match denote-signature-regexp filename)
+ (match-string 1 filename)
+ "")))
(defun denote-retrieve-filename-title (file)
"Extract title from FILE name, else return `file-name-base'.
@@ -1488,14 +1489,14 @@ See `denote--retrieve-locations-in-xrefs'."
;;;;; Common helpers for new notes
-(defun denote-format-file-name (path id keywords title-slug extension
&optional signature)
+(defun denote-format-file-name (path id keywords title-slug extension
signature-slug)
"Format file name.
-PATH, ID, KEYWORDS, TITLE-SLUG, EXTENSION and optional SIGNATURE
-are expected to be supplied by `denote' or equivalent command."
+PATH, ID, KEYWORDS, TITLE-SLUG, EXTENSION and SIGNATURE-SLUG are
+expected to be supplied by `denote' or equivalent command."
(let ((file-name (concat path id)))
- (when (and signature (not (string-empty-p signature)))
- (setq file-name (concat file-name "==" signature)))
- (when (and title-slug (not (string-empty-p title-slug)))
+ (when (not (string-empty-p signature-slug))
+ (setq file-name (concat file-name "==" signature-slug)))
+ (when (not (string-empty-p title-slug))
(setq file-name (concat file-name "--" title-slug)))
(when keywords
(setq file-name (concat file-name "__" (denote-keywords-combine
keywords))))
@@ -1522,17 +1523,16 @@ values of `denote-file-type'."
(kws (denote--format-front-matter-keywords keywords filetype)))
(if fm (format fm title date kws id) "")))
-(defun denote--path (title keywords dir id file-type &optional signature)
+(defun denote--path (title keywords dir id file-type signature)
"Return path to new file.
-Use ID, TITLE, KEYWORDS, FILE-TYPE and optional SIGNATURE to
-construct path to DIR."
+Use ID, TITLE, KEYWORDS, FILE-TYPE and SIGNATURE to construct
+path to DIR."
(denote-format-file-name
dir id
(denote-sluggify-keywords keywords)
(denote-sluggify title 'title)
(denote--file-extension file-type)
- (when signature
- (denote-sluggify-signature signature))))
+ (denote-sluggify-signature signature)))
;; Adapted from `org-hugo--org-date-time-to-rfc3339' in the `ox-hugo'
;; package: <https://github.com/kaushalmodi/ox-hugo>.
@@ -1561,12 +1561,11 @@ construct path to DIR."
(t
(denote-date-org-timestamp date)))))
-(defun denote--prepare-note (title keywords date id directory file-type
template &optional signature)
+(defun denote--prepare-note (title keywords date id directory file-type
template signature)
"Prepare a new note file.
Arguments TITLE, KEYWORDS, DATE, ID, DIRECTORY, FILE-TYPE,
-TEMPLATE, and optional SIGNATURE should be valid for note
-creation."
+TEMPLATE, and SIGNATURE should be valid for note creation."
(let* ((path (denote--path title keywords directory id file-type signature))
(buffer (find-file path))
(header (denote--format-front-matter
@@ -1870,6 +1869,8 @@ instead of the default prompt.
Previous inputs at this prompt are available for minibuffer
completion. Consider `savehist-mode' to persist minibuffer
histories between sessions."
+ (when (and default-signature (string-empty-p default-signature))
+ (setq default-signature nil))
(denote-sluggify-signature
;; NOTE 2023-10-27: By default SPC performs completion in the
;; minibuffer. We do not want that, as the user should be able to
@@ -3856,7 +3857,7 @@ Consult the manual for template samples."
(setq denote-last-path
(denote--path title keywords
(file-name-as-directory (denote-directory))
- (format-time-string denote-id-format) 'org))
+ (format-time-string denote-id-format) 'org ""))
(denote--keywords-add-to-history keywords)
(concat front-matter denote-org-capture-specifiers)))
@@ -3895,7 +3896,7 @@ option `denote-templates'."
title (denote--date date 'org) kws
(format-time-string denote-id-format date) 'org)))
(setq denote-last-path
- (denote--path title kws directory id 'org))
+ (denote--path title kws directory id 'org ""))
(denote--keywords-add-to-history kws)
(concat front-matter template denote-org-capture-specifiers)))
- [elpa] externals/denote updated (5b92f37097 -> b5d3ab6e4e), ELPA Syncer, 2023/11/23
- [elpa] externals/denote 180bde5742 13/17: Refactor denote--default-directory-is-silo-p, ELPA Syncer, 2023/11/23
- [elpa] externals/denote 95f8c14e48 03/17: Simplify denote-link-return-links and denote-link-return-backlinks, ELPA Syncer, 2023/11/23
- [elpa] externals/denote cf63fd9015 05/17: Simplify denote-keywords-add and denote-keywords-remove, ELPA Syncer, 2023/11/23
- [elpa] externals/denote b936bbdf4e 08/17: Make signature parameter non optional for some functions,
ELPA Syncer <=
- [elpa] externals/denote 70d07dd122 02/17: Fix typo, ELPA Syncer, 2023/11/23
- [elpa] externals/denote 9742bca7e3 09/17: Fix denote-change-file-type-and-front-matter when there is a signature, ELPA Syncer, 2023/11/23
- [elpa] externals/denote ba7561688d 01/17: Remove unnecessary code in denote-trim-* functions and denote-extract-keywords-from-front-matter, ELPA Syncer, 2023/11/23
- [elpa] externals/denote 8e4a8ee69b 15/17: Refactor denote--link-in-context-regexp, ELPA Syncer, 2023/11/23
- [elpa] externals/denote b5d3ab6e4e 17/17: Merge pull request #193 from jeanphilippegg/cleanups, ELPA Syncer, 2023/11/23
- [elpa] externals/denote 39847ad78b 16/17: Refactor denote--link-format, ELPA Syncer, 2023/11/23
- [elpa] externals/denote 53d52d9d46 07/17: Fix documentation of denote-file-type, ELPA Syncer, 2023/11/23
- [elpa] externals/denote b5810569fe 10/17: Refactor denote--find-first-unused-id, ELPA Syncer, 2023/11/23
- [elpa] externals/denote 01ea1c2cc4 12/17: Remove unnecessary checks, ELPA Syncer, 2023/11/23
- [elpa] externals/denote 3ebc7026d4 11/17: signature should always be a string (maybe empty), ELPA Syncer, 2023/11/23