[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 00451c6fc6: Make ispell-region/buffer push the mark of the final
From: |
Lars Ingebrigtsen |
Subject: |
master 00451c6fc6: Make ispell-region/buffer push the mark of the final word |
Date: |
Tue, 10 May 2022 10:25:08 -0400 (EDT) |
branch: master
commit 00451c6fc62d96c866fe87ae153e27d687c50d1a
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Make ispell-region/buffer push the mark of the final word
* lisp/textmodes/ispell.el (ispell-region): Push the mark of the
final location.
(ispell-process-line): Change the return value to include the
position of the final word.
---
etc/NEWS | 8 ++++++++
lisp/textmodes/ispell.el | 33 ++++++++++++++++++++++++---------
2 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 2557a092a8..1c89493a1f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -780,6 +780,14 @@ so automatically.
* Changes in Specialized Modes and Packages in Emacs 29.1
+** ispell
+
+---
+*** 'ispell-region' and 'ispell-buffer' now push the mark.
+The location of the last word the user was queried about is pushed to
+the mark ring, so that the user can skip back to the location with
+'C-x C-x'.
+
** dabbrev
---
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index b58514972a..93008ca7fb 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -3052,6 +3052,8 @@ when needed."
;;;###autoload
(defun ispell-region (reg-start reg-end &optional recheckp shift)
"Interactively check a region for spelling errors.
+Mark is left at the final word that the user was queried about.
+
Return nil if spell session was terminated, otherwise returns shift offset
amount for last line processed."
(interactive "r") ; Don't flag errors on read-only bufs.
@@ -3063,7 +3065,8 @@ amount for last line processed."
(region-type (if (and (= reg-start (point-min)) (= reg-end (point-max)))
(buffer-name) "region"))
(program-basename (file-name-nondirectory ispell-program-name))
- (dictionary (or ispell-current-dictionary "default")))
+ (dictionary (or ispell-current-dictionary "default"))
+ max-word)
(unwind-protect
(save-excursion
(message "Spell-checking %s using %s with %s dictionary..."
@@ -3159,10 +3162,14 @@ ispell-region: Search for first region to skip after
(ispell-begin-skip-region-r
;; Reset `in-comment' (and indirectly
`add-comment') for new line
in-comment nil))
(setq ispell-end (point)) ; "end" tracks region retrieved.
- (if string ; there is something to spell check!
- ;; (special start end)
- (setq shift (ispell-process-line string
- (and recheckp shift))))
+ ;; There is something to spell check!
+ (when string
+ ;; (special start end)
+ (let ((res (ispell-process-line string
+ (and recheckp shift))))
+ (setq shift (car res))
+ (when (cdr res)
+ (setq max-word (cdr res)))))
(goto-char ispell-end)))))
(if ispell-quit
nil
@@ -3173,6 +3180,9 @@ ispell-region: Search for first region to skip after
(ispell-begin-skip-region-r
(kill-buffer ispell-choices-buffer))
(set-marker skip-region-start nil)
(set-marker rstart nil)
+ ;; Allow the user to pop back to the last position.
+ (when max-word
+ (push-mark max-word t))
(if ispell-quit
(progn
;; preserve or clear the region for ispell-continue.
@@ -3407,9 +3417,12 @@ Returns a string with the line data."
This will modify the buffer for spelling errors.
Requires variables ISPELL-START and ISPELL-END to be defined in its
dynamic scope.
-Returns the sum SHIFT due to changes in word replacements."
+
+Returns a cons cell where the `car' is sum SHIFT due to changes
+in word replacements, and the `cdr' is the location of the final
+word that was queried about."
;;(declare special ispell-start ispell-end)
- (let (poss accept-list)
+ (let (poss accept-list max-word)
(if (not (numberp shift))
(setq shift 0))
;; send string to spell process and get input.
@@ -3463,6 +3476,7 @@ Returns the sum SHIFT due to changes in word
replacements."
(error (concat "Ispell misalignment: word "
"`%s' point %d; probably incompatible
versions")
ispell-pipe-word actual-point)))
+ (setq max-word (marker-position word-start))
;; ispell-cmd-loop can go recursive & change buffer
(if ispell-keep-choices-win
(setq replace (ispell-command-loop
@@ -3559,7 +3573,7 @@ Returns the sum SHIFT due to changes in word
replacements."
(set-marker line-end nil)))
;; Finished with misspelling!
(setq ispell-filter (cdr ispell-filter)))
- shift))
+ (cons shift max-word)))
;;;###autoload
@@ -3600,7 +3614,8 @@ to limit the check."
;;;###autoload
(defun ispell-buffer ()
- "Check the current buffer for spelling errors interactively."
+ "Check the current buffer for spelling errors interactively.
+Mark is left at the final word that the user was queried about."
(interactive)
(ispell-region (point-min) (point-max)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 00451c6fc6: Make ispell-region/buffer push the mark of the final word,
Lars Ingebrigtsen <=