[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/spell-fu 143233734a 46/86: Allow global-spell-fu to be ign
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/spell-fu 143233734a 46/86: Allow global-spell-fu to be ignored per mode or using a function |
Date: |
Thu, 7 Jul 2022 12:03:42 -0400 (EDT) |
branch: elpa/spell-fu
commit 143233734a695f46078198e10e2e4c4687a82c0f
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Allow global-spell-fu to be ignored per mode or using a function
Resolves #2
---
changelog.rst | 5 +++++
readme.rst | 18 ++++++++++++++++++
spell-fu.el | 25 ++++++++++++++++++++++---
3 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/changelog.rst b/changelog.rst
index 08f18f39b7..3b49e7244d 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -3,6 +3,11 @@
Change Log
##########
+- In development.
+
+ - Support conditionally disabling ``global-spell-fu-mode`` via
+ ``global-spell-fu-ignore-buffer`` & ``global-spell-fu-ignore-modes``.
+
- Version 0.3 (2021-03-28)
- Support affix expansion when calling ``aspell`` (some non English
dictionaries use this).
diff --git a/readme.rst b/readme.rst
index 931f407ff0..1d789e3cd9 100644
--- a/readme.rst
+++ b/readme.rst
@@ -69,6 +69,9 @@ Global Settings
``spell-fu-incorrect-face`` (red, underline)
The font to use for the spell checking overlay.
+``global-spell-fu-ignore-modes`` nil
+ A list of modes that won't enable spell-checking from
``global-spell-fu-mode``.
+
Buffer Local Settings
^^^^^^^^^^^^^^^^^^^^^
@@ -90,6 +93,21 @@ You may wish to set these values differently based on the
current major-mode.
``spell-fu-faces-exclude``
When not ``nil``, text with faces in this list will be excluded.
+``global-spell-fu-ignore-buffer``
+ When not ``nil``, the buffer won't enable spell-checking from
``global-spell-fu-mode``.
+
+ This may also be a function that takes a single buffer argument,
+ where returning ``nil`` will enable spell-checking, anything else will not.
+
+ This example shows spell-fu being disabled for ORG mode and for read-only
buffers.
+
+ .. code-block:: elisp
+
+ (setq spell-fu-ignore-modes (list 'org-mode))
+ (setq global-spell-fu-ignore-buffer (lambda (buf) (buffer-local-value
'buffer-read-only buf)))
+
+ (global-spell-fu-mode)
+
Advanced Buffer Local Settings
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/spell-fu.el b/spell-fu.el
index e52da2a361..35ff139c31 100644
--- a/spell-fu.el
+++ b/spell-fu.el
@@ -80,6 +80,18 @@ Set to 0.0 to highlight immediately (as part of syntax
highlighting)."
:group 'spell-fu
:type 'float)
+(defcustom spell-fu-ignore-modes nil
+ "List of major-modes to exclude when `spell-fu' has been enabled globally."
+ :type '(repeat symbol)
+ :group 'spell-fu)
+
+(defvar-local global-spell-fu-ignore-buffer nil
+ "When non-nil, Global `spell-fu' Mode will not be enabled for this buffer.
+This variable can also be a predicate function, in which case
+it'll be called with one parameter (the buffer in question), and
+it should return non-nil to make Global `spell-fu' Mode not
+check this buffer.")
+
(defface spell-fu-incorrect-face
'
((((supports :underline (:style wave))) :underline (:style wave :color
"red"))
@@ -1063,13 +1075,20 @@ Return t when the word is removed."
(t
(spell-fu-mode-disable))))
-(defun spell-fu-mode-turn-on ()
+(defun spell-fu-mode--turn-on ()
"Enable the option `spell-fu-mode' where possible."
- (when (and (not (minibufferp)) (not spell-fu-mode))
+ (when
+ (and
+ (not spell-fu-mode) (not (minibufferp)) (not (memq major-mode
spell-fu-ignore-modes))
+ (or
+ (null global-spell-fu-ignore-buffer)
+ (if (functionp global-spell-fu-ignore-buffer)
+ (not (funcall global-spell-fu-ignore-buffer (current-buffer)))
+ nil)))
(spell-fu-mode 1)))
;;;###autoload
-(define-globalized-minor-mode global-spell-fu-mode spell-fu-mode
spell-fu-mode-turn-on)
+(define-globalized-minor-mode global-spell-fu-mode spell-fu-mode
spell-fu-mode--turn-on)
(provide 'spell-fu)
;;; spell-fu.el ends here
- [nongnu] elpa/spell-fu afeb1fd46f 10/86: readme: add some TODO's, (continued)
- [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, 2022/07/07
- [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 <=
- [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
- [nongnu] elpa/spell-fu b2da2874f3 67/86: Cleanup: use shorter variable names, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 00af362af3 71/86: Add multiple dictionary support, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 2ba65de269 74/86: Cleanup: include all arguments in doc-strings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 4782667d7b 76/86: Fail gracefully with a message when aspell can't be found, ELPA Syncer, 2022/07/07