diff options
| -rw-r--r-- | lisp/so-long.el | 54 | ||||
| -rw-r--r-- | test/lisp/so-long-tests/spelling-tests.el | 69 |
2 files changed, 106 insertions, 17 deletions
diff --git a/lisp/so-long.el b/lisp/so-long.el index b5eb1242156..8d9b0dc0627 100644 --- a/lisp/so-long.el +++ b/lisp/so-long.el | |||
| @@ -325,7 +325,7 @@ | |||
| 325 | 325 | ||
| 326 | ;; * Caveats | 326 | ;; * Caveats |
| 327 | ;; --------- | 327 | ;; --------- |
| 328 | ;; The variables affecting the automated behavior of this library (such as | 328 | ;; The variables affecting the automated behaviour of this library (such as |
| 329 | ;; `so-long-action') can be used as file- or dir-local values in Emacs 26+, but | 329 | ;; `so-long-action') can be used as file- or dir-local values in Emacs 26+, but |
| 330 | ;; not in previous versions of Emacs. This is on account of improvements made | 330 | ;; not in previous versions of Emacs. This is on account of improvements made |
| 331 | ;; to `normal-mode' in 26.1, which altered the execution order with respect to | 331 | ;; to `normal-mode' in 26.1, which altered the execution order with respect to |
| @@ -413,7 +413,7 @@ Has no effect if `global-so-long-mode' is not enabled.") | |||
| 413 | "Non-nil while `set-auto-mode' is executing.") | 413 | "Non-nil while `set-auto-mode' is executing.") |
| 414 | 414 | ||
| 415 | (defvar so-long--hack-local-variables-no-mode nil ; internal use | 415 | (defvar so-long--hack-local-variables-no-mode nil ; internal use |
| 416 | "Non-nil to prevent `hack-local-variables' applying a 'mode' variable.") | 416 | "Non-nil to prevent `hack-local-variables' applying a `mode' variable.") |
| 417 | 417 | ||
| 418 | (defvar-local so-long--inhibited nil ; internal use | 418 | (defvar-local so-long--inhibited nil ; internal use |
| 419 | "When non-nil, prevents the `set-auto-mode' advice from calling `so-long'.") | 419 | "When non-nil, prevents the `set-auto-mode' advice from calling `so-long'.") |
| @@ -654,7 +654,7 @@ an example." | |||
| 654 | ;; `provided-mode-derived-p' was added in 26.1 | 654 | ;; `provided-mode-derived-p' was added in 26.1 |
| 655 | (unless (fboundp 'provided-mode-derived-p) | 655 | (unless (fboundp 'provided-mode-derived-p) |
| 656 | (defun provided-mode-derived-p (mode &rest modes) | 656 | (defun provided-mode-derived-p (mode &rest modes) |
| 657 | "Return non-nil if MODE is derived from one of MODES. | 657 | "Non-nil if MODE is derived from one of MODES. |
| 658 | Uses the `derived-mode-parent' property of the symbol to trace backwards. | 658 | Uses the `derived-mode-parent' property of the symbol to trace backwards. |
| 659 | If you just want to check `major-mode', use `derived-mode-p'." | 659 | If you just want to check `major-mode', use `derived-mode-p'." |
| 660 | (while (and (not (memq mode modes)) | 660 | (while (and (not (memq mode modes)) |
| @@ -707,7 +707,7 @@ was established." | |||
| 707 | "List of buffer-local minor modes to explicitly disable. | 707 | "List of buffer-local minor modes to explicitly disable. |
| 708 | 708 | ||
| 709 | The ones which were originally enabled in the buffer are disabled by calling | 709 | The ones which were originally enabled in the buffer are disabled by calling |
| 710 | them with the numeric argument 0. Unknown modes, and modes which were were not | 710 | them with the numeric argument 0. Unknown modes, and modes which were not |
| 711 | enabled, are ignored. | 711 | enabled, are ignored. |
| 712 | 712 | ||
| 713 | This happens after any globalized minor modes have acted, so that buffer-local | 713 | This happens after any globalized minor modes have acted, so that buffer-local |
| @@ -742,8 +742,8 @@ If `so-long-revert' is subsequently invoked, then the variables are restored | |||
| 742 | to their original states. | 742 | to their original states. |
| 743 | 743 | ||
| 744 | The combination of `line-move-visual' (enabled) and `truncate-lines' (disabled) | 744 | The combination of `line-move-visual' (enabled) and `truncate-lines' (disabled) |
| 745 | is important for avoiding performance hits when moving vertically between | 745 | is important for maximising responsiveness when moving vertically within an |
| 746 | excessively long lines, as otherwise the full length of the line may need to be | 746 | extremely long line, as otherwise the full length of the line may need to be |
| 747 | scanned to find the next position." | 747 | scanned to find the next position." |
| 748 | :type '(alist :key-type (variable :tag "Variable") | 748 | :type '(alist :key-type (variable :tag "Variable") |
| 749 | :value-type (sexp :tag "Value")) | 749 | :value-type (sexp :tag "Value")) |
| @@ -1174,11 +1174,11 @@ enabled, and `so-long-predicate' has detected that the file contains long lines. | |||
| 1174 | Many Emacs modes struggle with buffers which contain excessively long lines, | 1174 | Many Emacs modes struggle with buffers which contain excessively long lines, |
| 1175 | and may consequently cause unacceptable performance issues. | 1175 | and may consequently cause unacceptable performance issues. |
| 1176 | 1176 | ||
| 1177 | This is commonly on account of \"minified\" code (i.e., code compacted | 1177 | This is commonly on account of \"minified\" code (i.e. code that has been |
| 1178 | into the smallest file size possible, which often entails removing newlines | 1178 | compacted into the smallest file size possible, which often entails removing |
| 1179 | should they not be strictly necessary). These kinds of files are typically | 1179 | newlines should they not be strictly necessary). These kinds of files are |
| 1180 | not intended to be edited, so not providing the usual editing mode in these | 1180 | typically not intended to be edited, so not providing the usual editing mode |
| 1181 | cases will rarely be an issue. | 1181 | in these cases will rarely be an issue. |
| 1182 | 1182 | ||
| 1183 | This major mode disables any active minor modes listed in `so-long-minor-modes' | 1183 | This major mode disables any active minor modes listed in `so-long-minor-modes' |
| 1184 | for the current buffer, and buffer-local values are assigned to variables in | 1184 | for the current buffer, and buffer-local values are assigned to variables in |
| @@ -1189,7 +1189,7 @@ values), despite potential performance issues, type \\[so-long-revert]. | |||
| 1189 | 1189 | ||
| 1190 | Use \\[so-long-commentary] for more information. | 1190 | Use \\[so-long-commentary] for more information. |
| 1191 | 1191 | ||
| 1192 | Use \\[so-long-customize] to configure the behavior." | 1192 | Use \\[so-long-customize] to configure the behaviour." |
| 1193 | ;; Housekeeping. `so-long-mode' might be invoked directly rather than via | 1193 | ;; Housekeeping. `so-long-mode' might be invoked directly rather than via |
| 1194 | ;; `so-long', so replicate the necessary behaviours. We could use this same | 1194 | ;; `so-long', so replicate the necessary behaviours. We could use this same |
| 1195 | ;; test in `so-long-after-change-major-mode' to run `so-long-hook', but that's | 1195 | ;; test in `so-long-after-change-major-mode' to run `so-long-hook', but that's |
| @@ -1344,7 +1344,7 @@ This is the `so-long-revert-function' for `so-long-mode'." | |||
| 1344 | 1344 | ||
| 1345 | A buffer-local \"downgrade\" from `so-long-mode' to `so-long-minor-mode'. | 1345 | A buffer-local \"downgrade\" from `so-long-mode' to `so-long-minor-mode'. |
| 1346 | 1346 | ||
| 1347 | When `so-long-function' is set to `so-long-mode', then we change it to to | 1347 | When `so-long-function' is set to `so-long-mode', then we change it to |
| 1348 | `turn-on-so-long-minor-mode' instead -- retaining the file-local major | 1348 | `turn-on-so-long-minor-mode' instead -- retaining the file-local major |
| 1349 | mode, but still doing everything else that `so-long-mode' would have done. | 1349 | mode, but still doing everything else that `so-long-mode' would have done. |
| 1350 | `so-long-revert-function' is likewise updated. | 1350 | `so-long-revert-function' is likewise updated. |
| @@ -1379,7 +1379,7 @@ and cannot be conveniently intercepted, so we are forced to replicate it here. | |||
| 1379 | 1379 | ||
| 1380 | This special-case code will ultimately be removed from Emacs, as it exists to | 1380 | This special-case code will ultimately be removed from Emacs, as it exists to |
| 1381 | deal with a deprecated feature; but until then we need to replicate it in order | 1381 | deal with a deprecated feature; but until then we need to replicate it in order |
| 1382 | to inhibit our own behavior in the presence of a header comment `mode' | 1382 | to inhibit our own behaviour in the presence of a header comment `mode' |
| 1383 | declaration. | 1383 | declaration. |
| 1384 | 1384 | ||
| 1385 | If a file-local mode is detected in the header comment, then we call the | 1385 | If a file-local mode is detected in the header comment, then we call the |
| @@ -1626,9 +1626,9 @@ Equivalent to calling (global-so-long-mode 0)" | |||
| 1626 | Many Emacs modes struggle with buffers which contain excessively long lines, | 1626 | Many Emacs modes struggle with buffers which contain excessively long lines, |
| 1627 | and may consequently cause unacceptable performance issues. | 1627 | and may consequently cause unacceptable performance issues. |
| 1628 | 1628 | ||
| 1629 | This is commonly on account of \"minified\" code (i.e., code compacted into the | 1629 | This is commonly on account of \"minified\" code (i.e. code that has been |
| 1630 | smallest file size possible, which often entails removing newlines should they | 1630 | compacted into the smallest file size possible, which often entails removing |
| 1631 | not be strictly necessary). | 1631 | newlines should they not be strictly necessary). |
| 1632 | 1632 | ||
| 1633 | When such files are detected by `so-long-predicate', we invoke the selected | 1633 | When such files are detected by `so-long-predicate', we invoke the selected |
| 1634 | `so-long-action' to mitigate potential performance problems in the buffer. | 1634 | `so-long-action' to mitigate potential performance problems in the buffer. |
| @@ -1695,14 +1695,34 @@ or call the function `global-so-long-mode'.") | |||
| 1695 | (global-so-long-mode 0) | 1695 | (global-so-long-mode 0) |
| 1696 | nil) | 1696 | nil) |
| 1697 | 1697 | ||
| 1698 | |||
| 1698 | (provide 'so-long) | 1699 | (provide 'so-long) |
| 1699 | 1700 | ||
| 1700 | ;; Local Variables: | 1701 | ;; Local Variables: |
| 1701 | ;; emacs-lisp-docstring-fill-column: 80 | 1702 | ;; emacs-lisp-docstring-fill-column: 80 |
| 1702 | ;; fill-column: 80 | 1703 | ;; fill-column: 80 |
| 1703 | ;; indent-tabs-mode: nil | 1704 | ;; indent-tabs-mode: nil |
| 1705 | ;; ispell-check-comments: exclusive | ||
| 1706 | ;; ispell-local-dictionary: "british" | ||
| 1704 | ;; End: | 1707 | ;; End: |
| 1705 | 1708 | ||
| 1709 | ;; This library is extensively documented in British English, contrary to the | ||
| 1710 | ;; preference for American English in Emacs. I hope the benefits of the library | ||
| 1711 | ;; will outweigh any discontent you may experience regarding the spelling (or | ||
| 1712 | ;; that you find the spelling to be an agreeable bonus). Certain standard Emacs | ||
| 1713 | ;; terminology, and text quoted from elsewhere in Emacs, retains its original | ||
| 1714 | ;; spelling. The following LocalWords should result in no misspellings from | ||
| 1715 | ;; M-x ispell-buffer (using aspell). | ||
| 1716 | |||
| 1717 | ; LocalWords: LocalWords british ispell aspell hunspell emacs elisp el init dir | ||
| 1718 | ; LocalWords: customize customized customizing Customization globalized amongst | ||
| 1719 | ; LocalWords: initialized profiler boolean minified pre redisplay config keymap | ||
| 1720 | ; LocalWords: noerror selectable mapc sgml nxml hl flydiff defs arg Phil Sainty | ||
| 1721 | ; LocalWords: defadvice nadvice whitespace ie bos eos eobp origmode un Un cXXXr | ||
| 1722 | ; LocalWords: docstring auf wiedersehen longlines alist autoload Refactored Inc | ||
| 1723 | ; LocalWords: MERCHANTABILITY RET REGEXP VAR ELPA WS mitigations EmacsWiki eval | ||
| 1724 | ; LocalWords: setq rx filename filenames | ||
| 1725 | |||
| 1706 | ;; So long, farewell, auf wiedersehen, goodbye | 1726 | ;; So long, farewell, auf wiedersehen, goodbye |
| 1707 | ;; You have to go, this code is minified | 1727 | ;; You have to go, this code is minified |
| 1708 | ;; Goodbye! | 1728 | ;; Goodbye! |
diff --git a/test/lisp/so-long-tests/spelling-tests.el b/test/lisp/so-long-tests/spelling-tests.el new file mode 100644 index 00000000000..d5bae1ef0ce --- /dev/null +++ b/test/lisp/so-long-tests/spelling-tests.el | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | ;;; spelling-tests.el --- Test suite for so-long.el -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2019 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Phil Sainty <psainty@orcon.net.nz> | ||
| 6 | ;; Keywords: convenience | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Code: | ||
| 24 | |||
| 25 | (require 'ert) | ||
| 26 | (require 'ispell) | ||
| 27 | (require 'cl-lib) | ||
| 28 | |||
| 29 | ;; This test is tagged as :unstable on the basis that there may be | ||
| 30 | ;; inconsistencies between spell-checking facilities on different | ||
| 31 | ;; systems, which may cause the test to be unreliable in practice. | ||
| 32 | ;; As such the Emacs test Makefile will skip it by default, but you | ||
| 33 | ;; can run it manually with: | ||
| 34 | ;; | ||
| 35 | ;; make lisp/so-long-tests/spelling-tests SELECTOR=t | ||
| 36 | |||
| 37 | ;; Only define the test if spell-checking is possible. | ||
| 38 | (when (and ispell-program-name | ||
| 39 | (executable-find ispell-program-name) | ||
| 40 | (condition-case () | ||
| 41 | (progn (ispell-check-version) t) | ||
| 42 | (error nil)) | ||
| 43 | (member "british" (ispell-valid-dictionary-list))) | ||
| 44 | (ert-deftest so-long-spelling () | ||
| 45 | "Check the spelling in the source code." | ||
| 46 | :tags '(:unstable) ;; It works for me, but I'm not sure about others. | ||
| 47 | ;; There could be different "british" dictionaries yielding different | ||
| 48 | ;; results, for instance. | ||
| 49 | ;; | ||
| 50 | ;; The Emacs test Makefile's use of HOME=/nonexistent triggers an error | ||
| 51 | ;; when starting the inferior ispell process, so we set HOME to a valid | ||
| 52 | ;; (but empty) temporary directory for this test. | ||
| 53 | (let* ((tmpdir (make-temp-file "so-long." :dir ".ispell")) | ||
| 54 | (process-environment (cons (format "HOME=%s" tmpdir) | ||
| 55 | process-environment)) | ||
| 56 | (find-spelling-mistake | ||
| 57 | (unwind-protect | ||
| 58 | (cl-letf (((symbol-function 'ispell-command-loop) | ||
| 59 | (lambda (_miss _guess word _start _end) | ||
| 60 | (message "Unrecognised word: %s." word) | ||
| 61 | (throw 'mistake t)))) | ||
| 62 | (catch 'mistake | ||
| 63 | (find-library "so-long") | ||
| 64 | (ispell-buffer) | ||
| 65 | nil)) | ||
| 66 | (delete-directory tmpdir)))) | ||
| 67 | (should (not find-spelling-mistake))))) | ||
| 68 | |||
| 69 | ;;; spelling-tests.el ends here | ||