I use flyspell-lazy to improve flyspell performance and it works really well. However, when I open a buffer with a lot of text, I get this error:
Debugger entered--Lisp error: (args-out-of-range #<buffer buffer2> 155 215)
#<subr buffer-substring-no-properties>(215 155)
ad-Advice-buffer-substring-no-properties(#<subr buffer-substring-no-properties> 215 155)
apply(ad-Advice-buffer-substring-no-properties #<subr buffer-substring-no-properties> (215 155))
buffer-substring-no-properties(215 155)
flyspell-lazy-check-pending()
apply(flyspell-lazy-check-pending nil)
timer-event-handler([t 0 3 0 t flyspell-lazy-check-pending nil idle 0])
Here's another version of the error:
Debugger entered--Lisp error: (args-out-of-range #<buffer 0-why-I-wrote-this-book.txt> 90378 90651)
buffer-substring-no-properties(90651 90378)
flyspell-lazy-check-pending()
apply(flyspell-lazy-check-pending nil)
timer-event-handler([t 0 3 0 t flyspell-lazy-check-pending nil idle 0])
How can I resolve this error?
As requested, here are my flyspell settings:
(use-package flyspell
:config
'(flyspell-abbrev-p t)
'(flyspell-use-global-abbrev-table-p t)
'(global-flyspell-mode t)
:bind
(:map flyspell-mode-map
("C-." . nil)
)
)
;; flyspell skip source blocks
;; NO spell check for embedded snippets
(defadvice org-mode-flyspell-verify (after org-mode-flyspell-verify-hack activate)
(let ((rlt ad-return-value)
(begin-regexp "^[ \t]*#\\+begin_\\(src\\|html\\|latex\\)")
(end-regexp "^[ \t]*#\\+end_\\(src\\|html\\|latex\\)")
old-flag
b e)
(when ad-return-value
(save-excursion
(setq old-flag case-fold-search)
(setq case-fold-search t)
(setq b (re-search-backward begin-regexp nil t))
(if b (setq e (re-search-forward end-regexp nil t)))
(setq case-fold-search old-flag))
(if (and b e (< (point) e)) (setq rlt nil)))
(setq ad-return-value rlt)))
(add-hook 'org-mode-hook (lambda () (flyspell-lazy-mode 1)))