Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvement: option to disable query for whether to open newly saved file #16362

Open
rommeswi opened this issue Apr 8, 2024 · 4 comments

Comments

@rommeswi
Copy link
Contributor

rommeswi commented Apr 8, 2024

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 using SPC f c, not opening the newly saved file should be an option. What I would like to have is an option dotspacemacs-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.

@rommeswi
Copy link
Contributor Author

rommeswi commented Apr 8, 2024

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.

@bcc32
Copy link
Contributor

bcc32 commented Apr 8, 2024

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).

@rommeswi
Copy link
Contributor Author

rommeswi commented Apr 8, 2024

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.

@fnussbaum
Copy link
Contributor

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 specification1 of the first argument from spacemacs/save-as.

Footnotes

  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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants