unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#26892: 25.2; whitespace-mode does not turn off correctly
@ 2017-05-11 23:34 Nick Helm
  2017-05-12  6:19 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Helm @ 2017-05-11 23:34 UTC (permalink / raw)
  To: 26892


Emacs -Q
C-u 20 SPC RET RET RET RET   ; type some random whitespace
M-x global-whitespace-mode
M-x whitespace-mode
M-x whitespace-mode

The last command should toggle local whitespace-mode off, but note that the
whitespace display characters are not properly removed from the current
buffer.

I had a look at whitespace.el and I think the problem lies in
`whitespace-display-char-on'. Among other things, this function stores the
buffer display table and replaces it with a temporary display table to show
whitespace chars. The original is restored when the mode is turned off.

However, with global-whitespace-mode active, there is already a temporary
display table in place, which whitespace-mode incorrectly picks up and stores,
clobbering the original display table in the process. When whitespace-mode is
turned off, it restores the temporary display table set by
global-whitespace-mode, which leads to the problem.

Here's a little patch to check if global-whitespace-mode is active before
storing the display table. I've tried this for a few days with no obvious
problems.

--- whitespace-a.el	2017-05-12 00:59:34.000000000 +1200
+++ whitespace-b.el	2017-05-12 01:02:26.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 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





In GNU Emacs 25.2.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911))
 of 2017-04-22 built on builder10-9.porkrind.org
Windowing system distributor 'Apple', version 10.3.1504
Configured using:
 'configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp' --with-modules'

Configured features:
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES

Important settings:
  value of $LANG: en_NZ.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Messages

Minor modes in effect:
  recentf-mode: t
  savehist-mode: t
  ivy-mode: t
  global-eldoc-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  transient-mark-mode: t

Recent messages:
Loading /Users/nick/.emacs.d/config/mc/mc-run-once.list...done
Emacs start-up time: 1.0 seconds
For information about GNU Emacs and the GNU system, type C-h C-a.
Loading /Users/nick/.emacs.d/config/recentf/recentf.history...done
Cleaning up the recentf list...done (0 removed)
user-error: The mark is not set now, so there is no region
s-b is undefined [2 times]

Load-path shadows:
/Users/nick/.emacs.d/lisp/org/ox hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ox
/Users/nick/.emacs.d/lisp/org/ox-texinfo hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ox-texinfo
/Users/nick/.emacs.d/lisp/org/ox-publish hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ox-publish
/Users/nick/.emacs.d/lisp/org/ox-org hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ox-org
/Users/nick/.emacs.d/lisp/org/ox-odt hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ox-odt
/Users/nick/.emacs.d/lisp/org/ox-md hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ox-md
/Users/nick/.emacs.d/lisp/org/ox-man hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ox-man
/Users/nick/.emacs.d/lisp/org/ox-latex hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ox-latex
/Users/nick/.emacs.d/lisp/org/ox-icalendar hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ox-icalendar
/Users/nick/.emacs.d/lisp/org/ox-html hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ox-html
/Users/nick/.emacs.d/lisp/org/ox-beamer hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ox-beamer
/Users/nick/.emacs.d/lisp/org/ox-ascii hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ox-ascii
/Users/nick/.emacs.d/lisp/org/org hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org
/Users/nick/.emacs.d/lisp/org/org-w3m hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-w3m
/Users/nick/.emacs.d/lisp/org/org-version hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-version
/Users/nick/.emacs.d/lisp/org/org-timer hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-timer
/Users/nick/.emacs.d/lisp/org/org-table hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-table
/Users/nick/.emacs.d/lisp/org/org-src hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-src
/Users/nick/.emacs.d/lisp/org/org-rmail hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-rmail
/Users/nick/.emacs.d/lisp/org/org-protocol hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-protocol
/Users/nick/.emacs.d/lisp/org/org-plot hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-plot
/Users/nick/.emacs.d/lisp/org/org-pcomplete hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-pcomplete
/Users/nick/.emacs.d/lisp/org/org-mouse hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-mouse
/Users/nick/.emacs.d/lisp/org/org-mobile hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-mobile
/Users/nick/.emacs.d/lisp/org/org-mhe hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-mhe
/Users/nick/.emacs.d/lisp/org/org-macs hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-macs
/Users/nick/.emacs.d/lisp/org/org-macro hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-macro
/Users/nick/.emacs.d/lisp/org/org-loaddefs hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-loaddefs
/Users/nick/.emacs.d/lisp/org/org-list hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-list
/Users/nick/.emacs.d/lisp/org/org-irc hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-irc
/Users/nick/.emacs.d/lisp/org/org-install hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-install
/Users/nick/.emacs.d/lisp/org/org-inlinetask hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-inlinetask
/Users/nick/.emacs.d/lisp/org/org-info hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-info
/Users/nick/.emacs.d/lisp/org/org-indent hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-indent
/Users/nick/.emacs.d/lisp/org/org-id hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-id
/Users/nick/.emacs.d/lisp/org/org-habit hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-habit
/Users/nick/.emacs.d/lisp/org/org-gnus hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-gnus
/Users/nick/.emacs.d/lisp/org/org-footnote hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-footnote
/Users/nick/.emacs.d/lisp/org/org-feed hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-feed
/Users/nick/.emacs.d/lisp/org/org-faces hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-faces
/Users/nick/.emacs.d/lisp/org/org-eshell hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-eshell
/Users/nick/.emacs.d/lisp/org/org-entities hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-entities
/Users/nick/.emacs.d/lisp/org/org-element hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-element
/Users/nick/.emacs.d/lisp/org/org-docview hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-docview
/Users/nick/.emacs.d/lisp/org/org-datetree hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-datetree
/Users/nick/.emacs.d/lisp/org/org-ctags hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-ctags
/Users/nick/.emacs.d/lisp/org/org-crypt hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-crypt
/Users/nick/.emacs.d/lisp/org/org-compat hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-compat
/Users/nick/.emacs.d/lisp/org/org-colview hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-colview
/Users/nick/.emacs.d/lisp/org/org-clock hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-clock
/Users/nick/.emacs.d/lisp/org/org-capture hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-capture
/Users/nick/.emacs.d/lisp/org/org-bibtex hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-bibtex
/Users/nick/.emacs.d/lisp/org/org-bbdb hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-bbdb
/Users/nick/.emacs.d/lisp/org/org-attach hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-attach
/Users/nick/.emacs.d/lisp/org/org-archive hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-archive
/Users/nick/.emacs.d/lisp/org/org-agenda hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/org-agenda
/Users/nick/.emacs.d/lisp/org/ob hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob
/Users/nick/.emacs.d/lisp/org/ob-tangle hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-tangle
/Users/nick/.emacs.d/lisp/org/ob-table hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-table
/Users/nick/.emacs.d/lisp/org/ob-sqlite hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-sqlite
/Users/nick/.emacs.d/lisp/org/ob-sql hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-sql
/Users/nick/.emacs.d/lisp/org/ob-shen hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-shen
/Users/nick/.emacs.d/lisp/org/ob-screen hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-screen
/Users/nick/.emacs.d/lisp/org/ob-scheme hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-scheme
/Users/nick/.emacs.d/lisp/org/ob-scala hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-scala
/Users/nick/.emacs.d/lisp/org/ob-sass hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-sass
/Users/nick/.emacs.d/lisp/org/ob-ruby hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-ruby
/Users/nick/.emacs.d/lisp/org/ob-ref hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-ref
/Users/nick/.emacs.d/lisp/org/ob-R hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-R
/Users/nick/.emacs.d/lisp/org/ob-python hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-python
/Users/nick/.emacs.d/lisp/org/ob-plantuml hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-plantuml
/Users/nick/.emacs.d/lisp/org/ob-picolisp hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-picolisp
/Users/nick/.emacs.d/lisp/org/ob-perl hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-perl
/Users/nick/.emacs.d/lisp/org/ob-org hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-org
/Users/nick/.emacs.d/lisp/org/ob-octave hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-octave
/Users/nick/.emacs.d/lisp/org/ob-ocaml hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-ocaml
/Users/nick/.emacs.d/lisp/org/ob-mscgen hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-mscgen
/Users/nick/.emacs.d/lisp/org/ob-maxima hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-maxima
/Users/nick/.emacs.d/lisp/org/ob-matlab hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-matlab
/Users/nick/.emacs.d/lisp/org/ob-makefile hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-makefile
/Users/nick/.emacs.d/lisp/org/ob-lob hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-lob
/Users/nick/.emacs.d/lisp/org/ob-lisp hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-lisp
/Users/nick/.emacs.d/lisp/org/ob-lilypond hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-lilypond
/Users/nick/.emacs.d/lisp/org/ob-ledger hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-ledger
/Users/nick/.emacs.d/lisp/org/ob-latex hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-latex
/Users/nick/.emacs.d/lisp/org/ob-keys hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-keys
/Users/nick/.emacs.d/lisp/org/ob-js hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-js
/Users/nick/.emacs.d/lisp/org/ob-java hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-java
/Users/nick/.emacs.d/lisp/org/ob-io hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-io
/Users/nick/.emacs.d/lisp/org/ob-haskell hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-haskell
/Users/nick/.emacs.d/lisp/org/ob-gnuplot hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-gnuplot
/Users/nick/.emacs.d/lisp/org/ob-fortran hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-fortran
/Users/nick/.emacs.d/lisp/org/ob-exp hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-exp
/Users/nick/.emacs.d/lisp/org/ob-eval hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-eval
/Users/nick/.emacs.d/lisp/org/ob-emacs-lisp hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-emacs-lisp
/Users/nick/.emacs.d/lisp/org/ob-dot hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-dot
/Users/nick/.emacs.d/lisp/org/ob-ditaa hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-ditaa
/Users/nick/.emacs.d/lisp/org/ob-css hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-css
/Users/nick/.emacs.d/lisp/org/ob-core hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-core
/Users/nick/.emacs.d/lisp/org/ob-comint hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-comint
/Users/nick/.emacs.d/lisp/org/ob-clojure hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-clojure
/Users/nick/.emacs.d/lisp/org/ob-calc hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-calc
/Users/nick/.emacs.d/lisp/org/ob-C hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-C
/Users/nick/.emacs.d/lisp/org/ob-awk hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-awk
/Users/nick/.emacs.d/lisp/org/ob-asymptote hides /Users/nick/Desktop/Emacs.app/Contents/Resources/lisp/org/ob-asymptote

Features:
(shadow face-remap emacsbug colir color recentf tree-widget wid-edit
time em-term term disp-table ehelp esh-opt esh-ext mu4e desktop frameset
mu4e-speedbar speedbar sb-image ezimage dframe mu4e-main mu4e-context
mu4e-view cal-menu calendar cal-loaddefs epa derived browse-url comint
ansi-color mu4e-headers mu4e-compose mu4e-draft mu4e-actions rfc2368
smtpmail sendmail mu4e-mark mu4e-message html2text mu4e-proc mu4e-utils
doc-view subr-x image-mode mu4e-lists mu4e-vars message format-spec
rfc822 mml mml-sec epg epg-config mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev mail-utils
gmm-utils mailheader hl-line cl mu4e-meta dired-x dired savehist smex
ido seq counsel jka-compr esh-util etags xref project ring swiper ivy
delsel ivy-overlay ffap url-parse auth-source cl-seq eieio byte-opt
bytecomp byte-compile cl-extra cconv eieio-core cl-macs gnus-util
mm-util help-fns help-mode mail-prsvr password-cache url-vars
multiple-cursors mc-hide-unmatched-lines-mode mc-separate-operations
rectangular-region-mode mc-mark-pop mc-mark-more mc-cycle-cursors
mc-edit-lines multiple-cursors-core advice rect nh-posmark nh-resize
nh-macdict markdown-mode thingatpt noutline outline easy-mmode easymenu
iso-transl nh-tax nh-move-lines gv flyspell ispell linum plain-theme
edmacro kmacro cl-loaddefs pcase cl-lib time-date mule-util tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
ns-win ucs-normalize term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote kqueue cocoa ns multi-tty
make-network-process emacs)

Memory information:
((conses 16 291871 101436)
 (symbols 48 29250 0)
 (miscs 40 60 296)
 (strings 32 44032 118873)
 (string-bytes 1 1279925)
 (vectors 16 44379)
 (vector-slots 8 762963 80102)
 (floats 8 452 191)
 (intervals 56 708 164)
 (buffers 976 19))





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#26892: 25.2; whitespace-mode does not turn off correctly
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2017-05-12  6:19 UTC (permalink / raw)
  To: Nick Helm; +Cc: 26892

> From: Nick Helm <nick@tenpoint.co.nz>
> Date: Fri, 12 May 2017 11:34:33 +1200
> 
> Emacs -Q
> C-u 20 SPC RET RET RET RET   ; type some random whitespace
> M-x global-whitespace-mode
> M-x whitespace-mode
> M-x whitespace-mode
> 
> The last command should toggle local whitespace-mode off, but note that the
> whitespace display characters are not properly removed from the current
> buffer.
> 
> I had a look at whitespace.el and I think the problem lies in
> `whitespace-display-char-on'. Among other things, this function stores the
> buffer display table and replaces it with a temporary display table to show
> whitespace chars. The original is restored when the mode is turned off.
> 
> However, with global-whitespace-mode active, there is already a temporary
> display table in place, which whitespace-mode incorrectly picks up and stores,
> clobbering the original display table in the process. When whitespace-mode is
> turned off, it restores the temporary display table set by
> global-whitespace-mode, which leads to the problem.
> 
> Here's a little patch to check if global-whitespace-mode is active before
> storing the display table. I've tried this for a few days with no obvious
> problems.

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

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

Thanks.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#26892: 25.2; whitespace-mode does not turn off correctly
  2017-05-12  6:19 ` Eli Zaretskii
@ 2017-05-15  0:26   ` Nick Helm
  2017-05-19 12:27     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Helm @ 2017-05-15  0:26 UTC (permalink / raw)
  To: 26892

[-- 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#26892: 25.2; whitespace-mode does not turn off correctly
  2017-05-15  0:26   ` Nick Helm
@ 2017-05-19 12:27     ` Eli Zaretskii
  2017-05-21 23:11       ` Nick Helm
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2017-05-19 12:27 UTC (permalink / raw)
  To: Nick Helm; +Cc: 26892-done

> From: Nick Helm <nick@tenpoint.co.nz>
> CC: Eli Zaretskii <eliz@gnu.org>
> Date: Mon, 15 May 2017 12:26:14 +1200
> 
> 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.

Thanks, pushed.

A couple of notes, for the future:

 . The test at first failed for me, and needed some tweaking, because
   whitespace-mode refuses to turn on in batch mode.  I guess you ran
   the tests in interactive mode?  You should run tests in batch.

 . The patch was not applicable without manual editing, because it
   used file names like whitespace-a.el, which don't exist.  Please in
   the future submit patches produced against the correct file names,
   preferably with "git diff" or somesuch.

 . Please include with the patch a ChangeLog-style commit log message
   (see CONTRIBUTE for details).

 . Finally, this contribution exhausts the amount of changes we can
   accept from you without legal paperwork, so I encourage you to
   start the paperwork rolling, for us to be able to accept your
   future contributions.  (I can send you the forms off-list if you
   want.)

Thanks again for working on this.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#26892: 25.2; whitespace-mode does not turn off correctly
  2017-05-19 12:27     ` Eli Zaretskii
@ 2017-05-21 23:11       ` Nick Helm
  2017-05-22  4:10         ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Helm @ 2017-05-21 23:11 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 26892-done


> A couple of notes, for the future:
>
>  . The test at first failed for me, and needed some tweaking, because
>    whitespace-mode refuses to turn on in batch mode.  I guess you ran
>    the tests in interactive mode?  You should run tests in batch.

Sorry, yes, I did. I read about batch testing in the manual, but didn't
click that most tests need to run that way. Of course they do, now that
I think about it. 

>  . The patch was not applicable without manual editing, because it
>    used file names like whitespace-a.el, which don't exist.  Please in
>    the future submit patches produced against the correct file names,
>    preferably with "git diff" or somesuch.
>
>  . Please include with the patch a ChangeLog-style commit log message
>    (see CONTRIBUTE for details).
>
>  . Finally, this contribution exhausts the amount of changes we can
>    accept from you without legal paperwork, so I encourage you to
>    start the paperwork rolling, for us to be able to accept your
>    future contributions.  (I can send you the forms off-list if you
>    want.)

I'd like to keep contributing where I can, so please do send the
paperwork when you have a moment. 

Thank you for the feedback and for fixing up the code. It is very much
appreciated! 





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#26892: 25.2; whitespace-mode does not turn off correctly
  2017-05-21 23:11       ` Nick Helm
@ 2017-05-22  4:10         ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2017-05-22  4:10 UTC (permalink / raw)
  To: Nick Helm; +Cc: 26892

> From: Nick Helm <nick@tenpoint.co.nz>
> CC: <26892-done@debbugs.gnu.org>
> Date: Mon, 22 May 2017 11:11:11 +1200
> >  . Finally, this contribution exhausts the amount of changes we can
> >    accept from you without legal paperwork, so I encourage you to
> >    start the paperwork rolling, for us to be able to accept your
> >    future contributions.  (I can send you the forms off-list if you
> >    want.)
> 
> I'd like to keep contributing where I can, so please do send the
> paperwork when you have a moment. 

Sent off-list.

> Thank you for the feedback and for fixing up the code. It is very much
> appreciated! 

You are very welcome.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-05-22  4:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2017-05-19 12:27     ` Eli Zaretskii
2017-05-21 23:11       ` Nick Helm
2017-05-22  4:10         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).