From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim X Newsgroups: gmane.emacs.help Subject: Re: How to make font lock work with comments? Date: Fri, 31 Dec 2010 08:27:38 +1100 Organization: Unlimited download news at news.astraweb.com Message-ID: <87ipybvtmd.fsf@puma.rapttech.com.au> References: <8649bced-1240-483b-ba41-9bc581938275@t8g2000prh.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1293745247 12508 80.91.229.12 (30 Dec 2010 21:40:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 30 Dec 2010 21:40:47 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 30 22:40:42 2010 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.69) (envelope-from ) id 1PYQEh-0008GK-97 for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Dec 2010 22:40:39 +0100 Original-Received: from localhost ([127.0.0.1]:45338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PYQEg-00047k-OR for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Dec 2010 16:40:38 -0500 Original-Path: usenet.stanford.edu!news.kjsl.com!news.alt.net!news.astraweb.com!border2.newsrouter.astraweb.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:Nrv2Bz7oaSVd4nWzFG5qn560WpQ= Original-Lines: 72 Original-NNTP-Posting-Host: 2678319e.news.astraweb.com Original-X-Trace: DXC=MjoER4T@0WMI]J2Y9=AF]JL?0kYOcDh@J7^o:UA4R?cEaYW9XoKNQFD]G; 2>V^?kWCCAkl5c@XgkN69dGJn8i9_Nn`Hhjfc5WV@ Original-Xref: usenet.stanford.edu gnu.emacs.help:183759 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:77974 Archived-At: Elena writes: > On Dec 29, 9:50 am, rusi wrote: >> Im hacking on an apl mode >> >>  (let ((st (make-syntax-table)) >>         (comment-char ?\x235d)) >> : >> : >>  (modify-syntax-entry comment-char "<" st) >> >> This char shows as follows (Dont know if it shows elsewhere..) >> >> ⍝ A comment >> >> When I put point on the char and call describe-char I get >> >> --------------------------------- >>         character: ⍝ (9053, #o21535, #x235d) >> preferred charset: unicode (Unicode (ISO10646)) >>        code point: 0x235D >>            syntax: <         which means: comment >>          category: .:Base >>          to input: type "{upshoe-jot}" or "{lamp}" or "{comment}" or >> "{@}" with apl-ascii >>       buffer code: #xE2 #x8D #x9D >>         file code: not encodable by coding system iso-latin-1-unix >>           display: by this font (glyph code) >>     xft:-unknown-unifont-normal-normal-normal-*-12-*-*-*-d-0- >> iso10646-1 (#x2359) >> ------------------------------ >> >> In other words emacs sees this as a comment-type char (similar to what >> it says for semicolon in elisp buffers >> >> And yet in an elisp buffer the ; to EOL is red >> but here it is not. >> >> Any clues? > > Syntax and font-locking are two different things and are handled > separately. Commands look at syntax, humans look at font-locking. > > Try typing the string ";" (quotes included) into an Elisp buffer and > then calling `describe-char' on the semicolon: Emacs will tell you the > semicolon is a comment char, yet it will be highlighting it as string. > > Check out `font-lock-add-keywords'. The two are not as seperate as implied. The font-lock system can/does use the syntax table, primarily for comments and strings. See the section Syntactic Font Lock in the elisp manual (section 23.6.8). Also note that the development version of Emacs has some changes in this area i.e. from the NEWS file ,---- | ** New variable syntax-propertize-function to set syntax-table properties. | Replaces font-lock-syntactic-keywords which are now obsolete. | This allows syntax-table properties to be set independently from font-lock: | just call syntax-propertize to make sure the text is propertized. | Together with this new variable come a new hook | syntax-propertize-extend-region-functions, as well as two helper functions: | syntax-propertize-via-font-lock to reuse old font-lock-syntactic-keywords | as-is; and syntax-propertize-rules which provides a new way to specify | syntactic rules. `---- Tim -- tcross (at) rapttech dot com dot au