Emacs modes for bending and bison or removing auto-indentation for these modes?

Emacs does a poor job of auto-indenting in Flex and Bison. In fact, it does not seem to support flexible mode. So how does the emacs user handle this? I like VIm, but I would prefer not to switch, because I'm much faster and more convenient in Emacs.

I had a third elisp module for Bison a few months ago, but when its indentation is broken, it will never be fixed. In short, it was a bad hack.

Or is there a way that I can disable auto-indentation for .l and .y files (so clicking will indent one)? How would I also change this elisp setting for emacs only?

A good and short guide to elisp is also very helpful. I would not mind spending a few days writing my own ways of bending and bison, if I had the correct documentation.

+7
indentation flex-lexer emacs bison elisp
source share
2 answers

Emacs selects the main mode mainly based on the file name extension. .l is an extended extension: some use it for lex, others use lisp (and there are several other rarer uses). Emacs associates .l with lisp and .lex with lex (for which it uses C mode).

If the .l files you work with are more often than lex than lisp, you can change which .l files are associated with the following line in .emacs:

 (add-to-list 'auto-mode-alist '("\\.l\\'" . c-mode)) 

You can also declare inside the file which mode you want Emacs to use when it opens the file. Put the following snippet on the first line of the file (usually in a comment):

 -*-mode: c-mode-*- 

This is a more general function offering other syntaxes and other features; See the "File Variables" section of the Emacs manual for more information.


If you want to get started with Emacs lisp, read Emacs lisp intro (which can be included with your Emacs or OS). After you have worked a bit with the basics of the language, you can skip to the chapter on modes in the Emacs lisp reference manual.

+3
source share

Extra tip: you can decide what you want, this is the general behavior of Emacs - what it uses when it does not have a special mode for the file format. This is called the main mode in emacs lingo: you can request it on the fly using Mx fundamental-mode or put -*- mode: fundamental -*- on the first line of the file or configure auto-mode-alist as follows:

 (add-to-list 'auto-mode-alist '("\\.l\\'" . fundamental-mode)) 

Another thing you can try might be indented-text-mode (possibly with auto indented-text-mode turned off).

+1
source share

All Articles