Last active
July 11, 2016 13:34
-
-
Save jidaikobo-shibata/604173d11ff376036635fd4811df6abb to your computer and use it in GitHub Desktop.
Emacs(Elisp): To integrate indent style, delete existing whitespaces before indent-for-tab-command. indent-for-tab-commandの前に存在する行頭ホワイトスペースを削除することでインデントスタイルを統一する
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
;; defadvice-indent-for-tab-command | |
;; gist-description: Emacs(Elisp): To integrate indent style, delete existing whitespaces before indent-for-tab-command. indent-for-tab-commandの前に存在する行頭ホワイトスペースを削除することでインデントスタイルを統一する | |
;; gist-id: 604173d11ff376036635fd4811df6abb | |
;; gist-name: defadvice-indent-for-tab-command.el | |
;; gist-private: nil | |
(defadvice indent-for-tab-command (around advise-indent-for-tab-command activate) | |
"To integrate indent style, delete existing whitespaces before indentation." | |
(let (beg | |
end | |
(end-line nil)) | |
(cond | |
((use-region-p) | |
(setq beg (region-beginning) | |
end (region-end) | |
end-line (line-number-at-pos end))) | |
(t | |
(beginning-of-line) | |
(setq beg (point)) | |
(end-of-line) | |
(setq end (point)))) | |
(perform-replace "^[\t ]+" "" nil t nil nil nil beg end) | |
(goto-char beg) | |
(set-mark-command nil) | |
(goto-char end) | |
ad-do-it | |
(when end-line (goto-line (- end-line 1))) ;; why should i have to do minus? | |
(back-to-indentation))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment