unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Werner LEMBERG <wl@gnu.org>
To: schwab@linux-m68k.org
Cc: acm@muc.de, monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: `make-overlay' very slow (was: hiding lines)
Date: Sat, 11 Apr 2009 00:42:48 +0200 (CEST)	[thread overview]
Message-ID: <20090411.004248.247201382.wl@gnu.org> (raw)
In-Reply-To: <20090410.235059.24212167.wl@gnu.org>

[-- Attachment #1: Type: Text/Plain, Size: 945 bytes --]


>>> I've now come up with the code as shown in the attachment.  It
>>> works fine, however, I would like to not have empty lines; in
>>> other words, invisible text should not take any space in the
>>> buffer.  Does Emacs supports such a `compressed invisibility'?
>>
>> 
>> Make the newline invisible.
> 
> Thanks!  This perhaps deserves a notice in the documentation.

I've now tried the code with my real-world table (containing
approx. 420000 lines):

  git://repo.or.cz/srv/git/wortliste.git

and I found out that it is, alas, unusable.  It starts with about 1000
replacements per second on my GNU/Linux box (using simply `-' as the
regexp), but soon the speed decreases: After approx. 10000
replacements it only can handle 100 replacements per second -- the
attached code now contains a small counter to show the progress.  If
you comment out the call to `make-overlay', the code really flies...

Am I doing something wrong?


    Werner

[-- Attachment #2: line-invisible.el --]
[-- Type: Text/Plain, Size: 1053 bytes --]

(defun make-lines-invisible (regexp &optional arg)
  "Make all lines matching a regexp invisible and intangible.
With a prefix arg, make it visible again.  It is not necessary
that REGEXP matches the whole line; if a hit is found, the
affected line gets automatically selected.

This command affects the whole buffer."
  (interactive "MRegexp: \nP")
  (let (ov
	ovs
	count)
    (cond
     ((equal arg '(4))
      (setq ovs (overlays-in (point-min) (point-max)))
      (mapc (lambda (o)
	      (if (overlay-get o 'make-lines-invisible)
		  (delete-overlay o)))
	    ovs))
     (t
      (save-excursion
	(goto-char (point-min))
	(setq count 0)
	(while (re-search-forward regexp nil t)
	  (setq count (1+ count))
	  (if (= (% count 100) 0)
	      (message "%d" count))
	  (setq ov (make-overlay (line-beginning-position)
				 (1+ (line-end-position))))
;	  (overlay-put ov 'make-lines-invisible t)
;	  (overlay-put ov 'invisible t)
;	  (overlay-put ov 'intangible t)
	  (goto-char (line-end-position))))))))

(global-set-key "\C-cz" 'make-lines-invisible)

  reply	other threads:[~2009-04-10 22:42 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-02  6:52 hiding lines Werner LEMBERG
2009-04-02 19:30 ` Alan Mackenzie
2009-04-03  0:39   ` Stefan Monnier
2009-04-03 12:26     ` Alan Mackenzie
2009-04-03 13:22       ` Stefan Monnier
2009-04-06  6:11         ` Werner LEMBERG
2009-04-06 13:10           ` Stefan Monnier
2009-04-06 16:20             ` Werner LEMBERG
2009-04-07  0:50               ` Stefan Monnier
2009-04-07  5:26                 ` Werner LEMBERG
2009-04-10 19:54           ` Werner LEMBERG
2009-04-10 20:42             ` Andreas Schwab
2009-04-10 21:50               ` Werner LEMBERG
2009-04-10 22:42                 ` Werner LEMBERG [this message]
2009-04-10 23:36                   ` `make-overlay' very slow Stefan Monnier
2009-04-11  6:11                     ` Werner LEMBERG
2009-04-11  7:34                       ` Lennart Borgman
2009-04-11  7:45                         ` Werner LEMBERG
2009-04-11  7:46                           ` Lennart Borgman
2009-04-11  8:33                             ` Werner LEMBERG
2009-04-11  8:55                       ` Eli Zaretskii
2009-04-11 12:51                       ` Stefan Monnier
2009-04-14 12:03                         ` Kenichi Handa
2009-04-14 13:03                           ` Stefan Monnier
2009-04-14 21:15                             ` Richard M Stallman
2009-04-15  3:56                             ` Kenichi Handa
2009-04-16 15:02                           ` clone-indirect-buffer-hook should be make-indirect-buffer-hook klaus.berndl
2009-04-03  5:44   ` hiding lines Andreas Roehler

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=20090411.004248.247201382.wl@gnu.org \
    --to=wl@gnu.org \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=schwab@linux-m68k.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 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).