Emacs major mode for Fvwm

I’ve spent (quite) some time writing an Emacs major mode for Fvwm as I thought the hilighting Fundamental mode provided was insufficient. Before everything I should thank Thomas Adam for giving me his fvmw.vim file, this has spared me the enormous task of having to look up every single Fvwm keyword in the manpages…

Now on with a disclaimer: this is a work in progress, I consider it to be useful, but there are bound to be errors and shortcomings in it. Also it’s very well possible that some keywords are wrongly categorized. I have left the expressions I used to generate the optimized regular expressions in the file so you can modify it if you feel so inclined, thouh I would appreciate it if you communitcated any errors you found to me.


  • syntax hilighting on the main Fvwm configuration file
  • hilights FvwmScript’s syntax

This is what it looks like: shot.


  • add more keywords
  • move wrongly placed keywords around
  • add functions to insert Fvwm functions definitions and add keybindings to them

You can grab it here, you should add something like the following to you .emacs configuration file.

[code];; Add the ~/.elisp directory to our emacs load-path
(setq load-path (append load-path (list “~/.elisp”)))
;; load the fvwm-mode so we can use it
(load “fvwm-mode”)

;; Automatically load fvwm mode for fvwm configuration files
(setq auto-mode-alist
(cons '(“config” . fvwm-mode)
(cons '(“FvwmApplet-” . fvwm-mode)
(cons '(“FvwmScript-” . fvwm-mode)

You should modify it depending on the name of your Fvwm configuration file (.fvwm2rc for older Fvwm versions) and the naming convention you use for FvwmScript files.

I hope it is at least of use to some people :slight_smile:

[EDIT]Added a screenshot
[EDIT]Forgot to show the code on how to include the file in your setup, fixed now :blush:

Heh. You’re welcome. It was really nothing… :slight_smile: I have to say though, whilst I am not an Emacs user, the colouration looks nice. :slight_smile: A job well done, tBD. :slight_smile:

– Thomas Adam.

This looks nice! I’ll definetly try it out, even though emacs isn’t my main editor, who knows, it might become after this :stuck_out_tongue_winking_eye:

Any chance at explaining to an emacs vargin what to do with this file? :blush: I just finished emergeing emacs and i have no idea whats going on lol.


pretty easy

after the first start, you got a dir named .xemacs or .emacs (depending which you use) in your ~

in this, there are usually 2 files, init.el and custom.el
init.el is for loading stuff on startup, custom.el for customizing look’n’feel (you can mix like you want, but that doesn’t make sense)

To use it, add code
(setq auto-mode-alist
(cons '(“config” . fvwm-mode)
(cons '(“FvwmApplet-” . fvwm-mode)
(cons '(“FvwmScript-” . fvwm-mode)
auto-mode-alist))))[/code] to init.el

It should automatically turn on when entering a fvwm-file named this way. If named different, hit M-x (first hold Meta/Alt and then press x) and type fvwm-mode (you can use tab like in a shell). If it still doesn’t work, M-x font-lock-mode (you might want to add code[/code] to init.el).

hope to have helped

PS: If I understood you wrong and you wanted to find out HOW this file works, please refer to an Emacs Lisp tutorial.

For some reason i didnt have either of thoses files so i made an init.el file and added

(load "PATH/TO/fvwm-mode.el")
(setq auto-mode-alist
         (cons '("config" . fvwm-mode)
         (cons '("FvwmApplet-" . fvwm-mode)
         (cons '("FvwmScript-" . fvwm-mode)

When i start xemacs down on the bottom of the window it says

Loading /home/voider/.xemacs/fvwm-mode.el...done

When i open an FvwmScript file i dont get any highlighing. Also im not sure where to add

;; Add the ~/.elisp directory to our emacs load-path
(setq load-path (append load-path (list "~/.elisp")))
;; load the fvwm-mode so we can use it
(load "fvwm-mode")

;; Automatically load fvwm mode for fvwm configuration files
(setq auto-mode-alist
      (cons '("config" . fvwm-mode)
       (cons '("FvwmApplet-" . fvwm-mode)
        (cons '("FvwmScript-" . fvwm-mode)

Also i dont have a ~/.elisp file. LOL im in all kinds of trouble.


As it seems to try to load the file I suppose you just haven’t pointed it to the right library path, so you’ll need to create a directory to store your elisp files in, which is ~/.elisp on my system, them place fvwm-mode.el in it.

Now in your .emacs file you can either do as Hun did and load one single elisp file by using:

(load "~/.elisp/fvwm-mode.el")

or you could make all files in that directory available by using:

(setq load-path (append load-path (list "~/.elisp")))

and then loading the mode you want:

(load "fvwm-mode")

After that you just have to associate Fvwm configuration files with fvwm-mode by using something like:

;; Automatically load fvwm mode for fvwm configuration files (setq auto-mode-alist (cons '("config" . fvwm-mode) (cons '("FvwmApplet-" . fvwm-mode) (cons '("FvwmScript-" . fvwm-mode) auto-mode-alist))))
Substitute the strings in double quotes with the appropriat values for your case, like “config” with “.fvwm2rc”.

Also, be sure to turn on syntax hilighting by putting this in your .emacs for GNU Emacs

(global-font-lock-mode 1)   

and this for XEmacs:

(setq font-lock-auto-fontify t)

HTH :slight_smile:

Thanks BlackDragon and Hun! Works great now. I guess ill be dumping vim and learing emacs :slight_smile:


I have released version 1.1 of fvwm-mode.el, it contains many fixes and improvements over the previous version. So what has changed?
[]I (nearly) totally rewrote the hilighting code, it’s now much easier to add keywords yourself, this however turned up a shortcoming in emacs versions prior to emacs 22, regexp-opt only supported a limited size for it’s arguments, so I had to create a workaround.[/:m]
[]I have added functions and keybindings to insert skeletons for Fvwm menu’s (C-c i m) and functions (C-c i f).[/:m]
[]Fixed another font-lock related bug that could create a nasty crash when font-lock wasn’t turned on at emacs start.[/:m][/list:u]
You can get the new version on my page for the project whick resides here.

I would like to hear from any bugs you might encounter, I’d also like to know if the mode still works properly in xemacs as I do some version checking in the file and I don’t know how xemacs will react to that… :confused:

Released 1.2 today, this release fixes some issues with the hilighting not being honoured when trying to comment out something containing doublequotes (thanks to Hun for reporting this bug).

The full changelog is in the file, which still can be found on my site here.

[EDIT]Did a bugfix release (1.2.1), this should fix another syntax-table issue, if you experience a bug where keywords get coloured in the middle of normal words (eg names of self defined functions) then this version should fix it. I just replaced the old version, so you should use the same link as before :slight_smile:
[EDIT]Did another bugfix release today (1.2.2), now syntax colouring should work perfectly (until I break it again, of course :wink:)

1.5.0 was released today with a lot of new features.

[list][]There is now a menu (which looks kind of broken in XEmacs :frowning: )[/:m]
[]You can now complete Fvwm keywords by pressing M-Tab (or Esc-Tab for those using alt-tab for other stuff)[/:m]
[]Quite some fixed in the syntax colouring[/:m]
[]You can now choose if you want the syntax to be hilighted in a case sensitive or a case insensitive way, Fvwm doesn’t care about style, but some of us do (well, I do :wink: )[/:m]
[]Also got rid of the size limitation on fvwm-execute-region, you can now execute arbitrarily large regions.[/:m][/list:u]
You can grab it at the link from the first post or from it’s project page.

Enjoy, and don’t hesitate to report bug or to post feature requests! :slight_smile:

Great! I have been asking for an Emacs mode in this forum long time ago.

This is really cool!

There are two small things:

  1. Each time when load a config, emacs tooks a few seconds to generating list of completions. It is a little bit slow.
  2. If indention can be done, it will be perfect.

Great job

I am aware of the slowness, it’s gone in emacs 22.x.x (CVS Emacs) though as that version supports hashmaps which dramatically speeds up the generation of the completion list. As an other option you could delay generating the completion list until you first use completion by putting the following in your ~/.emacs:

(setq fvwm-preload-completions nil)

Note however that you will then get the delay the first time you try to complete a word, which might be annoying as it interrupts your train of thought, I’m still trying to figure out a solution to make this faster…

Yeah, indentation is next on my todo list, unfortunately I don’t get much work on it done due to schoolwork being really over the limit atm… :frowning:

PS: I have released a 1.5.1 version which fixes a rather serious bug in fvwm-script-insert-skeleton.

PPS: I’m really glad at least some people seem to actively use it besides myself :smiley:

It’s been a longtime but now I’ve release another version, version 1.5.2, mostly bugfixes though.

[list][]Fixed the automatic timestamp insertion to always insert a timestamp if you save a changed file (it does nothing when the file wasn’t modified or you have undone all of the modifications since the last save)[/:m]
[]Fixed a font lock issue, FVWM doesn’t support end-of-line comments, only start-of-line comments but Fvwm Mode hilighted both, now it no longer does.[/:m][/list:u]
Things that still haven’t been fixed:
[list][]The slow creation of the completion list in XEmacs and Emacs 21.x this is the next item on my todo list…[/:m]
[]The broken menu appearance in XEmacs, which I suspect is more of an XEmacs issue anyway…[/:m][/list:u]
If you find any bugs or have any suggestions don’t hesitate to let me know :slight_smile:

I’ve just downloaded fvwm-mode.el, and it looks really nice! 8)

Just two small things:

  1. Line 3 of fvwm-mode.el says it’s release 1.5.1, but it’s 1.5.2, isn’t it?

  2. I have the following line in my config:

#default styles (fonts, window styles, window decorations,...)
Obviously, that’s a comment, but fvwm-mode thinks that #def is the html notation of a colour. So the first part of the line is displayed in that pinkish colour, the rest of the line is treated as normal code. (Well, well, why must I use such a tricky comment? :wink: )

Whatever, now I’m going to have fun with Emacs and Fvwm… :smiley:

Thanks for the bugreport :wink: I’ve fixed both issues for the next version, if you can’t wait that long you can grab a path here.

More font-lock issues are on the ‘ToFix list’ for the next release :slight_smile:

I hope you like what I have managed to hack together so far :slight_smile:

Hi, is there a highlight file for something like gedit or vim? I just don’t want to install such a big thing like emacs just for editing my fvwm config files.


I wouldn’t exactly call Vim small, but anyway. Vim higlights FVWM configuration files by default if they are called .fvwm2rc iirc :slight_smile:

I’ve been doing quite some work on fvwm-made lately resulting in much faster completion for Emacsen that support pcomplet. I also added a basic indentation function (off by default) and improved quite a bit on the module’s internal documentation (you should try C-h m sometime).

I’ve also written a small manual for it to get you up and running with most of the mode’s features (based on the latest devel release, so expect things to break if you’re using a release <= 1.5.2 and try to follow this manual). It’s by no means finshed, I at the very least should add ViktorGriph’s suggestion from the Fvwm Wiki.

Please post/mail/whatever all comments/suggestions/criticism you might have, all of it is more than appreciated! :smiley:

Oh, before I forget, the manual and mode can still be found here.

In section 4.2 you should point out the need of FvwmCommandS to be loaded by fvwm in order for command execution to work.