From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Werner LEMBERG Newsgroups: gmane.emacs.devel Subject: `make-overlay' very slow (was: hiding lines) Date: Sat, 11 Apr 2009 00:42:48 +0200 (CEST) Message-ID: <20090411.004248.247201382.wl@gnu.org> References: <20090410.215424.136009858.wl@gnu.org> <20090410.235059.24212167.wl@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Sat_Apr_11_00_42_48_2009_137)--" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1239403388 29113 80.91.229.12 (10 Apr 2009 22:43:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 10 Apr 2009 22:43:08 +0000 (UTC) Cc: acm@muc.de, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: schwab@linux-m68k.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 11 00:44:26 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LsPST-0004Gr-98 for ged-emacs-devel@m.gmane.org; Sat, 11 Apr 2009 00:44:25 +0200 Original-Received: from localhost ([127.0.0.1]:50512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LsPR4-0002gb-RT for ged-emacs-devel@m.gmane.org; Fri, 10 Apr 2009 18:42:58 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LsPQz-0002gG-Rz for emacs-devel@gnu.org; Fri, 10 Apr 2009 18:42:53 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LsPQv-0002eK-98 for emacs-devel@gnu.org; Fri, 10 Apr 2009 18:42:53 -0400 Original-Received: from [199.232.76.173] (port=55380 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LsPQv-0002eH-2Y for emacs-devel@gnu.org; Fri, 10 Apr 2009 18:42:49 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]:52440) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1LsPQu-0003fn-FA for emacs-devel@gnu.org; Fri, 10 Apr 2009 18:42:48 -0400 Original-Received: (qmail invoked by alias); 10 Apr 2009 22:42:46 -0000 Original-Received: from ip-78-94-5-101.unitymediagroup.de (EHLO localhost) [78.94.5.101] by mail.gmx.net (mp043) with SMTP; 11 Apr 2009 00:42:46 +0200 X-Authenticated: #54312696 X-Provags-ID: V01U2FsdGVkX19rNG4y/d5rjARk7EWWigqc9Cq6dDT0nVk0AfFktq mlYkzYAlka+XJ5 In-Reply-To: <20090410.235059.24212167.wl@gnu.org> X-Mailer: Mew version 6.2.50 on Emacs 22.3.1 / Mule 5.0 (SAKAKI) X-Y-GMX-Trusted: 0 X-FuHaFi: 0.67,0.6 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:110200 Archived-At: ----Next_Part(Sat_Apr_11_00_42_48_2009_137)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit >>> 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 ----Next_Part(Sat_Apr_11_00_42_48_2009_137)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="line-invisible.el" (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) ----Next_Part(Sat_Apr_11_00_42_48_2009_137)----