unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Xah <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: At&t assembler syntax highlighting
Date: Thu, 20 Nov 2008 22:23:18 -0800 (PST)	[thread overview]
Message-ID: <12128a3c-bd3e-4cd3-bebc-d36b2262e5a5@d42g2000prb.googlegroups.com> (raw)
In-Reply-To: mailman.808.1227161618.26697.help-gnu-emacs@gnu.org

On Nov 19, 10:13 pm, Alexander <coo...@gmail.com> wrote:
> Xahпишет:> On Nov 18, 10:46 pm, Alexander<coo...@gmail.com>  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
> > ∑http://xahlee.org/
>
> It will be good.
>
> asm-mode quite pretty highlights source code, but it is not able to add comments 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:

• modify the syntax table of that mode, using a hook.
• possibly modify the the keymap in that mode, using a hook, so that
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 “-” in elisp mode is considered part of word, so that cursor
movement will move a whole something-something instead of stopping at
“_”.

(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

• Syntax Class Table - GNU Emacs Lisp Reference Manual
http://xahlee.org/elisp/Syntax-Class-Table.html

• Syntax Flags - GNU Emacs Lisp Reference Manual
http://xahlee.org/elisp/Syntax-Flags.html

the latter has some comments on how to do the “/* comment */”.

------------------------

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
∑ http://xahlee.org/

  parent reply	other threads:[~2008-11-21  6:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.726.1227077176.26697.help-gnu-emacs@gnu.org>
2008-11-19  7:57 ` At&t assembler syntax highlighting Xah
2008-11-19 10:08   ` rustom
2008-11-20  6:07     ` Alexander
2008-11-20  6:13   ` Alexander
     [not found]   ` <mailman.808.1227161618.26697.help-gnu-emacs@gnu.org>
2008-11-21  6:23     ` Xah [this message]
     [not found] <mailman.739.1227099258.26697.help-gnu-emacs@gnu.org>
2008-11-19 13:08 ` rustom
2008-11-19 12:49 martin rudalics
  -- strict thread matches above, loose matches on Subject: below --
2008-11-19  6:46 Alexander

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=12128a3c-bd3e-4cd3-bebc-d36b2262e5a5@d42g2000prb.googlegroups.com \
    --to=xahlee@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.
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).