py-isort.el
py-isort.el copied to clipboard
Can't not sort region that in a non-file buffer
When the buffer is not saved, or in org-src-mode
which is not related to a file, py-isort
alerts an error.
I wrote a function to do that after seeing this package and your comment. The function does not rely on any Emacs package and is quite short:
(defun isort-buffer ()
"Uses the Python program isort on current buffer."
(interactive)
(setq tmp-file (make-temp-file "isort-test"))
(mark-whole-buffer)
(write-region (point-min) (point-max) tmp-file)
(shell-command (concat "isort " tmp-file))
(erase-buffer)
(insert-file-contents tmp-file))
You can just bind it to your favorite shortcut or call it with M-x
.