[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote ea0f50575e 5/5: Make some "rename" functions pub
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote ea0f50575e 5/5: Make some "rename" functions public |
Date: |
Wed, 14 Sep 2022 03:57:33 -0400 (EDT) |
branch: externals/denote
commit ea0f50575efc6ba5592c9406932fd87d28d52c6c
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Make some "rename" functions public
We are working towards version 1.0.0. The idea is to provide functions
that users/developers can rely on. By making them public (removing the
double hyphens) we signify that those forms are (i) in a stable
state, and (ii) any change to them will be handled with care and
documented accordingly.
---
README.org | 6 ++++++
denote.el | 29 +++++++++++++++++++----------
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/README.org b/README.org
index 0ffd9b4737..0bb3fe4320 100644
--- a/README.org
+++ b/README.org
@@ -2105,6 +2105,12 @@ might change them without further notice.
category (so it works with packages such as ~marginalia~ and
~embark~).
++ ~denote-rename-file-prompt~ :: Prompt to rename file named =OLD-NAME=
+ to =NEW-NAME=.
+
++ ~denote-rename-file-and-buffer~ :: Rename file named =OLD-NAME= to
+ =NEW-NAME=, updating buffer name.
+
+ ~denote-file-types~ :: Alist of ~denote-file-type~ and their format
properties. Each element is of the form =(SYMBOL . PROPERTY-LIST)=.
=SYMBOL= is one of those specified in ~denote-file-type~.
diff --git a/denote.el b/denote.el
index cd9ad8fab8..e0102fb0c0 100644
--- a/denote.el
+++ b/denote.el
@@ -1491,13 +1491,17 @@ the file type is assumed to be the first of
`denote-file-types'."
(with-current-buffer buffer
(set-visited-file-name new-name nil t))))
-(defun denote--rename-file (old-name new-name)
- "Rename file named OLD-NAME to NEW-NAME.
-Update Dired buffers if the file is renamed."
+(defun denote-rename-file-and-buffer (old-name new-name)
+ "Rename file named OLD-NAME to NEW-NAME, updating buffer name."
(unless (string= (expand-file-name old-name) (expand-file-name new-name))
(rename-file old-name new-name nil)
(denote--rename-buffer old-name new-name)))
+(define-obsolete-function-alias
+ 'denote--rename-file
+ 'denote-rename-file-and-buffer
+ "1.0.0")
+
(defun denote--add-front-matter (file title keywords id file-type)
"Prepend front matter to FILE if `denote--only-note-p'.
The TITLE, KEYWORDS ID, and FILE-TYPE are passed from the
@@ -1595,7 +1599,7 @@ Throw error is FILE is not regular, else return FILE."
(user-error "Only rename regular files")
selected-file))))
-(defun denote--rename-file-prompt (old-name new-name)
+(defun denote-rename-file-prompt (old-name new-name)
"Prompt to rename file named OLD-NAME to NEW-NAME."
(unless (string= (expand-file-name old-name) (expand-file-name new-name))
(y-or-n-p
@@ -1603,6 +1607,11 @@ Throw error is FILE is not regular, else return FILE."
(propertize (file-name-nondirectory old-name) 'face 'error)
(propertize (file-name-nondirectory new-name) 'face 'success)))))
+(define-obsolete-function-alias
+ 'denote--rename-file-prompt
+ 'denote-rename-file-prompt
+ "1.0.0")
+
;;;###autoload
(defun denote-rename-file (file title keywords)
"Rename file and update existing front matter if appropriate.
@@ -1674,8 +1683,8 @@ files)."
(new-name (denote-format-file-name
dir id keywords (denote-sluggify title) extension))
(max-mini-window-height 0.33)) ; allow minibuffer to be resized
- (when (denote--rename-file-prompt file new-name)
- (denote--rename-file file new-name)
+ (when (denote-rename-file-prompt file new-name)
+ (denote-rename-file-and-buffer file new-name)
(denote-update-dired-buffers)
(when (denote--writable-and-supported-p new-name)
(if (denote--edit-front-matter-p new-name file-type)
@@ -1738,7 +1747,7 @@ The operation does the following:
(extension (file-name-extension file t))
(new-name (denote-format-file-name
dir id keywords (denote-sluggify title)
extension)))
- (denote--rename-file file new-name)
+ (denote-rename-file-and-buffer file new-name)
(when (denote--writable-and-supported-p new-name)
(if (denote--edit-front-matter-p new-name file-type)
(denote--rewrite-keywords new-name keywords file-type)
@@ -1782,8 +1791,8 @@ typos and the like."
(dir (file-name-directory file))
(new-name (denote-format-file-name
dir id keywords (denote-sluggify title) extension)))
- (when (denote--rename-file-prompt file new-name)
- (denote--rename-file file new-name)
+ (when (denote-rename-file-prompt file new-name)
+ (denote-rename-file-and-buffer file new-name)
(denote-update-dired-buffers))
(user-error "No front matter for title and/or keywords")))
@@ -1831,7 +1840,7 @@ their respective front matter."
(extension (file-name-extension file t))
(new-name (denote-format-file-name
dir id keywords (denote-sluggify title)
extension)))
- (denote--rename-file file new-name)))
+ (denote-rename-file-and-buffer file new-name)))
(revert-buffer))
(user-error "No marked files; aborting")))