[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote e3c099bc25 01/14: Refactor denote--date
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote e3c099bc25 01/14: Refactor denote--date |
Date: |
Wed, 10 Aug 2022 01:57:29 -0400 (EDT) |
branch: externals/denote
commit e3c099bc256a9e477eba420c267719fe853f1ddd
Author: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Commit: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Refactor denote--date
- Make date parameter mandatory.
- Add file-type parameter.
---
denote.el | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/denote.el b/denote.el
index 66b9796d0f..9104d643e4 100644
--- a/denote.el
+++ b/denote.el
@@ -752,34 +752,34 @@ provided by `denote'. FILETYPE is one of the values of
;; Adapted from `org-hugo--org-date-time-to-rfc3339' in the `ox-hugo'
;; package: <https://github.com/kaushalmodi/ox-hugo>.
-(defun denote--date-rfc3339 (&optional date)
+(defun denote--date-rfc3339 (date)
"Format date using the RFC3339 specification.
-With optional DATE, use it else use the current one."
+If DATE is nil, use the current date."
(replace-regexp-in-string
"\\([0-9]\\{2\\}\\)\\([0-9]\\{2\\}\\)\\'" "\\1:\\2"
(format-time-string "%FT%T%z" date)))
-(defun denote--date-org-timestamp (&optional date)
+(defun denote--date-org-timestamp (date)
"Format date using the Org inactive timestamp notation.
-With optional DATE, use it else use the current one."
+If DATE is nil, use the current date."
(format-time-string "[%F %a %R]" date))
-(defun denote--date-iso-8601 (&optional date)
+(defun denote--date-iso-8601 (date)
"Format date according to ISO 8601 standard.
-With optional DATE, use it else use the current one."
+If DATE is nil, use the current date."
(format-time-string "%F" date))
-(defun denote--date (&optional date)
- "Expand the date for a new note's front matter.
-With optional DATE, use it else use the current one."
+(defun denote--date (date file-type)
+ "Expand the DATE in an appropriate format for FILE-TYPE.
+If DATE is nil, use the current date."
(let ((format denote-date-format))
(cond
((stringp format)
(format-time-string format date))
- ((or (eq denote-file-type 'markdown-toml)
- (eq denote-file-type 'markdown-yaml))
+ ((or (eq file-type 'markdown-toml)
+ (eq file-type 'markdown-yaml))
(denote--date-rfc3339 date))
- ((eq denote-file-type 'text)
+ ((eq file-type 'text)
(denote--date-iso-8601 date))
(t
(denote--date-org-timestamp date)))))
@@ -792,7 +792,7 @@ and TEMPLATE should be valid for note creation."
(let* ((path (denote--path title keywords directory id file-type))
(buffer (find-file path))
(header (denote--format-front-matter
- title (denote--date date) keywords
+ title (denote--date date file-type) keywords
(format-time-string denote--id-format date)
file-type)))
(with-current-buffer buffer
@@ -1115,7 +1115,7 @@ command and are used to construct a new front matter
block if
appropriate."
(when-let* (((denote--only-note-p file))
(filetype (denote--filetype-heuristics file))
- (date (denote--date (date-to-time id)))
+ (date (denote--date (date-to-time id) filetype))
(new-front-matter (denote--format-front-matter title date
keywords id filetype)))
(with-current-buffer (find-file-noselect file)
(goto-char (point-min))
@@ -2164,7 +2164,7 @@ Consult the manual for template samples."
(let* ((title (denote--title-prompt))
(keywords (denote--keywords-prompt))
(front-matter (denote--format-front-matter
- title (denote--date nil) keywords
+ title (denote--date nil 'org) keywords
(format-time-string denote--id-format nil) 'org)))
(setq denote-last-path
(denote--path title keywords
- [elpa] externals/denote 8103476e31 03/14: Simplify docstrings of helper date functions, (continued)
- [elpa] externals/denote 8103476e31 03/14: Simplify docstrings of helper date functions, ELPA Syncer, 2022/08/10
- [elpa] externals/denote f04fb92eae 13/14: Remove potentially confusing statement in doc, ELPA Syncer, 2022/08/10
- [elpa] externals/denote b201438b70 08/14: Add denote-templates :info link, ELPA Syncer, 2022/08/10
- [elpa] externals/denote 94fb45c486 04/14: Placate the compiler regarding docstring format, ELPA Syncer, 2022/08/10
- [elpa] externals/denote 8c28b4818b 09/14: Remove delete-dups from denote--inferred-keywords, ELPA Syncer, 2022/08/10
- [elpa] externals/denote f3cd705d51 05/14: Clarify doc string, ELPA Syncer, 2022/08/10
- [elpa] externals/denote 94cbaf151e 06/14: Add clarification to Commentary, ELPA Syncer, 2022/08/10
- [elpa] externals/denote 18a210b265 12/14: Add comment about front matter format variables, ELPA Syncer, 2022/08/10
- [elpa] externals/denote 394c5d3e69 10/14: Tweak indentation for stylistic consistency, ELPA Syncer, 2022/08/10
- [elpa] externals/denote b401e249e9 14/14: Clarify comment about duplicate IDs, ELPA Syncer, 2022/08/10
- [elpa] externals/denote e3c099bc25 01/14: Refactor denote--date,
ELPA Syncer <=
- [elpa] externals/denote 0ab93d9f8a 07/14: Fix typo in the manual, ELPA Syncer, 2022/08/10
- [elpa] externals/denote 20040e7a2f 11/14: Clarify docstring about 'downcase' function, ELPA Syncer, 2022/08/10
- [elpa] externals/denote 877c7243b9 02/14: Merge pull request #83 from jeanphilippegg/cleanup, ELPA Syncer, 2022/08/10