help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Narrow/widen in folding.el


From: Tim X
Subject: Re: Narrow/widen in folding.el
Date: Sun, 26 Dec 2010 09:48:28 +1100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Leo Alekseyev <dnquark@gmail.com> writes:

> On Tue, Dec 21, 2010 at 10:42 AM, Tassilo Horn <tassilo@member.fsf.org> wrote:
>> --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---
>
> 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 :)
>

I'm not sure if this is relevant or not, but I've noticed some
inconsistent behavior with respect to font-lock and sql mode. This is
someting which has only appeared in the last couple of weeks (using bzr
trunk for emacs 24.0.50). 

I've been working on a derived mode for coding pl/sql which is derived
from sql mode. I've found that in my derived mode, I have to explicitly
call sql-set-product in the load hook, even though I have sql-product
set to oracle. Essentially, this appears to reload the mode. In other
cases, using sql mode, I've noticed I sometimes need to start sql-mode,
set the product to ansi and then set it back o oracle in order to get
the appropriate font locking. 

My guess is that there is some sort of weird font lock issue arising
form sql modes attempt to support multiple different sets of font lock
keywords. This could be what is impacting on your use of outline as
well. 

As mentioned, this issue only started to appear in the last few weeks
i.e. this month. I've looked through the changelog and can't see
anything obvious. If/when I track it down, I will possibly log a bug
report if this is warranted. However, as I cannot nail it down yet and
as I'm mainly only seeing it with my own derived mode, I will wait until
I'm confident its not something wrong that I"m doing. 

Tim

-- 
tcross (at) rapttech dot com dot au


reply via email to

[Prev in Thread] Current Thread [Next in Thread]