From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Newsgroups: gmane.emacs.help Subject: Re: At&t assembler syntax highlighting Date: Thu, 20 Nov 2008 22:23:18 -0800 (PST) Organization: http://groups.google.com Message-ID: <12128a3c-bd3e-4cd3-bebc-d36b2262e5a5@d42g2000prb.googlegroups.com> References: <640338b8-6f62-47eb-af39-c5ac10877f54@e1g2000pra.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1227301625 15520 80.91.229.12 (21 Nov 2008 21:07:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Nov 2008 21:07:05 +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 Nov 21 22:08:08 2008 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 1L3dET-0001Px-0c for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Nov 2008 22:08:05 +0100 Original-Received: from localhost ([127.0.0.1]:43719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L3dDK-0002c4-6M for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Nov 2008 16:06:54 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!d42g2000prb.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 122 Original-NNTP-Posting-Host: 24.6.185.159 Original-X-Trace: posting.google.com 1227248599 27518 127.0.0.1 (21 Nov 2008 06:23:19 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 21 Nov 2008 06:23:19 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d42g2000prb.googlegroups.com; posting-host=24.6.185.159; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.26.2 (KHTML, like Gecko) Version/3.2 Safari/525.26.12, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:164664 X-Mailman-Approved-At: Fri, 21 Nov 2008 16:06:25 -0500 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:60013 Archived-At: On Nov 19, 10:13 pm, Alexander wrote: > Xah=D0=BF=D0=B8=D1=88=D0=B5=D1=82:> On Nov 18, 10:46 pm, Alexander wrote: > > > don't know. > > > but if you produce a list of function names, type names, keyword > > names, etc, i can produce the mode for you. > > > Xah > > =E2=88=91http://xahlee.org/ > > It will be good. > > asm-mode quite pretty highlights source code, but it is not able to add c= omments for at&t assembler. > comments for at&t assembler are added in following way: > # this is a comment > /* this is a comment */ > but in current asm-mode, comments added with ";;". > > Could give me some examples, how to change comments format for this mode? > Thanks. you'll have to do several things: =E2=80=A2 modify the syntax table of that mode, using a hook. =E2=80=A2 possibly modify the the keymap in that mode, using a hook, so tha= t the shortcut for comment-dwim do comment. the mode is probably not very well written since it gets the comment wrong. So the best thing is to either contact the author to have him fix these, or just modify the mode' source code yourself and become the maintainer/fork yourself. Here's a example how to modify the syntax table using a hook, so that the char =E2=80=9C-=E2=80=9D in elisp mode is considered part of word, so t= hat cursor movement will move a whole something-something instead of stopping at =E2=80=9C_=E2=80=9D. (add-hook 'emacs-lisp-mode-hook (lambda () (modify-syntax-entry ?- "w" emacs-lisp-mode-syntax-table ) ) ) the essense of using a hook to modify a mode's syntax table, is that you need to find the hook name and syntax table name. If the mode name is xyz-mode, its hook name is usually xyz-mode-hook and xyz-mode- syntax-table. To find out the mode's mode name, do Ctrl+h v then type major-mode. Here's a example of modifying the source code on the syntax table itself: (defvar xlsl-mode-syntax-table (let ((synTable (make-syntax-table))) (modify-syntax-entry ?\/ ". 12b" synTable) (modify-syntax-entry ?\n "> b" synTable) synTable ) "Syntax table for `xlsl-mode'." ) in this case, the lsl lang's comment is // this is comment /* this is NOT comment */ the emacs's syntax table concept and code is rather esoteric... i'm thinking it's that useful, or rather not powerful and flexible enough. in your case, you probably want (modify-syntax-entry ?# ". 12b" synTable) (modify-syntax-entry ?\n "> b" synTable) to cover the # comment i haven't wrote a mode that deal with comment like: /* comment here */ but basically 2 lines like the above will do. See =E2=80=A2 Syntax Class Table - GNU Emacs Lisp Reference Manual http://xahlee.org/elisp/Syntax-Class-Table.html =E2=80=A2 Syntax Flags - GNU Emacs Lisp Reference Manual http://xahlee.org/elisp/Syntax-Flags.html the latter has some comments on how to do the =E2=80=9C/* comment */=E2=80= =9D. ------------------------ maybe later today i'll write a full tutorial on how do deal with the 2 types of comments, one starts with a line and ends in a EOL, and the other using matching pairs. look at java mode's source code, since that lang uses the same as your case. -------------- if you find the above too hard, you can just resort to C-x r k runs the command kill-rectangle C-x r t runs the command string-rectangle for the first 5 years of using emacs, i just used these for comments, in any lang. Xah =E2=88=91 http://xahlee.org/ =E2=98=84