[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 2f42da8 228/486: Add rust-promote-module-into-di
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 2f42da8 228/486: Add rust-promote-module-into-dir |
Date: |
Sat, 7 Aug 2021 09:25:24 -0400 (EDT) |
branch: elpa/rust-mode
commit 2f42da89c773b9eaf439d23553a02c4de39829d7
Author: Tom Jakubowski <tom@crystae.net>
Commit: Tom Jakubowski <tom@crystae.net>
Add rust-promote-module-into-dir
Lacking tests and completely untested on Windows!
closes #128
---
rust-mode.el | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/rust-mode.el b/rust-mode.el
index 56b356d..2ce102a 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1402,6 +1402,28 @@ See `compilation-error-regexp-alist' for help on their
format.")
(interactive)
(rust-playpen-region (point-min) (point-max)))
+(defun rust-promote-module-into-dir ()
+ "Promote the module file visited by the current buffer into its own
directory.
+
+For example, if the current buffer is visiting the file `foo.rs',
+then this function creates the directory `foo' and renames the
+file to `foo/mod.rs'. The current buffer will be updated to
+visit the new file."
+ (interactive)
+ (let ((filename (buffer-file-name)))
+ (if (not filename)
+ (message "Buffer is not visiting a file.")
+ (if (string-equal (file-name-nondirectory filename) "mod.rs")
+ (message "Won't promote a module file already named mod.rs.")
+ (let* ((basename (file-name-sans-extension
+ (file-name-nondirectory filename)))
+ (mod-dir (file-name-as-directory
+ (concat (file-name-directory filename) basename)))
+ (new-name (concat mod-dir "mod.rs")))
+ (mkdir mod-dir t)
+ (rename-file filename new-name 1)
+ (set-visited-file-name new-name))))))
+
(provide 'rust-mode)
;;; rust-mode.el ends here
- [nongnu] elpa/rust-mode c69adaf 254/486: Add menu titles for items in imenu, (continued)
- [nongnu] elpa/rust-mode c69adaf 254/486: Add menu titles for items in imenu, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode dae5af7 298/486: Merge pull request #198 from tromey/indentation-fix, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode bfe4056 452/486: Re-implement rust-in-macro for performance, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode eaf95af 210/486: Merge pull request #111 from mrBliss/where-indentation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2540d7e 262/486: Go back to the current line and column after formatting., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 52870b6 203/486: Remove unused require of misc.el, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 95d089c 211/486: Merge pull request #110 from mrBliss/fix-103, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 00e5366 224/486: Merge pull request #122 from kraai/remove-duplicate-keywords, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0601540 205/486: Merge pull request #96 from MicahChalmer/add-licenses, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1492106 232/486: Fix hook args for after-revert-hook, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2f42da8 228/486: Add rust-promote-module-into-dir,
ELPA Syncer <=
- [nongnu] elpa/rust-mode 0914b48 234/486: Merge pull request #133 from kraai/avoid-cl, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 917503b 244/486: Fix failing tests, and add a test for the fix., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode a8a5e14 245/486: Fix for emacs24, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ed0b390 246/486: Merge pull request #148 from bmastenbrook/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b971c6d 247/486: Fix #151, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode abadab0 009/486: Update rust-mode.el with new keywords., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 6275e8e 010/486: Add trait to emacs keyword table., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9f21b28 024/486: change to 4-space indents everywhere, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode f1b6007 174/486: Merge pull request #71 from birkenfeld/doc-comments, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 07943f0 178/486: Perform syntactic angle bracket matching, ELPA Syncer, 2021/08/07