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: Leo Alekseyev
Subject: Re: Narrow/widen in folding.el
Date: Fri, 24 Dec 2010 18:18:30 -0800

On Tue, Dec 21, 2010 at 10:42 AM, Tassilo Horn <tassilo@member.fsf.org> wrote:

>
> 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---

I've started using Tassilo's snippet in some of my projects and I like
it a lot, especially combined with org-mode's visibility cycling (cf
http://orgmode.org/faq.html#sec-1.2 ).

I've been running into the following issue: I turn on the
outline-minor-mode through a file-local variable, e.g. "--  -*-
mode:sql; mode:outline-minor  -*- ".  However, the headings are not
fontified until I manually toggle outline-minor-mode on and off.  This
is somewhat strange, since the new entries do appear in
font-lock-keywords-alist.  But even toggling font-lock-mode doesn't
make it work, only re-enabling outline-minor-mode.  I'd love to hear
your thoughts on how to fix this :)

--Leo



reply via email to

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