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: I can see invisible characters Date: Tue, 19 May 2009 08:16:12 +0200 (CEST) Message-ID: <20090519.081612.200547853.wl@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Tue_May_19_08_16_12_2009_876)--" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1242720094 12117 80.91.229.12 (19 May 2009 08:01:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 19 May 2009 08:01:34 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 19 10:01:25 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 1M6KGL-0000Xj-Dz for ged-emacs-devel@m.gmane.org; Tue, 19 May 2009 10:01:25 +0200 Original-Received: from localhost ([127.0.0.1]:46466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6KGK-0003KO-DF for ged-emacs-devel@m.gmane.org; Tue, 19 May 2009 04:01:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M6KGF-0003Jw-1h for emacs-devel@gnu.org; Tue, 19 May 2009 04:01:19 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M6KGA-0003HQ-Da for emacs-devel@gnu.org; Tue, 19 May 2009 04:01:18 -0400 Original-Received: from [199.232.76.173] (port=48953 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6KG9-0003HF-Sa for emacs-devel@gnu.org; Tue, 19 May 2009 04:01:13 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]:51212) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1M6KG8-0006Qy-V9 for emacs-devel@gnu.org; Tue, 19 May 2009 04:01:13 -0400 Original-Received: (qmail invoked by alias); 19 May 2009 07:01:11 -0000 Original-Received: from 88-134-56-17-dynip.superkabel.de (EHLO localhost) [88.134.56.17] by mail.gmx.net (mp006) with SMTP; 19 May 2009 09:01:11 +0200 X-Authenticated: #54312696 X-Provags-ID: V01U2FsdGVkX19cb4cIwp9cjzzghZoCMfTT4DrG7j6yLuxoKe88ms tB/L4gDLxJOm7z X-Mailer: Mew version 6.2.51 on Emacs 23.0.93.1 / Mule 6.0 (HANACHIRUSATO) X-Y-GMX-Trusted: 0 X-FuHaFi: 0.59,0.52 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:110979 Archived-At: ----Next_Part(Tue_May_19_08_16_12_2009_876)-- Content-Type: Text/Plain; charset=utf-8 Content-Transfer-Encoding: base64 W0VtYWNzIENWUyAyMDA5LTA1LTEzXQ0KDQowLiBTdGFydCBgZW1hY3MgLVEnLg0KDQoxLiBEbyBg TS14IGxvYWQtZmlsZSBsaW5lLWludmlzaWJsZS5lbCcgKHRoaXMgYXNzaWducw0KICAgYG1ha2Ut bGluZXMtaW52aXNpYmxlJyB0byBgQy1jIHonKS4NCg0KMi4gTG9hZCBmaWxlIGB3JyB3aXRoIGBD LXggQy1mIHcnLg0KDQozLiBEbyBgQy1jIHogwrcnICh0aGlzIGlzLCBtYWtlIGFsbCBsaW5lcyBp bnZpc2libGUgd2hpY2ggY29udGFpbiBhDQogICBtaWRkbGUgZG90KS4NCg0KNC4gRG8gYEMtdSBD LXggPSc6IFRoZSBmaXJzdCB2aXNpYmxlIGNoYXJhY3RlciBpbiB0aGUgYnVmZmVyIGhhcyBzZXQN CiAgIHRoZSBgaW52aXNpYmxlJyBwcm9wZXJ0eS4gIEl0IHNlZW1zIHRvIGJlIGEgYnVnIHRoYXQg SSBjYW4gc2VlIHRoYXQNCiAgIGNoYXJhY3Rlci4gIEl0IGhhcyBhbHNvIHNldCB0aGUgYGludGFu Z2libGUnIHByb3BlcnR5LCBhbmQgSSBjYW4NCiAgIG1vdmUgdGhlIGN1cnNvciBvbiB0b3Agb2Yg aXQgKHdpdGggdGhlIGFycm93IGtleXMsIGJ1dCBub3Qgd2l0aA0KICAgQy1hKS4gIFRoaXMgZG9l c24ndCBsb29rIHJpZ2h0IHRvby4uLg0KDQogICBBbiBvZmYtYnktb25lIGVycm9yPw0KDQoNCiAg ICAgV2VybmVyDQoNCg== ----Next_Part(Tue_May_19_08_16_12_2009_876)-- Content-Type: Application/Octet-Stream Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=w QWFjaGVuO0Fht2NoZW4KQWFjaGVuZXI7QWG3Y2hlt25lcgpBYWNoZW5lcmluO0Fht2NoZbduZbdy aW4KQWFjaGVuZXJuO0Fht2NoZbduZXJuCkFhY2hlbmVycztBYbdjaGW3bmVycwpBYWNoZW5zO0Fh t2NoZW5zCkFhZG9yZjtBYbdkb3JmCkFhbGJhdWVyO0FhbD1iYXUtZXIKQWFsYmVjaztBYWy3YmVj awpBYWxiZXN0YW5kO0FhbD1iZS1zdGFuZApBYWxiZXN05G5kZTtBYWw9YmUtc3Tkbi1kZQpBYWxi b3JnO0FhbC1ib3JnCkFhbGJvcmdlcjtBYWw9Ym9yLWdlcgpBYWxkZXJzO0FhbLdkZXJzCkFhbGU7 QWEtbGUKQWFsZW47QWEtbGVuCkFhbGVuZXI7QWEtbGUtbmVyCkFhbGVuZXJuO0FhLWxlLW5lcm4K QWFsZW5lcnM7QWEtbGUtbmVycwpBYWxlbnM7QWEtbGVucwpBYWxlcjtBYS1sZXIK ----Next_Part(Tue_May_19_08_16_12_2009_876)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="line-invisible.el" ;;; line-invisible.el ;;; ;;; Werner Lemberg, April 2009 ;; from font-lock.el (defmacro save-buffer-state (varlist &rest body) "Bind variables according to VARLIST and eval BODY restoring buffer state." (declare (indent 1) (debug let)) (let ((modified (make-symbol "modified"))) `(let* ,(append varlist `((,modified (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) (inhibit-point-motion-hooks t) (inhibit-modification-hooks t) deactivate-mark buffer-file-name buffer-file-truename)) (unwind-protect (progn ,@body) (unless ,modified (restore-buffer-modified-p nil)))))) (defun make-lines-invisible (regexp &optional arg) "Make all lines matching a regexp invisible and intangible. With a prefix arg, make them visible again. It is not necessary that REGEXP matches the whole line; if a hit is found, the affected line gets automatically selected. This function always applies to the whole buffer. Note that this function modifies the `invisible' and `intangible' text properties; it may thus interfere with modes which use them. Due to implementation restrictions in current Emacs versions it is not possible to use overlays -- which would avoid text property modifications -- without becoming unbearably slow for large buffers with many matches." (interactive "MLine matching regexp: \nP") (save-excursion (cond (arg (save-buffer-state ((next-pos (point-min))) (while (setq next-pos (text-property-any next-pos (point-max) 'make-lines-invisible t)) (goto-char next-pos) (setq next-pos (or (next-single-property-change (point) 'make-lines-invisible) (point-max))) (remove-list-of-text-properties (point) next-pos '(make-lines-invisible invisible intangible))))) (t (save-buffer-state ((start 0) (end 0)) (goto-char (point-min)) (while (re-search-forward regexp nil t) (setq start (match-beginning 0)) (goto-char start) (setq start (line-beginning-position)) (setq end (match-end 0)) (goto-char end) (setq end (1+ (line-end-position))) ; handle \n (add-text-properties start end '(make-lines-invisible t invisible t intangible t)) (goto-char (line-end-position)))))))) (defun make-other-lines-invisible (regexp) "Make all lines not matching a regexp invisible and intangible. It is not necessary that REGEXP matches the whole line; if a hit is found, the affected line gets automatically unselected. This function always applies to the whole buffer. Note that this function modifies the `invisible' and `intangible' text properties; it may thus interfere with modes which use them. Due to implementation restrictions in current Emacs versions it is not possible to use overlays -- which would avoid text property modifications -- without becoming unbearably slow for large buffers with many matches." (interactive "MLine matching regexp: \n") (save-excursion (save-buffer-state ((start 1) (end 1)) (goto-char (point-min)) (while (re-search-forward regexp nil t) (setq end (match-beginning 0)) (goto-char end) (setq end (1- (line-beginning-position))) ; handle \n (if (<= start end) (add-text-properties start end '(make-lines-invisible t invisible t intangible t))) (setq start (match-end 0)) (goto-char start) (setq start (line-end-position)) (goto-char (line-end-position))) (setq end (point-max)) (if (< start end) (add-text-properties start end '(make-lines-invisible t invisible t intangible t)))))) (global-set-key "\C-cz" 'make-lines-invisible) (global-set-key "\C-cZ" 'make-other-lines-invisible) ;; eof ----Next_Part(Tue_May_19_08_16_12_2009_876)----