[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master c1c6f16: Fix turning off whitespace-mode
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] master c1c6f16: Fix turning off whitespace-mode |
Date: |
Fri, 19 May 2017 08:22:26 -0400 (EDT) |
branch: master
commit c1c6f167b2e683db3e2cee7cb29ab2eb745e1713
Author: Nick Helm <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Fix turning off whitespace-mode
* lisp/whitespace.el (whitespace-display-char-on): Correct the way
the original buffer-display-table is saved and restored when
global-whitespace-mode is active. (Bug#26892)
* test/lisp/whitespace-tests.el
(whitespace-tests-whitespace-mode-on): New function.
(whitespace-tests-display-tables): New test.
Copyright-paperwork-exempt: yes
---
lisp/whitespace.el | 7 ++++---
test/lisp/whitespace-tests.el | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 6aca47c..c6d5b16 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -2373,9 +2373,10 @@ Also refontify when necessary."
(let (vecs vec)
;; Remember whether a buffer has a local display table.
(unless whitespace-display-table-was-local
- (setq whitespace-display-table-was-local t
- whitespace-display-table
- (copy-sequence buffer-display-table))
+ (setq whitespace-display-table-was-local t)
+ (unless (or whitespace-mode global-whitespace-mode)
+ (setq whitespace-display-table
+ (copy-sequence buffer-display-table)))
;; Assure `buffer-display-table' is unique
;; when two or more windows are visible.
(setq buffer-display-table
diff --git a/test/lisp/whitespace-tests.el b/test/lisp/whitespace-tests.el
index 99cc3c4..1e45535 100644
--- a/test/lisp/whitespace-tests.el
+++ b/test/lisp/whitespace-tests.el
@@ -47,6 +47,40 @@
(should (equal (whitespace-tests--cleanup-string "a \n\t \n\n")
"a \n"))))
+
+;; We cannot call whitespace-mode because it will do nothing in batch
+;; mode. So we call its innards instead.
+(defun whitespace-tests-whitespace-mode-on ()
+ "Turn whitespace-mode on even in batch mode."
+ (whitespace-turn-on)
+ (whitespace-action-when-on)
+ (setq whitespace-mode t))
+
+(ert-deftest whitespace-tests-display-tables ()
+ "Test whitespace stores and restores the buffer display table - bug26892."
+ (with-temp-buffer
+ (whitespace-mode -1) ; turn off in case global ws mode is active
+ (let ((whitespace-style '(space-mark tab-mark newline-mark))
+ (whitespace-display-mappings '((space-mark 32 [183] [46])
+ (space-mark 160 [164] [95])
+ (newline-mark 10 [36 10])
+ (tab-mark 9 [187 9] [92 9])))
+ (buffer-display-table nil))
+ ;test the display table actually changes
+ (should-not (equal nil
+ (progn (whitespace-tests-whitespace-mode-on)
+ buffer-display-table)))
+ ;test the display table restores correctly
+ (should (equal nil
+ (progn (whitespace-turn-off)
+ buffer-display-table)))
+ ;test the stored display table is preserved
+ (should (equal nil
+ (progn (whitespace-tests-whitespace-mode-on)
+ (whitespace-tests-whitespace-mode-on)
+ (whitespace-turn-off)
+ buffer-display-table))))))
+
(provide 'whitespace-tests)
;;; whitespace-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master c1c6f16: Fix turning off whitespace-mode,
Eli Zaretskii <=