[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote eee100cc50 062/355: Add denote-dired-rename-file
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote eee100cc50 062/355: Add denote-dired-rename-file |
Date: |
Sun, 26 Jun 2022 23:58:00 -0400 (EDT) |
branch: externals/denote
commit eee100cc508b6e6ff05150c329ff7a82406d0e8c
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Add denote-dired-rename-file
This is not limited to notes that were created with Denote: it works on
any file in any directory. The idea is to apply the Denote-style file
name in more contexts, such as for longer-term storage and attachments
to notes.
Also see commit 431124f, which is thematically aligned with this one.
Thanks to Ypot for giving me the idea in issue 1 over at the GitHub
mirror: <https://github.com/protesilaos/denote/issues/1>.
---
denote-dired.el | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/denote-dired.el b/denote-dired.el
index 8628f5a1d2..efc78008cd 100644
--- a/denote-dired.el
+++ b/denote-dired.el
@@ -34,11 +34,42 @@
;;; Code:
(require 'denote)
+(require 'dired)
(defgroup denote-dired ()
"Integration between Denote and Dired."
:group 'denote)
+;;;; Commands
+
+;;;###autoload
+(defun denote-dired-rename-file (title keywords)
+ "Rename file at point to new file with TITLE and KEYWORDS.
+This command is intended to complement note-taking, such as by
+renaming attachments that the user adds to their notes."
+ (interactive
+ (list
+ (denote--title-prompt)
+ (denote--keywords-prompt)))
+ (let* ((file (dired-get-filename))
+ (dir (file-name-directory file))
+ (old-name (file-name-nondirectory file))
+ (extension (file-name-extension file t))
+ (new-name (denote--format-file
+ dir
+ (format-time-string denote--id)
+ keywords
+ (denote--sluggify title)
+ extension)))
+ (when (y-or-n-p
+ (format "Rename %s to %s?"
+ (propertize old-name 'face 'error)
+ (propertize (file-name-nondirectory new-name) 'face
'success)))
+ (rename-file old-name new-name nil)
+ (revert-buffer))))
+
+;;;; Extra fontification
+
(defvar dired-font-lock-keywords)
(defvar denote-dired-original-keywords dired-font-lock-keywords
- [elpa] externals/denote 1be0255183 340/355: Reword some statements in the manual, (continued)
- [elpa] externals/denote 1be0255183 340/355: Reword some statements in the manual, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 5c13cf4c1c 354/355: Rename internal id front matter rx for consistency, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 733a89ead5 007/355: Add missing autoload, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 8e7d42b160 016/355: Fix all (?) problems with org-capture integration, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 69f28cfd29 031/355: Re-indent form, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 06cbd091d1 049/355: Tweak README---this is a work-in-progress, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 9a2c501cd4 051/355: Tweak wording in description, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 712e24465a 065/355: Update denote-dired.el Commentary, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 69e35281da 070/355: Document denote-front-matter-date-format, ELPA Syncer, 2022/06/27
- [elpa] externals/denote dfc3a8fc60 071/355: Use denote-directory rather than hardcoded path, ELPA Syncer, 2022/06/27
- [elpa] externals/denote eee100cc50 062/355: Add denote-dired-rename-file,
ELPA Syncer <=
- [elpa] externals/denote 0e65f05bbb 080/355: Use 'delete-region' instead of 'delete-line', ELPA Syncer, 2022/06/27
- [elpa] externals/denote ab27f5a547 086/355: Tweak sample configuration, ELPA Syncer, 2022/06/27
- [elpa] externals/denote f97f1f8b56 082/355: chore: Ignore compiled and autoloads Emacs-Lisp files, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 8167d0c30c 091/355: Revert "Stop recording the file path in the front matter", ELPA Syncer, 2022/06/27
- [elpa] externals/denote 6227df012f 100/355: Make org-capture always set .org extension, ELPA Syncer, 2022/06/27
- [elpa] externals/denote e840648623 098/355: Fix typo in the manual, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 9f192263db 092/355: Remove file path from front matter; improve links, ELPA Syncer, 2022/06/27
- [elpa] externals/denote db9584f51d 093/355: BREAKING Change date/identifier pattern, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 3e2b560548 099/355: Elaborate on the Overview of Denote, ELPA Syncer, 2022/06/27
- [elpa] externals/denote cfe6e98e7b 090/355: Stop recording the file path in the front matter, ELPA Syncer, 2022/06/27