Version 4 (modified by 11 years ago) (diff) | ,
---|
Editor Configuration Snippets
Emacs
Suppose your personal preferred indentation style is dissimilar from the Pidgin indentation style, but you're a team player and you want to use Pidgin indentation when working on Pidgin/libpurple/whatever. These snippets can help you with that.
(c-add-style "pidgin" '((tab-width . 8) (c-tab-always-indent . t) (c-basic-offset . 8) (indent-tabs-mode . t))) (defun pidgin-c-mode-init () (if (or (posix-string-match "some/path/snippet" (buffer-file-name)) (posix-string-match "code/pidgin" (buffer-file-name))) (c-set-style "pidgin"))) (add-hook 'c-mode-hook 'pidgin-c-mode-init)
Make sure this hook runs after your normal setup hook, if your normal hook sets a style. The or is included just to show how to match multiple paths. You may perform the selection however you like, path snippets just happen to be useful given my filesystem organization. -- elb
If you're using Emacs23+, there's an arguably cleaner way to set up project-specific configuration via directory variables. All you need to do is to add the customization to
.dir-locals.el
file to the root dir of your pidgin clone and it will be applied to all files below that dir. For example, given thepidgin
style definition above, my setup is as follows (additionalc++-mode
config is necessary if you associate*.h
files with it, like I do):((c-mode . ((c-file-style . "pidgin"))) (c++-mode . ((c-file-style . "pidgin") (mode . c))))-- immerrr
VIM
Regardless of what the indentation style and tab width convention is in the rest of the tree, the ChangeLog and NEWS files should always use a tab width of 8. This may not be the right or best .vimrc snippet to do this, but it works. Insert this snippet into .vimrc (.gvimrc for you GUI addicts) after your existing tab configuration:
autocmd! BufReadPost,BufNewFile */ChangeLog call <SID>ChangeLogNewsOptions() autocmd! BufReadPost,BufNewFile */NEWS call <SID>ChangeLogNewsOptions() function! <SID>ChangeLogNewsOptions() " These settings affect ChangeLog and NEWS files only setlocal sw=8 setlocal tabstop=8 endfunction
It's ugly, but it works. -- rekkanoryo