[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote e92137a548 148/355: Use file attribute for mod t
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote e92137a548 148/355: Use file attribute for mod time while renaming |
Date: |
Sun, 26 Jun 2022 23:58:16 -0400 (EDT) |
branch: externals/denote
commit e92137a548ea703d4d4a068aadc6e8e5bb24224d
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Use file attribute for mod time while renaming
This means that if you are renaming "sample.pdf" from 2000-11-31 you
will get an identifier that reflects that date, instead of CURRENT-TIME.
Note that there are other file attributes for time. Read the doc string
of 'file-attributes'. If there is demand for it, we can add a user
option, otherwise I feel 'file-attribute-modification-time' is a
reasonable default.
Thanks to Jack Baty for proposing the idea over at the mailing list:
<https://lists.sr.ht/~protesilaos/denote/%3Cm2v8t6b45f.fsf@baty.net%3E>.
---
README.org | 20 +++++++++++++-------
denote-dired.el | 16 ++++++++++++----
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/README.org b/README.org
index 9859436aa1..6feb5359f4 100644
--- a/README.org
+++ b/README.org
@@ -284,25 +284,31 @@ facilitate the task of renaming them.
#+findex: denote-dired-rename-file
To this end, we provide the ~denote-dired-rename-file~ command. It has
-a two-fold purpose: (i) to change the file name of an existing note
-while retaining its identifier and (ii) to write a Denote-style file
-name for an item that was not created by ~denote~ or related commands
-(such as an image or PDF).
+a two-fold purpose: (i) to change the name of an existing file while
+retaining its identifier and (ii) to write a Denote-compliant file name
+for an item that was not created by ~denote~ or related commands (such
+as an image or PDF).
The ~denote-dired-rename-file~ command will target the file at point if
it finds one in the current Dired buffer. Otherwise it prompts with
minibuffer completion for a file name. It then uses the familiar
prompts for a =TITLE= and =KEYWORDS= the same way the ~denote~ command
-does it ([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]). As a
final step it asks for confirmation
+does ([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]). As a
final step, it asks for confirmation
before renaming the file at point, showing a message like:
#+begin_example
Rename sample.pdf to 20220612T052900--my-sample-title__testing.pdf? (y or n)
#+end_example
+When operating on a file that has no identifier, such as =sample.pdf=,
+Denote reads the file properties to retrieve its last modification time.
+If the file was from a past date like 2000-11-31 it will get an
+identifier starting with =20001131= followed by the time component (per
+our file-naming scheme).
+
The file type extension (e.g. =.pdf=) is read from the underlying file
-and is preserved in the renaming process. Files that have no extension
-are simply left without one.
+and is preserved through the renaming process. Files that have no
+extension are simply left without one.
Renaming only occurs relative to the current directory. Files are not
moved between directories.
diff --git a/denote-dired.el b/denote-dired.el
index 2598ecae9b..1856e9e37c 100644
--- a/denote-dired.el
+++ b/denote-dired.el
@@ -80,11 +80,19 @@
;;;; Commands
+(defun denote-dired--file-attributes-time (file)
+ "Return `file-attribute-modification-time' of FILE as identifier."
+ (format-time-string
+ denote--id
+ (file-attribute-modification-time (file-attributes file))))
+
(defun denote-dired--file-name-id (file)
- "Return FILE identifier, else provide one."
- (if (string-match denote--id-regexp file)
- (substring file (match-beginning 0) (match-end 0))
- (format-time-string denote--id)))
+ "Return FILE identifier, else generate one."
+ (cond
+ ((string-match denote--id-regexp file)
+ (substring file (match-beginning 0) (match-end 0)))
+ ((denote-dired--file-attributes-time file))
+ (t (format-time-string denote--id))))
;;;###autoload
(defun denote-dired-rename-file (file title keywords)
- [elpa] externals/denote 2eeedaf86a 075/355: Placate the compiler about 'denote-directory', (continued)
- [elpa] externals/denote 2eeedaf86a 075/355: Placate the compiler about 'denote-directory', ELPA Syncer, 2022/06/26
- [elpa] externals/denote eafc777268 076/355: Use 'denote-directory' function for '#+link', ELPA Syncer, 2022/06/26
- [elpa] externals/denote d08a72e19a 081/355: Re-indent line, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 5dace99b8d 085/355: Acknowledge Kaushal Modi for commit f97f1f8, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 85e33cb523 107/355: Remove needless single quotes, ELPA Syncer, 2022/06/26
- [elpa] externals/denote ba7299d878 088/355: Add TODO about styling 'denote-link' command, ELPA Syncer, 2022/06/26
- [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 <=
- [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, 2022/06/27
- [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