From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Peter Tury" Newsgroups: gmane.emacs.help Subject: font-lock-defaults doesn't work?? Date: 13 Apr 2007 08:35:48 -0700 Organization: http://groups.google.com Message-ID: <1176478548.918147.146490@d57g2000hsg.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1176478580 26479 80.91.229.12 (13 Apr 2007 15:36:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 13 Apr 2007 15:36:20 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 13 17:36:10 2007 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.50) id 1HcNon-0005c1-MM for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Apr 2007 17:36:09 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HcNt5-0004KX-1i for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Apr 2007 11:40:35 -0400 Original-Path: shelby.stanford.edu!newshub.stanford.edu!postnews.google.com!d57g2000hsg.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 62 Original-NNTP-Posting-Host: 192.100.130.7 Original-X-Trace: posting.google.com 1176478549 29638 127.0.0.1 (13 Apr 2007 15:35:49 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 13 Apr 2007 15:35:49 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: d57g2000hsg.googlegroups.com; posting-host=192.100.130.7; posting-account=sseaIQ0AAAD60wXG9Sq-ztc7bTCwqeM_ Original-Xref: shelby.stanford.edu gnu.emacs.help:147042 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:42646 Archived-At: 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