From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Alekseyev Newsgroups: gmane.emacs.help Subject: Re: Narrow/widen in folding.el Date: Fri, 24 Dec 2010 20:45:38 -0800 Message-ID: References: <87mxnz9dd1.fsf@member.fsf.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1293252366 7012 80.91.229.12 (25 Dec 2010 04:46:06 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 25 Dec 2010 04:46:06 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Tassilo Horn Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 25 05:46:02 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 1PWM13-0004me-T3 for geh-help-gnu-emacs@m.gmane.org; Sat, 25 Dec 2010 05:46:02 +0100 Original-Received: from localhost ([127.0.0.1]:35340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PWM13-00017p-AF for geh-help-gnu-emacs@m.gmane.org; Fri, 24 Dec 2010 23:46:01 -0500 Original-Received: from [140.186.70.92] (port=51092 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PWM0j-00017k-6O for help-gnu-emacs@gnu.org; Fri, 24 Dec 2010 23:45:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PWM0i-0005Rf-4E for help-gnu-emacs@gnu.org; Fri, 24 Dec 2010 23:45:41 -0500 Original-Received: from mail-fx0-f41.google.com ([209.85.161.41]:49853) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PWM0h-0005Rb-Ta for help-gnu-emacs@gnu.org; Fri, 24 Dec 2010 23:45:40 -0500 Original-Received: by fxm12 with SMTP id 12so1599028fxm.0 for ; Fri, 24 Dec 2010 20:45:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=9aAFCL/D7iUGXHVA3g6ohhsEfAHRCRZgEX5z0am9DEo=; b=EqYwRmGgjpF7U/RcIyELs5suWdsjHxeBrYjtvYXQQuLGCoTZFif/YxCEVvszT4Uo3r bF1XvZySCsjmJgXYTDBuHfrTJxkbA1bhXFHDS/6OLbwbE61fnXzGK6XsmH5S+lb6atoC tXy6RZKYZrqBpRbNJEv8YsaxPxgCn9YaTzixY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=o7w6cFYCU6305EuDC2GxhcfD06p46LhAWR2VDYkkANH/tocjtU7PKycTQqoDSruGYT fh3/1tqPLDrwW4UAqYOzVojzrB2Z3JBsCNoV1ZeSpE0OQZYriyLEBfIRr7ll3ooCmbJ7 VHrPAQUzlGUm6PPpAhmHJySyP2KoAkJUlTcoU= Original-Received: by 10.223.108.83 with SMTP id e19mr1892388fap.54.1293252338999; Fri, 24 Dec 2010 20:45:38 -0800 (PST) Original-Received: by 10.223.101.131 with HTTP; Fri, 24 Dec 2010 20:45:38 -0800 (PST) In-Reply-To: <87mxnz9dd1.fsf@member.fsf.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:77876 Archived-At: On Tue, Dec 21, 2010 at 10:42 AM, Tassilo Horn wro= te: > --8<---------------cut here---------------start------------->8--- > (require 'outline) > > (defvar th-outline-minor-mode-font-lock-keywords > =A0'((eval . (list (concat "^\\(?:" outline-regexp "\\).*") > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A00 '(outline-font-lock-face) t t))) > =A0"Additional expressions to highlight in Orgstruct Mode and Outline min= or mode. > The difference to `outline-font-lock-keywords' is that this will > overwrite other highlighting.") > > (defun th-outline-regexp () > =A0"Calculate the outline regexp for the current mode." > =A0(let ((comment-starter (replace-regexp-in-string > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"[[:space:]]+" "" comm= ent-start))) > =A0 =A0(when (string=3D comment-starter ";") > =A0 =A0 =A0(setq comment-starter ";;")) > =A0 =A0(concat comment-starter "[*]+ "))) > > (defun th-outline-minor-mode-init () > =A0(interactive) > =A0(unless (eq major-mode 'latex-mode) > =A0 =A0(setq outline-regexp (th-outline-regexp)) > =A0 =A0(font-lock-add-keywords > =A0 =A0 nil > =A0 =A0 th-outline-minor-mode-font-lock-keywords))) > > (add-hook 'outline-minor-mode-hook > =A0 =A0 =A0 =A0 =A0'th-outline-minor-mode-init) > --8<---------------cut here---------------end--------------->8--- Sincerest apologies for the spam, and please disregard the previous two messages. The problem with the above snippet still exists for me, but only for certain modes. In particular, for sql-mode, when th-outline-minor-mode-init is invoked via a hook when loading a file, as in Tassilo's code above, the font-lock-keywords variable does not appear to be set correctly. However, when th-outline-minor-mode-init is called interactively (either via M-x th-outline-minor-mode-init, or evaluating (outline-minor-mode t)), everything starts working. In other modes (e.g. shell and R), font-lock-keywords are set correctly, it seems, but the font-lock for first level heading doesn't seem to work. In elisp mode, everything works :) It's pretty hard to nail down the problem exactly, since it tends to be (a) mode-specific and (b) depends on whether the code is being called via a hook or interactively. Still, if there's a quick obvious fix, I'd like to know :)