TextMate News

Anything vaguely related to TextMate and macOS.

TabMate (modeline support)

Håkan Waara has written a plug-in for TextMate which add modeline support.

What is a modeline?

Ever since the first day of UNIX, text editors such as vi and emacs would insert a line at the top of text files with options specific to that file. Options include things as what language the code was written in, the size of tabs, whether to use spaces instead of tabs, et cetera.

categories General

10 Comments

26 May 2006

by blalor

Very cool! Er, what parameters are supported?

26 May 2006

by Brian

blalor: “Options include things as what language the code was written in, the size of tabs, whether to use spaces instead of tabs, et cetera.” – from the link

27 May 2006

by Dan Kelley

A wonderful first step!

I think a lot of TM users will forward to seeing documentation of how to write the modelines (*) and learning how to get TM to obey the instructions in the modeline (**).

  • My examination of the code suggests an emacs-like convention will be used, which is certainly a good choice.

** My tests (of tab width) suggest that TM ignores the information. However, it could be that I had to do more than install the plugin and restart…

“modeline” isn’t really the right word for this. In Emacs, at least, the modeline is the line immediately above the minibuffer, at the bottom of the display that tells you which mode you’re in, what the buffer coding scheme is, whether you’ve changed the current buffer, and any information about minor modes. The Emacs documentation calls these ‘-*-‘ lines.

Also, this really needs support for the “File Local Variables” section at the bottom of the file, which is a much cleaner way to write file local variable definitions (for Emacs at least; I don’t know whether vi supports it or not).

One other thing to watch out for is that TextMate still doesn’t support separate tab size and indent settings (why not?) This is crazy because tabs have to be set to size 8 in order for code to be properly formatted if you e.g. ‘cat’ it (or, for that matter, ‘type’ it on a DOS system), but you have to be pretty crazy to want to use indents of that size…

04 June 2006

by Dan Kelley

I am becoming more and more convinced that TM would benefit from what one might call local bundles. These would not be the present “wide” (to coin a term) bundles, but rather something that works only locally. The mode line could be a place in which to provide a pointer to a local bundle.

For example, I write course notes in latex format, and I’d love to have a snippet that accepts dragged image files and sets up a “figure” environment. I also write web pages that have pointers to PDF files, and so I’d like to set up a drag command to write appropriate link code. But in neither case would I expect the sort of action that I desire to be the same as another person would desire, and so the solution is not to add general commands to the “wide” bundles. (For example, in some of my projects I merely add a link for a dropped file, but in other projects I add an element to a database, and then add a link.)

If I could add a commented line at the top of a file, e.g. of the form
% -- Bundle:myLocalBundle --
for a latex file, then that would be really terrific. It would make sense for TM to look locally in the present directory for the bundle, and then it would look more widely.

In this post I am sketching what I might call second-level TM functionality, since if the interface is set up cleanly, folks could use it for a great many things. At the moment, I’m speaking only of saving typing for common tasks, but this is not a small thing. After all, the unix system is very text-based, and therefore TM could act as a convenient tool extending as widely and as deeply as users wish.

Given a system for sharing these bundles, the community could get results that are quite nonlinear in the effort of an individual.

I’m very new to this idea, how do I invoke it? Perhaps my Textmate is outdated?!

Oh so it doesn’t include the first line for you it just sets properties when it reads those top lines for the formatting?

16 June 2006

by Dan Kelley

Right, Jon, the idea (as it exists in Emacs, anyway) is that the first line is a comment that is parsed by the text editor. As to how to make the plugin work, I’ve no idea, really. I’ve installed it but I do not know how to make it do anything … perhaps TextMate does not yet handle it yet. I am pretty sure that TM effort is mainly being directed at a new release, so perhaps modeline support will come with that. I hope so, since I would /love/ to have this.

My particular desire is to specify the fill column in a modeline. This is because I like to fill my paragraphs for my latex documents, and I also like to use “diff” to see changes … well, this becomes essentially impossible if I happen to resize a window and then refill, since then the whole paragraph is considered different, by “diff”.

01 November 2007

by Cody Ray

In response to Alastair, this corresponds to Emacs’ file local variables and Vim modeline (hence the name). You are correct in that Emacs does have a modeline, but it is for providing feedback about the current mode (that is, Emacs modeline is for output, whereas the Vim modeline is for input)

how to activate the plugin