You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One thing I'm frequently fighting with in Emacs (because it allows me to do crazy things like that) is how to synchronize file copies sent through TRAMP and local copies.
As a concrete example, I was doing a small hotfix on a Python library today, in /usr/lib/python3/dist-pacakges/npm2deb/mapper.py. The git source is in ~/src/npm2deb/npm2deb/mapper.py so I naturally started writing there. But then to test my changes, instead of rebuilding and reinstalling the whole thing, I cheat and write directly to the system lib with TRAMP (/:sudo:/usr/lib/python3/dist-pacakges/npm2deb/mapper.py or whatever that magic sauce is). Then I can tweak things there ("we'll do it live!") but what often happens is I forget to sync the file back into ~/src.
If there was a quick way to write a copy of the file without changing the buffer association, this would be much easier and intuitive. This SO thread has a few implementations, for example:
(defunmy-clone-and-open-file (filename)
"Clone the current buffer writing it into FILENAME and open it"
(interactive "FClone to file: ")
(save-restriction
(widen)
(write-region (point-min) (point-max) filename nilnilnil'confirm))
(find-file filename))
I would personally prefer that approach of keeping the other buffer in the background:
(defuncrux-clone-file (filename)
"Clone the current buffer writing it into FILENAME and open it in another buffer"
(interactive "FClone to file: ")
(save-restriction
(widen)
(write-region (point-min) (point-max) filename nilnilnil'confirm))
(find-file-no-select filename))
Obviously, for my use case, this would need to be added in a after-save-hook.
Would that make sense? would this be accepted as a PR?
Thanks!
The text was updated successfully, but these errors were encountered:
One thing I'm frequently fighting with in Emacs (because it allows me to do crazy things like that) is how to synchronize file copies sent through TRAMP and local copies.
As a concrete example, I was doing a small hotfix on a Python library today, in
/usr/lib/python3/dist-pacakges/npm2deb/mapper.py. The git source is in~/src/npm2deb/npm2deb/mapper.pyso I naturally started writing there. But then to test my changes, instead of rebuilding and reinstalling the whole thing, I cheat and write directly to the system lib with TRAMP (/:sudo:/usr/lib/python3/dist-pacakges/npm2deb/mapper.pyor whatever that magic sauce is). Then I can tweak things there ("we'll do it live!") but what often happens is I forget to sync the file back into~/src.If there was a quick way to write a copy of the file without changing the buffer association, this would be much easier and intuitive. This SO thread has a few implementations, for example:
I would personally prefer that approach of keeping the other buffer in the background:
Obviously, for my use case, this would need to be added in a
after-save-hook.Would that make sense? would this be accepted as a PR?
Thanks!
The text was updated successfully, but these errors were encountered: