emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/jinx e14ae97422: jinx-correct: Do not restore point pos


From: ELPA Syncer
Subject: [elpa] externals/jinx e14ae97422: jinx-correct: Do not restore point position
Date: Tue, 28 Mar 2023 16:58:53 -0400 (EDT)

branch: externals/jinx
commit e14ae97422f124b0f371bfbea9d37500d2c662b1
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    jinx-correct: Do not restore point position
    
    When spell checking the whole buffer one sometimes wants to make a cursory 
edit
    at the location of the misspelling. Therefore it is a better behavior to not
    restore the point position. Instead push a mark which allows you to go back 
to
    where you came from before spell-checking.
    
    See discussion in #9.
---
 jinx.el | 54 +++++++++++++++++++++++++++---------------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/jinx.el b/jinx.el
index 1e5b0b648c..078429779d 100644
--- a/jinx.el
+++ b/jinx.el
@@ -641,33 +641,33 @@ With prefix argument GLOBAL non-nil change the languages 
globally."
 If prefix argument ALL non-nil correct all misspellings."
   (interactive "*P")
   (unless jinx-mode (jinx-mode 1))
-  (unwind-protect
-      (save-window-excursion
-        (save-excursion
-          (cl-letf (((symbol-function #'jinx--timer-handler) #'ignore)) ;; 
Inhibit
-            (if all
-                (let* ((overlays (or (jinx--force-overlays (point-min) 
(point-max))
-                                     (user-error "No misspellings in whole 
buffer")))
-                       (nearest (jinx--nearest-overlay overlays))
-                       (count (length overlays))
-                       before after)
-                  (dolist (ov overlays)
-                    (if (or after (eq ov nearest))
-                        (push ov after)
-                      (push ov before)))
-                  (setq overlays (nreverse (nconc before after)))
-                  (cl-loop for ov in overlays for idx from 1
-                           if (overlay-buffer ov) do ;; Could be already 
deleted
-                           (jinx--correct ov 'recenter
-                                          (format " (%d of %d, RET to skip)"
-                                                  idx count))))
-              (jinx--correct
-               (or
-                (jinx--nearest-overlay
-                 (or (jinx--get-overlays (window-start) (window-end))
-                     (jinx--force-overlays (window-start) (window-end))))
-                (user-error "No misspelling in visible text")))))))
-    (jit-lock-refontify)))
+  (cl-letf (((symbol-function #'jinx--timer-handler) #'ignore) ;; Inhibit
+            (old-point (if all (push-mark) (point-marker))))
+    (unwind-protect
+        (if all
+            (let* ((overlays (or (jinx--force-overlays (point-min) (point-max))
+                                 (user-error "No misspellings in whole 
buffer")))
+                   (nearest (jinx--nearest-overlay overlays))
+                   (count (length overlays))
+                   before after)
+              (dolist (ov overlays)
+                (if (or after (eq ov nearest))
+                    (push ov after)
+                  (push ov before)))
+              (setq overlays (nreverse (nconc before after)))
+              (cl-loop for ov in overlays for idx from 1
+                       if (overlay-buffer ov) do ;; Could be already deleted
+                       (jinx--correct ov 'recenter
+                                      (format " (%d of %d, RET to skip)"
+                                              idx count))))
+          (jinx--correct
+           (or
+            (jinx--nearest-overlay
+             (or (jinx--get-overlays (window-start) (window-end))
+                 (jinx--force-overlays (window-start) (window-end))))
+            (user-error "No misspelling in visible text"))))
+      (unless all (goto-char old-point))
+      (jit-lock-refontify))))
 
 ;;;###autoload
 (define-minor-mode jinx-mode



reply via email to

[Prev in Thread] Current Thread [Next in Thread]