Skip to content

Commit bca8afb

Browse files
jasonrobotgrafov
authored andcommitted
Removed hardcoded path, fix for first time not creating playground basedir (#7)
* Reworked this since it didnt work for me at all. Now uses 'cargo run' and proper crate dir structure, with a cargo.toml file. * fixed up deletion to be more robust * commented out debug message * removed a bunch of unused and commented out code * more cleanup, also -rm wasnt using the new snippet base dir function * added a macro to wrap interactive commands, to warn and exit if not in a playground * changed those big blocks of text to custom vars * finally got the keymap working * cleaned up the file header/template * remembered that 'unless' exists * killed dead code, added a comment * Made template work in cargo.toml. Fixed places where 'unless doesnt work. * fixed up the -rm function, now it actually kills all buffers related to the snippet (basically) * corrected comment * moved a function up for readability, updated Commentary documentation section, restored README.md, deleted unused upload/download code (rust playground on the web just uses gists on github) * wasnt ever using the rust-playground-compile-command custom, so used that * updated the startup screenshot to show the new stuff * made use of some of the functions I defined, DRY * fixed a hard coded path that was breaking the package * used mapcar instead of seq-map because its built-in, made the snippet dir create parents for first run.
1 parent 9b3f2a6 commit bca8afb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

rust-playground.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Start from PATH or the path of the current buffer's file, or NIL if this is not
107107
(if (not path)
108108
nil
109109
(if (not (string= path "/"))
110-
(let ((base "/home/jason/.emacs.d/rust-playground")
110+
(let ((base (expand-file-name rust-playground-basedir))
111111
(path-parent (file-name-directory (directory-file-name path))))
112112
(if (string= (file-name-as-directory base)
113113
(file-name-as-directory path-parent))
@@ -141,7 +141,7 @@ Otherwise message the user that they aren't in one."
141141
(snippet-file-name (rust-playground-snippet-main-file-name snippet-dir))
142142
(snippet-cargo-toml (rust-playground-toml-file-name snippet-dir)))
143143
;; create a buffer for Cargo.toml and switch to it
144-
(make-directory snippet-dir)
144+
(make-directory snippet-dir t)
145145
(set-buffer (create-file-buffer snippet-cargo-toml))
146146
(set-visited-file-name snippet-cargo-toml t)
147147
(rust-playground-mode)
@@ -194,7 +194,7 @@ Toggle between main.rs and Cargo.toml: C-c b
194194
(let* ((basedir (rust-playground-get-snippet-basedir))
195195
(srcdir (concat basedir (file-name-as-directory "src"))))
196196
;; now get the fullpath of cargo.toml, and the fullpath of every file under src/
197-
(remove 'nil (seq-map 'find-buffer-visiting
197+
(remove 'nil (mapcar 'find-buffer-visiting
198198
(cons (concat basedir "Cargo.toml")
199199
(directory-files srcdir t ".*\.rs")))))))
200200

0 commit comments

Comments
 (0)