(if you're wondering what you're doing here, jed is a hardcore text based editor for programmers)

Thanks to fellow Jed user and hacker Ullrich Horlacher I can now have local settings per directory.

I personally prefer 2 spaces in my Javascript. And thankfully most projects I work on agrees with that standard. However, I have one Mozilla project I work on which uses 4 spaces for indentation. So, what I've had to get used to to is to edit my ~/.jedrc every time I switch to work on that particular project. I change: variable C_INDENT = 2; to variable C_INDENT = 4; and then back again when switching to another project.

No more of that. Now I just add a file into the project root like this:

$ cd dev/airmozilla
$ cat .jed.sl
variable C_INDENT = 4;

And whenever I work on any file in that tree it applies the local override setting.

Here's how you can do that too:

First, put this code into your <your jed lib>/defaults.sl: (on my OSX, the jed lib is /usr/local/Cellar/jed/0.99-19/jed/lib/)

% load .jed.sl from current or parent directories
% but only if the user is the same
define load_local_config() {
  variable dir = getcwd();
  variable uid = getuid;
  variable jsl,st;
  while (dir != "/" and strlen(dir) > 1) {
    st = stat_file(dir);
    if (st == NULL) return;
    if (st.st_uid != uid) return;
    jsl = dir + "/.jed.sl";
    st = stat_file(jsl);
    if (st != NULL) {
      if (st.st_uid == uid) {
    dir = path_dirname(dir);

Then add this to the bottom of your ~/.jedrc:

define startup_hook() {
  load_local_config(); % .jed.sl

Now, go into a directory where you want to make local settings, create a file called .jed.sl and fill it to your hearts content!



Whow! That looks pretty oldschool! O_o
But is it actually?

This indentation thing.. We agreed on tabs here. So everyone can have his own settings how wide the indentation should be. Actualy I think as this is a style-thing this should not be part of the code anyway. Code should always be shown and styled the way you want it at the frontend! But: most functional behind that on the backend side.

So for instance tabbed indentation could easily be shown as spaces in your editor as well. And when you press Ctrl+S it becomes tabs again in the file. That'd be cool.... *dream*...

Peter Bengtsson

It's strange some sometimes even senior respectable developers prefer tabs. I just don't see the benefit considering all the potential problems with it.


Well... no shit: I'd love to be enlightened by you what the problem with tabs is and the benefits of spaces! :D

On the other hand: wouldn't you agree that everybody should see it in the way he likes it? And in the code its like whatever is best for the code..

Peter Bengtsson

No I would not necessarily agree. End of flame war.

Your email will never ever be published.

Related posts