all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: gento <gento_distefano@hotmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: syntax highlighting for comments
Date: Thu, 17 Sep 2009 03:29:14 -0700 (PDT)	[thread overview]
Message-ID: <9da5577a-80fb-4a5c-8fde-598ca8675b52@n2g2000vba.googlegroups.com> (raw)
In-Reply-To: 4aafe4ee$0$12656$ba4acef3@news.orange.fr

Thank you very much Bruno!

I'm using this

(add-hook 'find-file-hooks
 (lambda ()
  (when (string-match "\\.jou$" (buffer-file-name))
   (setq comment-start "/")
   (font-lock-add-keywords nil '("\\(/.*\\)$" (1 font-lock-comment-
face)))
   (font-lock-mode)
  )
 )
)

and it works.

Have a nice day




Bruno Barbier wrote:
> On 2009-09-15, bj <gento_distefano@hotmail.com> wrote:
> > any idea?
> >
> > On 8 Set, 10:26, gento <gento_distef...@hotmail.com> wrote:
> >> Hi All,
> >>
> >> I'm using emacs to edit journal text files *.jou, for which commented
> >> lines
> >> start with the character "/".
> >>
> >> I apply the comment syntax for the "*.jou" files by adding to
> >> the .emacs file
> >> the lines
> >>
> >> (add-hook 'find-file-hooks
> >>  (lambda ()
> >>   (when (string-match "\\.jou$" (buffer-file-name))
> >>    (setq comment-start "/")
> >>   )
> >>  )
> >> )
> >>
> >> Now I would also like to turn the text of the commented lines into
> >> red, and for this
> >> I added the line
> >>
> >> (font-lock-add-keywords nil '("\\(/.*\\)$" (1 font-lock-comment-
> >> face)))
> >>
> >> which unfortunately doesn’t work.
> >>
> >> Does anybody know where the mistake is?
> >> Many thanks
> >>
> >> gento
> >
>
>
> I don't have any major-mode for "*.jou" files; if you don't have
> either, the following should work for you.
>
>     (add-hook 'find-file-hooks
>                (lambda ()
>                  (when (string-match "\\.jou$" (buffer-file-name))
>                    )
>                  (font-lock-add-keywords nil
>                                          '("\\(/.*\\)$"
>                                            (1
>                                             font-lock-comment-face)))
>                  (font-lock-mode)
>                  )
>                )
>
> So, in short:
>    1) Your line with `font-lock-add-keywords' must be evaluated in the
>    right buffer.
>    2) And you have to turn `font-lock-mode' on in the buffer for
>    fontification to happen.
>
>
> If you want to add more features, you should probably take the time to
> define your own major mode "jou-mode":
>
>   (info "(emacs)Major modes")
>   (info "(elisp)Major modes")
>
>
> PS: I don't know what "jou" files are, but, if you are writing your
>      own journal file, you should give `org-mode' a try; it's a
>      wonderful addictive tool to take notes, to make plan and publish
>      everything in LaTeX, HTML, etc.
>      And it is included in recent versions of GNU Emacs.
>
>      http://orgmode.org/


      reply	other threads:[~2009-09-17 10:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-08  8:26 syntax highlighting for comments gento
2009-09-15 16:49 ` bj
2009-09-15 19:03   ` Bruno Barbier
2009-09-17 10:29     ` gento [this message]

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=9da5577a-80fb-4a5c-8fde-598ca8675b52@n2g2000vba.googlegroups.com \
    --to=gento_distefano@hotmail.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.