Dan Bar Dov | 15 Jun 2006 17:11

Help using font-lock

I'm having a problem understanding how to use font-lock-mode 
without using any major mode.

Actually, I'm editing some text in text-mode and I'd like several 
forms to be highlighted.

I tried to set the following in my init.el, but this does not seem to work

(setq font-lock-keywords
      '(("   \\*.*" . 'font-lock-string-face)
	("---+ .*" . 'font-lock-string-face)
))

I do not want to write a new major mode or anything fancy, something very simple.

I'll appreciate any help
Dan

matthew.miner | 16 Jun 2006 23:36
Favicon

Re: Help using font-lock

I am by no stretch of the imagination an expert at this, and I use emacs,
but here's one of mine.

If you run this (eval-buffer), you will have a 'faces-mode' command that
you can then run.
Alt-x faces-mode will then set all new faces for this buffer, highlighting
each face name with it's attributes.
These were the only ones I knew about.

Anyway, change a few strings to your regular expressions, add this to your
.emacs, open your text file, and run "faces-mode" (or whatever you rename
it to), and you should be good to go.

Suggestions for improvement are always welcome.

HIH

(defvar faces-font-lock-keywords
  (list
   '("font-lock-builtin-face"       . font-lock-builtin-face)
   '("font-lock-comment-face"       . font-lock-comment-face)
   '("font-lock-constant-face"      . font-lock-constant-face)
   '("font-lock-doc-face"           . font-lock-doc-face)
   '("font-lock-function-name-face" . font-lock-function-name-face)
   '("font-lock-keyword-face"       . font-lock-keyword-face)
   '("font-lock-reference-face"     . font-lock-reference-face)
   '("font-lock-string-face"        . font-lock-string-face)
   '("font-lock-type-face"          . font-lock-type-face)
   '("font-lock-variable-name-face" . font-lock-variable-name-face)
   '("font-lock-warning-face"       . font-lock-warning-face)
(Continue reading)

Stephen J. Turnbull | 17 Jun 2006 09:48
Picon
Favicon

Re: Help using font-lock

>>>>> "Dan" == Dan Bar Dov <danb <at> voltaire.com> writes:

    Dan> I do not want to write a new major mode or anything fancy,
    Dan> something very simple.

Writing major modes is actually fairly easy.  However, If I recall
correctly, we have some approximation to the generic-x library (but it
may not be called that) available somewhere, probably in edit-utils,
which does exactly what you want: you derive a mode from it (one macro
call with easy-to-use arguments like the name of the new mode) and add
font-lock keywords to get the desired highlighting.

I'll take a look in a day or so, I'm buried this weekend, unfortunately.

--

-- 
School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.

Dan Bar Dov | 18 Jun 2006 09:59

RE: Help using font-lock

Thanks, I'll give it a try.

Dan 

> -----Original Message-----
> From: xemacs-news-bounces <at> xemacs.org 
> [mailto:xemacs-news-bounces <at> xemacs.org] On Behalf Of 
> matthew.miner <at> misys.com
> Sent: Saturday, June 17, 2006 12:36 AM
> To: xemacs-news <at> xemacs.org
> Subject: Re: Help using font-lock
> 
> I am by no stretch of the imagination an expert at this, and 
> I use emacs,
> but here's one of mine.
> 
> If you run this (eval-buffer), you will have a 'faces-mode' 
> command that
> you can then run.
> Alt-x faces-mode will then set all new faces for this buffer, 
> highlighting
> each face name with it's attributes.
> These were the only ones I knew about.
> 
> Anyway, change a few strings to your regular expressions, add 
> this to your
> .emacs, open your text file, and run "faces-mode" (or 
> whatever you rename
> it to), and you should be good to go.
> 
(Continue reading)

Andy Sawyer | 17 Jun 2006 11:39

Re: Help using font-lock

"Dan Bar Dov" <danb <at> voltaire.com> writes:

> I'm having a problem understanding how to use font-lock-mode 
> without using any major mode.
>
> Actually, I'm editing some text in text-mode and I'd like several 
> forms to be highlighted.
>
> I tried to set the following in my init.el, but this does not seem to work
>
> (setq font-lock-keywords
>       '(("   \\*.*" . 'font-lock-string-face)
> 	("---+ .*" . 'font-lock-string-face)
> ))
>
> I do not want to write a new major mode or anything fancy, something
> very simple.

 Writing a new major mode to do this is one of those things that turns
out to be very simple, once you know how :). Try this:

,----
| (define-derived-mode dbd-mode
|   text-mode
|   "DBD"
|   "Highlight for DBD."
|   (font-lock-mode 1))
| 
| (defconst dbd-mode-font-lock-keywords
|   '(("   \\*.*" . font-lock-string-face)
(Continue reading)

Dan Bar Dov | 22 Jun 2006 15:29

RE: Help using font-lock

Thanks for all the replies, here's what I ended up with (if anyone's interested)
(no comments though ...)
----------------------

(defface twiki-header1-face
  '((((class color) (background dark)) (:foreground "cyan"))
    ;; red4 is hardly different from black on windows.
    (((class color) (background light) (type mswindows)) (:bold t :foreground "red" :background "yellow"
:size 12pt))
    (((class color) (background light)) (:foreground "red4"))
    (((class grayscale) (background light)) (:foreground "LightGray" :bold t))
    (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
    (t (:bold t)))
  "Font Lock mode face used to highlight twiki keywords."
  :group 'font-lock-twiki-faces)

(defface twiki-header2-face
  '((((class color) (background dark)) (:foreground "cyan"))
    ;; red4 is hardly different from black on windows.
    (((class color) (background light) (type mswindows)) (:bold t :foreground "red" :background "moccasin"))
    (((class color) (background light)) (:foreground "red4"))
    (((class grayscale) (background light)) (:foreground "LightGray" :bold t))
    (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
    (t (:bold t)))
  "Font Lock mode face used to highlight twiki keywords."
  :group 'font-lock-twiki-faces)

(defface twiki-header3-face
  '((((class color) (background dark)) (:foreground "cyan"))
    ;; red4 is hardly different from black on windows.
(Continue reading)

Aidan Kehoe | 25 Jun 2006 09:33
Favicon

Re: RFC: Mailing list cleanup


 Ar an t-ochtú lá is fiche de mí Bealtaine, scríobh Stephen J. Turnbull: 

 > [...]

I’m in favour of all your proposals, with the exception of redirecting
xemacs-cvs to xemacs-patches. Your suggestion of filtering based on message
subjects basically recreates the existing situation for lots of people, who
are filtering based on which list a message comes from, with no benefit to
them or anyone else (there’s no actual proposal eliminate the
“commit-and-review” posts in what you write!). 

--

-- 
Santa Maradona, priez pour moi!

Vin Shelton | 28 Jun 2006 05:46
Picon
Favicon

Re: RFC: Mailing list cleanup

On 6/25/06, Aidan Kehoe <kehoea <at> parhasard.net> wrote:
>
>  Ar an t-ochtú lá is fiche de mí Bealtaine, scríobh Stephen J. Turnbull:
>
>  > [...]
>
> I'm in favour of all your proposals, with the exception of redirecting
> xemacs-cvs to xemacs-patches. Your suggestion of filtering based on message
> subjects basically recreates the existing situation for lots of people, who
> are filtering based on which list a message comes from, with no benefit to
> them or anyone else (there's no actual proposal eliminate the
> "commit-and-review" posts in what you write!).

I agree with Aidan.  Stephen, in general I lilke the simplifying you
are suggesting, but I would rather not have the CVS commit messages
sent to xemacs-patches.

Regards,
  Vin

Mike | 29 Jun 2006 00:53
Favicon

HTML Mode

I am having great difficulty getting HTML mode to work in XEmacs.  I have tried both html-helper-mode and
hm--html-menus and neither work for me.  I am running on Windows XP and my XEmacs version is 21.4.18.  If
someone could recommend a good HTML mode to implement and possibly some instructions, that would be a
great help.  It seems all of the instructions I have found on the web are geared towards Linux/UNIX and it
looks like there might be subtle differences but I don't know what they are.

Thanks!
-MikeD


Gmane