[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 936a187 276/486: handle indirect buffers and mul
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 936a187 276/486: handle indirect buffers and multiple windows in rust-format-buffer |
Date: |
Sat, 7 Aug 2021 09:25:35 -0400 (EDT) |
branch: elpa/rust-mode
commit 936a1878b7b5c60ee5f3d501df262028821fa2f3
Author: Trevor Spiteri <tspiteri@ieee.org>
Commit: Trevor Spiteri <tspiteri@ieee.org>
handle indirect buffers and multiple windows in rust-format-buffer
---
rust-mode.el | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 54 insertions(+), 11 deletions(-)
diff --git a/rust-mode.el b/rust-mode.el
index 60a81f1..55148f6 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1287,17 +1287,60 @@ This is written mainly to be used as
`end-of-defun-function' for Rust."
(unless (executable-find rust-rustfmt-bin)
(error "Could not locate executable \"%s\"" rust-rustfmt-bin))
- (let ((cur-line (line-number-at-pos))
- (cur-column (current-column))
- (cur-win-start (window-start)))
- (rust--format-call (current-buffer))
- ;; Move to the same line and column as before. This is best
- ;; effort: if rustfmt inserted lines before point, we end up in
- ;; the wrong place. See issue #162.
- (goto-char (point-min))
- (forward-line (1- cur-line))
- (forward-char cur-column)
- (set-window-start (selected-window) cur-win-start))
+ (let* ((current (current-buffer))
+ (base (or (buffer-base-buffer current) current))
+ buffer-pos
+ window-pos)
+ (dolist (buffer (buffer-list))
+ (when (or (eq buffer base)
+ (eq (buffer-base-buffer buffer) base))
+ (with-current-buffer buffer
+ (push (list buffer
+ (line-number-at-pos)
+ (current-column))
+ buffer-pos))))
+ (dolist (window (window-list))
+ (let ((buffer (window-buffer window)))
+ (when (or (eq buffer base)
+ (eq (buffer-base-buffer buffer) base))
+ (let ((start (window-start window))
+ (point (window-point window)))
+ (with-current-buffer buffer
+ (push (list window
+ (line-number-at-pos start)
+ (save-excursion (goto-char start) (current-column))
+ (line-number-at-pos point)
+ (save-excursion (goto-char point) (current-column)))
+ window-pos))))))
+ (rust--format-call current)
+ (dolist (pos buffer-pos)
+ (let ((buffer (pop pos))
+ (line (pop pos))
+ (column (pop pos)))
+ (with-current-buffer buffer
+ ;; Move to the same line and column as before. This is best
+ ;; effort: if rustfmt inserted lines before point, we end up in
+ ;; the wrong place. See issue #162.
+ (goto-char (point-min))
+ (forward-line (1- line))
+ (forward-char column))))
+ (dolist (pos window-pos)
+ (let ((window (pop pos))
+ (start-line (pop pos))
+ (start-column (pop pos))
+ (point-line (pop pos))
+ (point-column (pop pos)))
+ (with-current-buffer (window-buffer window)
+ (let ((start (save-excursion (goto-char (point-min))
+ (forward-line (1- start-line))
+ (forward-char start-column)
+ (point)))
+ (point (save-excursion (goto-char (point-min))
+ (forward-line (1- point-line))
+ (forward-char point-column)
+ (point))))
+ (set-window-start window start)
+ (set-window-point window point))))))
;; Issue #127: Running this on a buffer acts like a revert, and could cause
;; the fontification to get out of sync. Call the same hook to ensure it is
- [nongnu] elpa/rust-mode 54a9c3d 380/486: Merge pull request #296 from dekellum/indent-return-type-defcustom, (continued)
- [nongnu] elpa/rust-mode 54a9c3d 380/486: Merge pull request #296 from dekellum/indent-return-type-defcustom, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ce7a27f 381/486: Add compilation mode warning face, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c1059d6 387/486: Added angle bracket tests, some of which fail without the fix, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 06f1c68 389/486: Merge pull request #300 from mmilenko/rust-looking-back-macro--backward-char--fix, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 48290d3 399/486: Merge pull request #318 from kraai/patch-1, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode f6ebcbd 400/486: Update travis scripts to use EVM, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 077cba7 402/486: Add local docker based tests runner, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1d42d69 416/486: Speed up line indentation inside strings (#313), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 4a7a860 480/486: Properly markup two additional section headings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode a789a25 266/486: Fix #168: use while in rust-rewind-irrelevant, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 936a187 276/486: handle indirect buffers and multiple windows in rust-format-buffer,
ELPA Syncer <=
- [nongnu] elpa/rust-mode 09efc45 320/486: Merge pull request #219 from Aankhen/highlight-question-mark, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b10ad41 326/486: Merge pull request #220 from Aankhen/highlight-string-interpolation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d71fe94 307/486: restore points when an error occurs too, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1b3db88 422/486: Add a function wrap and unwrap with the dbg! macro., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8733792 448/486: Drop Emacs-24, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9eb2c63 460/486: Fix README internal link (#389), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 13c4335 462/486: Improve doc-strings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c23453d 463/486: rearrange I: Move options and faces to beginning of file, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 649f492 484/486: Create rust-cargo.el from existing code, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 198c777 386/486: Replaced font-lock-fontify-buffer with font-lock-ensure, ELPA Syncer, 2021/08/07