Improve point handling in perltidy functions
This moves the point and content of the window close to where you were before you ran perltidy. Of course if perltidy adds or removes a significant amount of characters / lines as part of tidying, the point will be moved by that amount. However in practice this I've found this to be close enough.
This commit is contained in:
parent
5389bf976d
commit
0f40fe9df2
|
@ -2074,6 +2074,10 @@ Other:
|
|||
- Fixed =spacemacs/run-pandoc= not to reset =pandoc--local-settings=
|
||||
(thanks to martian-f)
|
||||
- Added declaration for the ~SPC P~ prefix (thanks to Codruț Constantin Gușoi)
|
||||
**** Perl5
|
||||
- Fixed =spacemacs/perltidy-format-buffer= and
|
||||
=spacemacs/perltidy-format-function= to move the point and window to their
|
||||
original locations.
|
||||
**** PHP
|
||||
- Added company-php (thanks to jim and Eivind Fonn)
|
||||
- Fixed php-company autocompletion (thanks to Dela Anthonio)
|
||||
|
|
|
@ -40,11 +40,19 @@ If region is active, operate on it, else operate on line."
|
|||
(defun spacemacs/perltidy-format-buffer ()
|
||||
"Format current buffer with perltidy."
|
||||
(interactive)
|
||||
(let ((old-point (point))
|
||||
(old-window-start (window-start)))
|
||||
(mark-whole-buffer)
|
||||
(spacemacs/perltidy-format))
|
||||
(spacemacs/perltidy-format)
|
||||
(goto-char old-point)
|
||||
(set-window-start (selected-window) old-window-start)))
|
||||
|
||||
(defun spacemacs/perltidy-format-function ()
|
||||
"Format current function with perltidy."
|
||||
(interactive)
|
||||
(let ((old-point (point))
|
||||
(old-window-start (window-start)))
|
||||
(mark-defun)
|
||||
(spacemacs/perltidy-format))
|
||||
(spacemacs/perltidy-format)
|
||||
(goto-char old-point)
|
||||
(set-window-start (selected-window) old-window-start)))
|
||||
|
|
Loading…
Reference in a new issue