Open rommeswi opened 2 months ago
Well, and something related that would be very intuitive to have is a default binding for creating a new buffer and saving it as a new file. SPC b n n
and SPC f s
should somehow be combined into SPC f n
or something similar. Or is there a reason why this binding does not exist? For new users it would definitely be very natural.
default binding for creating a new buffer and saving it as a new file.
You can just use SPC f f
to specify a file you want to create, write some contents, and then save as SPC f s
(you'll have to press that at some point eventually to save whatever you write, so there's no way to do it in just one key binding).
Indeed, I totally missed that possibility. Thank you for improving my workflow! Regarding the SPC f c
option of not querying for whether to open the file, it would still be a nice to have.
I would not object to adding a user option. In any case, one could of course change the behaviour locally with something like:
(defun my/spacemacs/save-as (filename)
(interactive (list (expand-file-name (read-file-name "Save buffer as: " nil nil nil
(when current-prefix-arg (buffer-name))))))
(spacemacs/save-as filename :current))
(spacemacs/set-leader-keys "fc" 'my/spacemacs/save-as)
This is slightly inconvenient as there does not seem to be an idiomatic way to call a function using its interactive specification for some of its arguments, and using fixed values for the remaining ones. Hence I just copied the interactive specification[^1] of the first argument from spacemacs/save-as
.
[^1]: As a side note, as an alternative to using a prefix argument, inserting the current file name can be done using the future history, i. e. by pressing M-n
in the minibuffer prompt. Of course this uses the file name instead of the buffer name, which only makes sense for file-backed buffers. In the latter case, however, the behaviour might be preferable, for example when buffer names have been uniquified.
This is just a minor issue I have with saving copies of files since a while ago. I remember when first using spacemacs, I did not have this issue:
Whenever I save a buffer as a copy with
SPC f c
, spacemacs queries me whether I want to open the file. I have never not opened the new file. I understand that for some users who frequently create backups of files usingSPC f c
, not opening the newly saved file should be an option. What I would like to have is an optiondotspacemacs-default-open-file-on-copy
or something similar that I can set to "current", "other", or "nil" to avoid the extra query.If this would be undesirable, feel free to directly reject the issue, it is really just a very minor annoyance.