From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: Narrow/widen in folding.el Date: Tue, 21 Dec 2010 19:42:34 +0100 Message-ID: <87mxnz9dd1.fsf@member.fsf.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1292957025 21299 80.91.229.12 (21 Dec 2010 18:43:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 21 Dec 2010 18:43:45 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 21 19:43:40 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PV7BU-0007Ib-5d for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Dec 2010 19:43:40 +0100 Original-Received: from localhost ([127.0.0.1]:60576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PV7BT-0004IQ-JK for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Dec 2010 13:43:39 -0500 Original-Received: from [140.186.70.92] (port=52476 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PV7Aw-0004Hw-DE for help-gnu-emacs@gnu.org; Tue, 21 Dec 2010 13:43:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PV7Av-0001yn-6F for help-gnu-emacs@gnu.org; Tue, 21 Dec 2010 13:43:06 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:53342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PV7Au-0001yY-R1 for help-gnu-emacs@gnu.org; Tue, 21 Dec 2010 13:43:05 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PV7Ae-0006b2-Pz for help-gnu-emacs@gnu.org; Tue, 21 Dec 2010 19:42:48 +0100 Original-Received: from 95-88-32-105-dynip.superkabel.de ([95.88.32.105]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 21 Dec 2010 19:42:48 +0100 Original-Received: from tassilo by 95-88-32-105-dynip.superkabel.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 21 Dec 2010 19:42:48 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 75 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 95-88-32-105-dynip.superkabel.de User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:0r29FuqYA0420XJMtlk1Tvb7JJU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:77749 Archived-At: Andrea Crotti writes: Hi! >> I use folding.el a lot, and find it useful, but its interaction with >> isearch is decidedly suboptimal: if you start with a folded buffer, >> search for something, and land in a fold, the buffer will be narrowed >> to this fold, and to get out you have to hit C-x n w. This becomes a >> pain when I have to do lots of small quick searches/edits in a folded >> document. Is there a way to fix this behavior?.. > > I suggest to try org-mode, you can do the same things that you're doing > now but is much more powerful. But org-mode doesn't work for source code files, e.g. it's not the right thing for using folding in C++ files. > If I use isearch it expands when it finds something and doesn't narrow > it back if I press for example C-a, C-e org builds upon outline mode, and outline provides a nice outline-minor-mode that can be used to use outlining in any files. It also temporally unhides hidden parts when isearching. I have a small config snippet that calculates the right `outline-regexp'. Basically, it's the current buffer's comment syntax followed by at least one *. The more *s, the higher the level. --8<---------------cut here---------------start------------->8--- (require 'outline) (defvar th-outline-minor-mode-font-lock-keywords '((eval . (list (concat "^\\(?:" outline-regexp "\\).*") 0 '(outline-font-lock-face) t t))) "Additional expressions to highlight in Orgstruct Mode and Outline minor mode. The difference to `outline-font-lock-keywords' is that this will overwrite other highlighting.") (defun th-outline-regexp () "Calculate the outline regexp for the current mode." (let ((comment-starter (replace-regexp-in-string "[[:space:]]+" "" comment-start))) (when (string= comment-starter ";") (setq comment-starter ";;")) (concat comment-starter "[*]+ "))) (defun th-outline-minor-mode-init () (interactive) (unless (eq major-mode 'latex-mode) (setq outline-regexp (th-outline-regexp)) (font-lock-add-keywords nil th-outline-minor-mode-font-lock-keywords))) (add-hook 'outline-minor-mode-hook 'th-outline-minor-mode-init) --8<---------------cut here---------------end--------------->8--- So in Lisp, I can do: ;;* Headline 1 ;;** Headline 1.1 ;;** Headline 1.2 and in C I can do //* Headline 1 //** Headline 1.1 //** Headline 1.2 I also bind TAB to a function that calls `org-cycle' if I'm on an outline heading, and in all other cases does what TAB would do normally. Bye, Tassilo