[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/spell-fu db0eef27ab 33/86: Add: spell-fu-goto-next-error,
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/spell-fu db0eef27ab 33/86: Add: spell-fu-goto-next-error, spell-fu-goto-previous-error |
Date: |
Thu, 7 Jul 2022 12:03:41 -0400 (EDT) |
branch: elpa/spell-fu
commit db0eef27ab0dcbcc2378af7c1f959850c9a19910
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Add: spell-fu-goto-next-error, spell-fu-goto-previous-error
Useful for jumping between errors.
---
readme.rst | 17 +++++++++++++++-
spell-fu.el | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 77 insertions(+), 6 deletions(-)
diff --git a/readme.rst b/readme.rst
index bc842cac1c..cc429f8284 100644
--- a/readme.rst
+++ b/readme.rst
@@ -145,6 +145,22 @@ however they will be used when set:
When generating the word-list, this file is included when present.
+Commands
+--------
+
+While this package is intended to be used with minimal interaction,
+there are some commands provided which may come in handy.
+
+``spell-fu-goto-next-error``
+ Moves the point to the next error.
+
+``spell-fu-goto-previous-error``
+ Moves the point to the previous error.
+
+``spell-fu-buffer``
+ Checks spelling for the entire buffer, reporting the number of misspelled
words found.
+
+
Other Packages
==============
@@ -167,7 +183,6 @@ TODO
- Support alternates to ``aspell`` for generating word lists.
- Support a custom command for generating a word list.
-- Support going to next/previous misspelled word.
- Support affix expansion when calling aspell (some non English dictionaries
use this).
- Support refreshing the word list at run-time when ispell updates the
personal dictionary
*(currently updates require re-enabling the mode).*
diff --git a/spell-fu.el b/spell-fu.el
index a3eec4b8aa..e6b51d76d4 100644
--- a/spell-fu.el
+++ b/spell-fu.el
@@ -97,7 +97,6 @@ Set to 0.0 to highlight immediately (as part of syntax
highlighting)."
(defvar-local spell-fu-faces-exclude nil
"List of faces to check or nil to exclude none (used by
`spell-fu-check-range').")
-
(defvar-local spell-fu-check-range 'spell-fu-check-range-default
"Function that takes a beginning and end points to check for the current
buffer.
@@ -116,7 +115,6 @@ Notes:
;; ---------------------------------------------------------------------------
;; Internal Variables
-
;; Use to ensure the cache is not from a previous release.
;; Only ever increase.
(defconst spell-fu--cache-version "0.1")
@@ -361,7 +359,6 @@ save some time by not spending time reading it back."
(message "failed, %s" (error-message-string err))
nil)))))
-
(defun spell-fu--cache-words-load-impl (cache-file)
"Return the Lisp content from reading CACHE-FILE.
@@ -417,7 +414,6 @@ On failure of any kind, return nil, the caller will need to
regenerate the cache
(spell-fu--word-list-ensure words-file dict)
-
;; Use previously loaded dictionary from language 'dict' where possible.
(setq spell-fu--cache-table (assoc-default dict
spell-fu--cache-table-alist))
@@ -496,7 +492,6 @@ Argument FACES-EXCLUDE faces to check POS excludes or
ignored when nil."
(setq result t)))
result))
-
(defun spell-fu--check-range-with-faces (point-start point-end)
"Check spelling for POINT-START & POINT-END, checking text matching face
rules."
(spell-fu--remove-overlays point-start point-end)
@@ -702,6 +697,67 @@ when checking the entire buffer for example."
(interactive)
(spell-fu-region nil nil t))
+(defun spell-fu--goto-next-or-previous-error (dir)
+ "Jump to the next or previous error using DIR, return t when found,
otherwise nil."
+ (let
+ ( ;; Track the closest point in a given line.
+ (point-found-delta most-positive-fixnum)
+ (point-init (point))
+ (point-prev nil)
+ (point-found nil))
+ (save-excursion
+ (while (and (null point-found) (not (equal (point) point-prev)))
+ (let
+ (
+ (point-start (line-beginning-position))
+ (point-end (line-end-position)))
+
+ (jit-lock-fontify-now point-start point-end)
+
+ ;; Ensure idle timer is handled immediately.
+ (cond
+ ((<= spell-fu-idle-delay 0.0)
+ nil)
+ (t
+ (spell-fu--idle-handle-pending-ranges-impl point-start
point-end)))
+
+ (dolist (item-ov (overlays-in point-start point-end))
+ (when (overlay-get item-ov 'spell-fu-mode)
+ (let
+ (
+ (item-start (overlay-start item-ov))
+ (item-end (overlay-end item-ov)))
+ (when
+ (if (< dir 0)
+ (< item-end point-init)
+ (> item-start point-init))
+ (let ((test-delta (abs (- point-init item-start))))
+ (when (< test-delta point-found-delta)
+ (setq point-found item-start)
+ (setq point-found-delta test-delta))))))))
+ (setq point-prev (point))
+ (forward-line dir)))
+
+ (if point-found
+ (progn
+ (goto-char point-found)
+ t)
+ (message
+ "Spell-fu: no %s spelling error found"
+ (if (< dir 0)
+ "previous"
+ "next"))
+ nil)))
+
+(defun spell-fu-goto-next-error ()
+ "Jump to the next error, return t when found, otherwise nil."
+ (interactive)
+ (spell-fu--goto-next-or-previous-error 1))
+
+(defun spell-fu-goto-previous-error ()
+ "Jump to the previous error, return t when found, otherwise nil."
+ (interactive)
+ (spell-fu--goto-next-or-previous-error -1))
;; ---------------------------------------------------------------------------
;; Define Minor Mode
- [nongnu] elpa/spell-fu 4fc84a9028 69/86: Fix spell-fu-directory's documentation, (continued)
- [nongnu] elpa/spell-fu 4fc84a9028 69/86: Fix spell-fu-directory's documentation, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 53bd2b24c6 81/86: Cleanup: add spell-fu--canonicalize-word utility function, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu a5a06e150a 02/86: Fix error comparing times of cache to word-list, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu bd00417a0e 09/86: Improve status messages when generating word-list & cache, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu afeb1fd46f 10/86: readme: add some TODO's, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu b7e5cf3d73 11/86: Fix missing checks that ispell variables are bound before use, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 30be3683b2 12/86: readme: update settings docs, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 18724c2e53 14/86: Avoid potentially accessing the same files time multiple times, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 8e8711f1fa 22/86: Add TODO's to the readme, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 88d803e994 26/86: Cleanup: use updated auto-formatting results, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu db0eef27ab 33/86: Add: spell-fu-goto-next-error, spell-fu-goto-previous-error,
ELPA Syncer <=
- [nongnu] elpa/spell-fu a7db587471 36/86: Remove redundant escaping, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu c58be13845 39/86: Fix #3 default word regex now excludes trailing apostrophes, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 98424adbea 42/86: adds helper routine to get lang from dict, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 143233734a 46/86: Allow global-spell-fu to be ignored per mode or using a function, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 103d3a19ce 49/86: Fix checking words that spanned different faces, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 1c0424b4c9 55/86: Cleanup: minor tweak to docstring, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu fd27978614 57/86: Update readme.rst, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu a7879fe9e7 59/86: Cleanup: over-wide docstrings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu a2a0e3b786 60/86: Cleanup: remove redundant group properties, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 570ccd84ed 64/86: Fix spell-fu-goto-{next/prev}-error silently failing, ELPA Syncer, 2022/07/07