diff options
author | Sacha Chua <sacha@sachachua.com> | 2023-11-19 16:06:19 -0500 |
---|---|---|
committer | Sacha Chua <sacha@sachachua.com> | 2023-11-19 16:06:19 -0500 |
commit | ced2ca54cc7ad205fa9bdeca23452634f72487f2 (patch) | |
tree | 3c825b6be47f73348db8b7d6c174d2ac6dde7e60 | |
parent | feeb2184242e56e70564a1551adcd856260ddbad (diff) | |
download | emacsconf-el-ced2ca54cc7ad205fa9bdeca23452634f72487f2.tar.xz emacsconf-el-ced2ca54cc7ad205fa9bdeca23452634f72487f2.zip |
New function emacsconf-update-file-prefixes
-rw-r--r-- | emacsconf.el | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/emacsconf.el b/emacsconf.el index d5e6c3d..1b33c31 100644 --- a/emacsconf.el +++ b/emacsconf.el @@ -260,6 +260,27 @@ Return the list of new filenames." (when (derived-mode-p 'dired-mode) (revert-buffer)))) +(defun emacsconf-update-file-prefixes (talk &optional dry-run) + "Update all files for the specified SLUG to use the new file prefix." + (interactive (list (emacsconf-complete-talk-info))) + (let (results) + (dolist (dir (list + emacsconf-cache-dir + (and emacsconf-res-dir (expand-file-name "cache" emacsconf-res-dir)) + emacsconf-backstage-dir)) + (when (and dir (file-directory-p dir)) + (dolist (file (directory-files dir t (concat "^" emacsconf-id "-" emacsconf-year "-" (plist-get talk :slug) "--.*"))) + (let ((new-file (replace-regexp-in-string + (concat "/" emacsconf-id "-" emacsconf-year "-" (plist-get talk :slug) "--.*?--.*?\\(\\(--.*\\)?\.[a-zA-Z0-9]+\\)$") + (concat "/" (plist-get talk :file-prefix) + "\\1") + file))) + (unless (string= file new-file) + (unless dry-run + (rename-file file new-file)) + (add-to-list 'results (cons file new-file) t)))))) + results)) + (defun emacsconf-rename-and-upload-to-backstage (talk &optional filename) "Rename marked files or the current file, then upload to backstage." (interactive (list (emacsconf-complete-talk-info))) |