Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement gusbrs's Code for Contribution to GNU ELPA #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 15 additions & 23 deletions flyspell-correct.el
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,14 @@ until all errors in buffer have been addressed."
;; idiomatically done using the opoint arg of
;; `flyspell-correct-word-before-point'.
(interactive "d")
;; push mark when starting
(when (or (not (mark t))
(/= (mark t) (point)))
(push-mark (point) t))
(let ((original-pos (point))
(target-pos (point))
(hard-move-point)
(mark-opos))
(original-mark-ring mark-ring)
(preserve-mark))
(when (or (not (mark t))
(/= (mark t) (point)))
(push-mark (point) t))
(unwind-protect
(save-excursion
(let ((incorrect-word-pos))
Expand Down Expand Up @@ -406,9 +406,9 @@ until all errors in buffer have been addressed."
(when res
;; stop at misspelled word
(when (eq (car-safe res) 'stop)
(setq target-pos incorrect-word-pos
hard-move-point t
mark-opos t))
(setq target-pos incorrect-word-pos)
(setq hard-move-point t)
(setq preserve-mark t))

;; break from rapid mode
(when (or
Expand All @@ -419,23 +419,15 @@ until all errors in buffer have been addressed."
;; explicit rapid mode disablers
(eq (car-safe res) 'break)
(eq (car-safe res) 'stop))
(setq overlay nil))

(when (and
;; don't push mark if there is no change
(not (memq (car-safe res) '(stop break skip)))
(/= (mark t) (point)))
;; `flyspell-correct-at-point' may move point, use
;; original `incorrect-word-pos' instead
(push-mark incorrect-word-pos t)))))))))

(when hard-move-point
(when mark-opos
(push-mark (point) t))
(goto-char target-pos))
(setq overlay nil)))))))))

(if hard-move-point
(goto-char target-pos)
(goto-char (mark t)))
;; We pushed the mark when starting, but if the operation is canceled
;; without any change that mark is redundant and needs to be cleaned-up.
(when (= (mark t) (point)) (pop-mark)))))
(unless preserve-mark
(setq mark-ring original-mark-ring)))))

;;; Overlays

Expand Down