branch: externals/phpinspect commit 99e628847cfd5591c3e9ace3ccaf6fe20cf26fe3 Author: Hugo Thunnissen <de...@hugot.nl> Commit: Hugo Thunnissen <de...@hugot.nl>
Wrap buffer edit logic in `save-excursion' --- phpinspect-imports.el | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/phpinspect-imports.el b/phpinspect-imports.el index 805a955755..2704a66199 100644 --- a/phpinspect-imports.el +++ b/phpinspect-imports.el @@ -210,20 +210,21 @@ group." ;; Re-insert use statements (with-current-buffer (phpinspect-buffer-buffer buffer) - (goto-char start) - (delete-region start end) - (dolist (statement statements) - (insert (format "use %s;%c" (car statement) ?\n))) - - (if (and (looking-at "[[:blank:]\n]+")) - ;; Delete excess trailing whitespace (there's more than 2 between the - ;; last use statement and the next token) - (when (< 1 (- (match-end 0) (match-beginning 0))) - (delete-region (match-beginning 0) (match-end 0)) - (insert-char ?\n)) - ;; Insert an extra newline (there's only one between the last use - ;; statement and the next token) - (insert-char ?\n)))))) + (save-excursion + (goto-char start) + (delete-region start end) + (dolist (statement statements) + (insert (format "use %s;%c" (car statement) ?\n))) + + (if (and (looking-at "[[:blank:]\n]+")) + ;; Delete excess trailing whitespace (there's more than 2 between the + ;; last use statement and the next token) + (when (< 1 (- (match-end 0) (match-beginning 0))) + (delete-region (match-beginning 0) (match-end 0)) + (insert-char ?\n)) + ;; Insert an extra newline (there's only one between the last use + ;; statement and the next token) + (insert-char ?\n))))))) (defun phpinspect-fix-imports () "Find types that are used in the current buffer and make sure