Created
December 30, 2013 03:18
-
-
Save vermiculus/8177389 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun *magit-delete-trailing-whitespace-from-file () | |
"Removes whitespace from the current item." | |
(interactive) | |
(save-excursion | |
(magit-visit-item) | |
(delete-trailing-whitespace) | |
(save-buffer) | |
(kill-buffer)) | |
(magit-refresh)) |
Yes; Magit's maintainer provided his own version on my SO question:
(defun my-magit-delete-trailing-whitespace-from-file ()
"Remove whitespace from the current file."
(interactive)
(save-excursion
(magit-diff-visit-file-worktree (magit-file-at-point))
(delete-trailing-whitespace)
(save-buffer)
(kill-buffer))
(magit-refresh))
If a reader is seeing this in the far future, I'd check the SO post for any possible updates for new Magit versions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code is obsolete with the latest version of magit. My fix was editing line 5 to:
(magit-diff-visit-file-worktree (magit-file-at-point))