From: "Peter Tury" <tury.peter@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: font-lock-defaults doesn't work??
Date: 13 Apr 2007 08:35:48 -0700 [thread overview]
Message-ID: <1176478548.918147.146490@d57g2000hsg.googlegroups.com> (raw)
Hi,
I am trying to create a new major mode from scratch. I found that
syntax parsing doesn't work properly sometimes. Why? Am I missed
something or this is a bug?
Details:
I have the following defun for start. If I remove the "secretly
must-to-have parts" (see below) then M-: (syntax-ppss) returns lists
as if it would parse a lisp buffer: characters in a line after `;'
reported as in-comment chars, and real comments (= delimited by `/*'
and `*/' doesn't recognized as comments. However, fontification works
nicely -- most of the time, but not always: _sometimes_, if I put `;'
inside a /*-comment and then delete this `;', then comment-color is
removed... More interestingly once I got nil for the value of
font-lock-syntax-table (queried via C-h v font-lock-syntax-table from
the buffer where I activated this new mode via M-x t-mode
previously)!?
So it seems syntax parsing is wrong and fontification is
indeterministic iff I set(??) font-lock-syntax-table via
font-lock-defaults, but everything works well if I directly set it via
set-syntax-table.
Is this normal? Do you know the reason? Should I report it as a bug?
(defun t-mode ()
"test major mode"
(interactive)
(kill-all-local-variables)
(setq major-mode (quote t-mode))
(setq mode-name "t-mode")
;; secretly must-to-have parts -- start
(let ((t-syntax-table (make-syntax-table)))
(modify-syntax-entry ?/ ". 14" t-syntax-table)
(modify-syntax-entry ?* ". 23" t-syntax-table)
(set-syntax-table t-syntax-table))
;; secretly must-to-have parts -- end
(set (make-local-variable 'font-lock-defaults)
'(nil nil t
((?/ . ". 14")
(?* . ". 23"))))
(run-mode-hooks 't-mode-hook))
Note: emacs' help writes for font-lock-syntax-table: "this is normally
set via `font-lock-defaults'", while elisp manual writes for
make-syntax-table (in 35.3): "most major mode syntax tables are
created in this way" -- however I would think that make-syntax-table
is unusable if I set font-lock-syntax-table via font-lock-
defaults...??
(I use patched EmacsW32 v feb.20.2007, and haven't tested the
situation with -Q...)
Thanks for your help in advance,
P
next reply other threads:[~2007-04-13 15:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-13 15:35 Peter Tury [this message]
2007-04-14 9:42 ` font-lock-defaults doesn't work?? Tim X
2007-04-14 10:13 ` Peter Tury
2007-04-14 10:47 ` Lennart Borgman (gmail)
2007-04-15 3:54 ` Tim X
2007-04-16 10:07 ` Peter Tury
-- strict thread matches above, loose matches on Subject: below --
2007-04-15 7:48 martin rudalics
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1176478548.918147.146490@d57g2000hsg.googlegroups.com \
--to=tury.peter@gmail.com \
--cc=help-gnu-emacs@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.