unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* whitespace.el does not seem to delete its overlays
@ 2005-04-08 13:43 Stephan Stahl
  2005-04-08 14:46 ` Stefan Monnier
  2005-04-09  3:38 ` Richard Stallman
  0 siblings, 2 replies; 9+ messages in thread
From: Stephan Stahl @ 2005-04-08 13:43 UTC (permalink / raw)


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

Hi.

whitespace-buffer does not delete its overlays but adds more and more
onto the buffer.

try this to reproduce:
1.:
emacs -Q
C-x C-f test.c (attached, just contains int         foo=1;
                seperated by a space followed by a tab)

2.:
M-x whitespace-buffer
put point on the highlighted overlay and press C-u C-x =
this shows

  character: SPC (040, 32, 0x20, U+0020)
    charset: ascii (ASCII (ISO646 IRV))
 code point: 32
     syntax:           which means: whitespace
   category: a:ASCII   l:Latin
buffer code: 0x20
  file code: 0x20 (encoded by coding system undecided-dos)
    display: by this font (glyph code)
     -outline-Courier New-normal-r-normal-normal-13-97-96-96-c-90-iso8859-1 (0x20)

There are 2 overlays here:
 From 14 to 15
  face                 [whitespace-highlight-face]
 From 14 to 15


There are text properties here:
  fontified            t

repeat 2. to see that now there are 3 overlays
repeat 2. to see that now there are 4 overlays
...

It seems whitespace.el does try to delete some overlay by calling the
function whitespace-unhighlight-the-space but this is not enough or
does not work.

The same thing does happen when global-whitespace-mode is enabled
because then whitespace-buffer is called from a timer.
-- 
Stephan Stahl

[-- Attachment #2: test.c --]
[-- Type: application/octet-stream, Size: 13 bytes --]

int 	foo=1;

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: whitespace.el does not seem to delete its overlays
  2005-04-08 13:43 whitespace.el does not seem to delete its overlays Stephan Stahl
@ 2005-04-08 14:46 ` Stefan Monnier
  2005-04-08 22:57   ` Stephan Stahl
  2005-04-09  3:38 ` Richard Stallman
  1 sibling, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2005-04-08 14:46 UTC (permalink / raw)
  Cc: emacs-devel

> whitespace-buffer does not delete its overlays but adds more and more
> onto the buffer.

I believe the patch below fixes it.  I've installed it in the CVS, please
try it out and tell me if it helps,


        Stefan


Index: whitespace.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/whitespace.el,v
retrieving revision 1.31
diff -u -u -b -r1.31 whitespace.el
--- whitespace.el	8 Apr 2005 14:26:13 -0000	1.31
+++ whitespace.el	8 Apr 2005 14:40:33 -0000
@@ -736,12 +732,10 @@
 (defun whitespace-highlight-the-space (b e)
   "Highlight the current line, unhighlighting a previously jumped to line."
   (if whitespace-display-spaces-in-color
-      (progn
+      (let ((ol (whitespace-make-overlay b e)))
 	(whitespace-unhighlight-the-space)
-	(add-to-list 'whitespace-highlighted-space
-		     (whitespace-make-overlay b e))
-	(whitespace-overlay-put (whitespace-make-overlay b e) 'face
-				'whitespace-highlight-face))))
+	(push ol whitespace-highlighted-space)
+	(whitespace-overlay-put ol 'face 'whitespace-highlight-face))))
 ;;  (add-hook 'pre-command-hook 'whitespace-unhighlight-the-space))
 
 (defun whitespace-unhighlight-the-space ()

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

* Re: whitespace.el does not seem to delete its overlays
  2005-04-08 14:46 ` Stefan Monnier
@ 2005-04-08 22:57   ` Stephan Stahl
  0 siblings, 0 replies; 9+ messages in thread
From: Stephan Stahl @ 2005-04-08 22:57 UTC (permalink / raw)
  Cc: emacs-devel

Hi Stefan.

Stefan Monnier said:
> I believe the patch below fixes it.  I've installed it in the CVS, please
> try it out and tell me if it helps,

This patch does help with the "too many overlays" problem but now there are
too few of them left :-).

It seems that only the last overlay survives.  I tried the example code from
my other mail but did copy the line several times and now after i run
M-x whitespace-buffer only the last line shows the whitespace-highlight-face.
-- 
Stephan Stahl

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

* Re: whitespace.el does not seem to delete its overlays
  2005-04-08 13:43 whitespace.el does not seem to delete its overlays Stephan Stahl
  2005-04-08 14:46 ` Stefan Monnier
@ 2005-04-09  3:38 ` Richard Stallman
  2005-04-09  8:05   ` Stephan Stahl
  1 sibling, 1 reply; 9+ messages in thread
From: Richard Stallman @ 2005-04-09  3:38 UTC (permalink / raw)
  Cc: emacs-devel

Does this make it work right?

*** whitespace.el	01 Oct 2004 13:57:03 -0400	1.30
--- whitespace.el	08 Apr 2005 21:54:36 -0400	
***************
*** 736,747 ****
  (defun whitespace-highlight-the-space (b e)
    "Highlight the current line, unhighlighting a previously jumped to line."
    (if whitespace-display-spaces-in-color
!       (progn
  	(whitespace-unhighlight-the-space)
! 	(add-to-list 'whitespace-highlighted-space
! 		     (whitespace-make-overlay b e))
! 	(whitespace-overlay-put (whitespace-make-overlay b e) 'face
! 				'whitespace-highlight-face))))
  ;;  (add-hook 'pre-command-hook 'whitespace-unhighlight-the-space))
  
  (defun whitespace-unhighlight-the-space ()
--- 736,746 ----
  (defun whitespace-highlight-the-space (b e)
    "Highlight the current line, unhighlighting a previously jumped to line."
    (if whitespace-display-spaces-in-color
!       (let (overlay)
  	(whitespace-unhighlight-the-space)
! 	(setq overlay (whitespace-make-overlay b e))
! 	(add-to-list 'whitespace-highlighted-space overlay)
! 	(whitespace-overlay-put overlay 'face 'whitespace-highlight-face))))
  ;;  (add-hook 'pre-command-hook 'whitespace-unhighlight-the-space))
  
  (defun whitespace-unhighlight-the-space ()

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

* Re: whitespace.el does not seem to delete its overlays
  2005-04-09  3:38 ` Richard Stallman
@ 2005-04-09  8:05   ` Stephan Stahl
  2005-04-10  1:55     ` Richard Stallman
  0 siblings, 1 reply; 9+ messages in thread
From: Stephan Stahl @ 2005-04-09  8:05 UTC (permalink / raw)
  Cc: Stefan Monnier, emacs-devel

Hi Richard.

Richard Stallman said:
> Does this make it work right?

Your patch has the same symptom as Stefans:

This patch does help with the "too many overlays" problem but now there are
too few of them left :-).

It seems that only the last overlay survives.  I tried the example code from
my other mail but did copy the line several times and now after i run
M-x whitespace-buffer only the last line shows the whitespace-highlight-face.
-- 
Stephan Stahl

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

* Re: whitespace.el does not seem to delete its overlays
  2005-04-09  8:05   ` Stephan Stahl
@ 2005-04-10  1:55     ` Richard Stallman
  2005-04-10 12:04       ` Stephan Stahl
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Stallman @ 2005-04-10  1:55 UTC (permalink / raw)
  Cc: monnier, emacs-devel

    It seems that only the last overlay survives.

That seems to be what the code was designed to do.

As for what the code SHOULD be trying to do, I am not really
certain.  I never use that feature,

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

* Re: whitespace.el does not seem to delete its overlays
  2005-04-10  1:55     ` Richard Stallman
@ 2005-04-10 12:04       ` Stephan Stahl
  2005-04-11  1:56         ` Richard Stallman
  0 siblings, 1 reply; 9+ messages in thread
From: Stephan Stahl @ 2005-04-10 12:04 UTC (permalink / raw)
  Cc: monnier, emacs-devel

Richard Stallman said:
>     It seems that only the last overlay survives.
>
> That seems to be what the code was designed to do.
>
> As for what the code SHOULD be trying to do, I am not really
> certain.  I never use that feature,

I was used to the old behavior showing all the "wrong"
whitespaces not just the last one.  Now whitespace.el does not
seem to be that useful anymore.

I'll try to find some time to get to know whitespace.el better
and change this :-).
-- 
Stephan Stahl

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

* Re: whitespace.el does not seem to delete its overlays
  2005-04-10 12:04       ` Stephan Stahl
@ 2005-04-11  1:56         ` Richard Stallman
  2005-04-11  6:13           ` Stephan Stahl
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Stallman @ 2005-04-11  1:56 UTC (permalink / raw)
  Cc: monnier, emacs-devel

    I was used to the old behavior showing all the "wrong"
    whitespaces not just the last one.

Now I understand what you want it to do.
Does this replacement function make it work right?

(defun whitespace-highlight-the-space (b e)
  "Highlight the current line, unhighlighting a previously jumped to line."
  (if whitespace-display-spaces-in-color
      (let ((ol (whitespace-make-overlay b e)))
	(push ol whitespace-highlighted-space)
	(whitespace-overlay-put ol 'face 'whitespace-highlight-face))))

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

* Re: whitespace.el does not seem to delete its overlays
  2005-04-11  1:56         ` Richard Stallman
@ 2005-04-11  6:13           ` Stephan Stahl
  0 siblings, 0 replies; 9+ messages in thread
From: Stephan Stahl @ 2005-04-11  6:13 UTC (permalink / raw)
  Cc: Stephan Stahl, monnier, emacs-devel

Richard Stallman said:
> Now I understand what you want it to do.
> Does this replacement function make it work right?

Yes it does work correct now.
Thank you.
-- 
Stephan Stahl

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

end of thread, other threads:[~2005-04-11  6:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-08 13:43 whitespace.el does not seem to delete its overlays Stephan Stahl
2005-04-08 14:46 ` Stefan Monnier
2005-04-08 22:57   ` Stephan Stahl
2005-04-09  3:38 ` Richard Stallman
2005-04-09  8:05   ` Stephan Stahl
2005-04-10  1:55     ` Richard Stallman
2005-04-10 12:04       ` Stephan Stahl
2005-04-11  1:56         ` Richard Stallman
2005-04-11  6:13           ` Stephan Stahl

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).