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: Re: hiding lines Date: Fri, 10 Apr 2009 21:54:24 +0200 (CEST) Message-ID: <20090410.215424.136009858.wl@gnu.org> References: <20090403122603.GA3082@muc.de> <20090406.081123.144381775.wl@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Fri_Apr_10_21_54_24_2009_115)--" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1239393306 3022 80.91.229.12 (10 Apr 2009 19:55:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 10 Apr 2009 19:55:06 +0000 (UTC) Cc: acm@muc.de, emacs-devel@gnu.org To: monnier@iro.umontreal.ca Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 10 21:56:24 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 1LsMpr-0005UC-Kf for ged-emacs-devel@m.gmane.org; Fri, 10 Apr 2009 21:56:23 +0200 Original-Received: from localhost ([127.0.0.1]:36547 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LsMoT-0002gG-Aa for ged-emacs-devel@m.gmane.org; Fri, 10 Apr 2009 15:54:57 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LsMo2-0002QG-U9 for emacs-devel@gnu.org; Fri, 10 Apr 2009 15:54:30 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LsMny-0002MF-5c for emacs-devel@gnu.org; Fri, 10 Apr 2009 15:54:30 -0400 Original-Received: from [199.232.76.173] (port=39075 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LsMnx-0002MB-W4 for emacs-devel@gnu.org; Fri, 10 Apr 2009 15:54:26 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]:40581) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1LsMnx-000781-Dl for emacs-devel@gnu.org; Fri, 10 Apr 2009 15:54:25 -0400 Original-Received: (qmail invoked by alias); 10 Apr 2009 19:54:23 -0000 Original-Received: from ip-78-94-5-101.unitymediagroup.de (EHLO localhost) [78.94.5.101] by mail.gmx.net (mp067) with SMTP; 10 Apr 2009 21:54:23 +0200 X-Authenticated: #54312696 X-Provags-ID: V01U2FsdGVkX185ylEg2pM5qpLXjGeiyHkQQcjVPy/LLCPKNPWWgv OE8yCD0E7MdYgR In-Reply-To: <20090406.081123.144381775.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.75,0.62 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. 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:110191 Archived-At: ----Next_Part(Fri_Apr_10_21_54_24_2009_115)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit > Consider this table: > > foo > bar > foo=bar > bar-foo > baz > baz=baz > baz-foo=baz > > I would like to make all lines invisable *and* intangible which > don't contain a `='. Otherwise interactive search-and-replace would > try to modify invisible text. At least this is my conclusion of > your explanations. 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'? Otherwise it's getting quite complicated, I fear... Werner ----Next_Part(Fri_Apr_10_21_54_24_2009_115)-- 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) (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)) (while (re-search-forward regexp nil t) (setq ov (make-overlay (line-beginning-position) (line-end-position))) (overlay-put ov 'make-lines-invisible t) (overlay-put ov 'invisible t) (overlay-put ov 'intangible t))))))) (global-set-key "\C-cz" 'make-lines-invisible) ----Next_Part(Fri_Apr_10_21_54_24_2009_115)----