From: Tassilo Horn <tassilo@member.fsf.org>
To: emacs-devel@gnu.org
Subject: Font locking in sh-mode stopped working (Emacs 24)
Date: Tue, 11 May 2010 09:15:57 +0200 [thread overview]
Message-ID: <201005110915.58315.tassilo@member.fsf.org> (raw)
Hi all,
since the last time I've updated my emacs bzr checkout (2010-05-07),
font-locking in sh-mode stopped working. Everything uses the `default'
face.
This doesn't happen with emacs -Q, but I was able to spot the part of my
customization which triggers that behavior. The offending code adds
support for outline headings in comments to source code files. I use
that code for years, and it always worked fine. And even now, it only
stopped working for sh-mode, but it still works for emacs-lisp, java or
LaTeX-mode.
Here's the code:
--8<---------------cut here---------------start------------->8---
(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)
(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)
(defvar th-outline-minor-mode-modes
'(c-mode emacs-lisp-mode lisp-mode ruby-mode haskell-mode
lua-mode clojure-mode sh-mode))
(defun th-turn-on-outline-minor-mode ()
(interactive)
(outline-minor-mode 1))
(dolist (mode th-outline-minor-mode-modes)
(add-hook (intern (concat (symbol-name mode) "-hook"))
'th-turn-on-outline-minor-mode))
--8<---------------cut here---------------end--------------->8---
Basically, it calculates the `outline-regexp' for a mode by
concatenating the `comment-starter' with one or more *, and all lines
starting with that should be highlighted with `outline-font-lock-face'.
To reproduce the problem, put the code in *scratch* and eval it. Then
find some shell script, and you'll see that no highlighting is done.
It is important to also evaluate the three last forms, which put the
outline-minor-mode activation inside the mode-hooks. If I omit these
lines, open a shell script and then activate `outline-minor-mode'
manually, font-locking works normal...
Am I doing anything wrong?
Bye,
Tassilo
reply other threads:[~2010-05-11 7:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201005110915.58315.tassilo@member.fsf.org \
--to=tassilo@member.fsf.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).