all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nick Helm <nick@tenpoint.co.nz>
To: <26892@debbugs.gnu.org>
Subject: bug#26892: 25.2; whitespace-mode does not turn off correctly
Date: Mon, 15 May 2017 12:26:14 +1200	[thread overview]
Message-ID: <m2a86f2cex.fsf@tenpoint.co.nz> (raw)
In-Reply-To: <837f1ma96f.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 394 bytes --]


> Did you try running whitespace-tests with this change, and if so, did
> they pass?

Yes, all tests pass.

> If the tests pass, would you mind to please add a new test for this
> bug?

I've written a new test and confirmed it catches this problem. I also
tweaked the original patch to handle another instance of the same bug.

Patches for whitespace.el and whitespace-tests.el are attached.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: whitespace-tests.patch --]
[-- Type: text/x-patch, Size: 1574 bytes --]

--- whitespace-tests-a.el	2017-05-12 23:11:38.000000000 +1200
+++ whitespace-tests-b.el	2017-05-15 01:55:43.000000000 +1200
@@ -47,6 +47,31 @@
     (should (equal (whitespace-tests--cleanup-string "a  \n\t \n\n")
                    "a  \n"))))
 
+(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-mode 1)
+                                buffer-display-table)))
+      ;test the display table restores correctly
+      (should (equal nil
+                     (progn (whitespace-mode -1)
+                            buffer-display-table)))
+      ;test the stored display table is preserved
+      (should (equal nil
+                     (progn (whitespace-mode 1)
+                            (whitespace-mode 1)
+                            (whitespace-mode -1)
+                            buffer-display-table))))))
+
 (provide 'whitespace-tests)
 
 ;;; whitespace-tests.el ends here

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: whitespace.patch --]
[-- Type: text/x-patch, Size: 704 bytes --]

--- whitespace-a.el	2017-05-14 14:12:59.000000000 +1200
+++ whitespace-b.el	2017-05-15 01:11:30.000000000 +1200
@@ -2496,9 +2496,10 @@
     (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

  reply	other threads:[~2017-05-15  0:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-11 23:34 bug#26892: 25.2; whitespace-mode does not turn off correctly Nick Helm
2017-05-12  6:19 ` Eli Zaretskii
2017-05-15  0:26   ` Nick Helm [this message]
2017-05-19 12:27     ` Eli Zaretskii
2017-05-21 23:11       ` Nick Helm
2017-05-22  4:10         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2a86f2cex.fsf@tenpoint.co.nz \
    --to=nick@tenpoint.co.nz \
    --cc=26892@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.