Re: emacs indenting howto

From: Andi Kleen
Date: Wed Jan 21 2009 - 04:13:28 EST


On Wed, Jan 21, 2009 at 11:49:29AM +0300, Dan Carpenter wrote:
> On Wed, 21 Jan 2009, Andi Kleen wrote:
> >Dan Carpenter <error27@xxxxxxxxx> writes:
> >
> >>I don't think emacs understands tilda expansion. It didn't work for me.
> >
> >It does when you use expand-file-name
> >
> >-Andi
>
> No problem. Here is the updated patch.

FWIW this is what I use. It turns on linux-c-mode for anything with
linux in the path name. While that occasionally mis-hits, it only
does seldom.

(defvar is-emacs20 (if (string-match "2[0-9]\\." emacs-version) t nil))

(defun linux-c-mode ()
"C mode with adjusted defaults for use with the Linux kernel."
(interactive)
;; grr - still does not seem to work properly
(make-variable-buffer-local 'tab-width)
(make-variable-buffer-local 'c-basic-offset)
(c-mode)
; (if window-system
; (change-mode 'passive))
(make-variable-buffer-local 'version-control)
(setq version-control 't)
(c-set-style (if is-emacs20 "linux" "K&R"))
(setq tab-width 8)
(setq c-basic-offset 8))

(push '(".*/linux.*/.*\\.[ch]\\'" . linux-c-mode) auto-mode-alist)
(push '(".*/linux.*/.*\\.[ch]\\(-[a-z]+\\)?\\'" . linux-c-mode) auto-mode-alist)

I also have that one but it's probably obsolete by now:

(defun reiserfs-c-mode ()
"Hide silly ifdefs for reiserfs"
(interactive)
(linux-c-mode)
(setq hide-ifdef-initially t)
(hide-ifdef-mode 1)
(hide-ifdef-define '__KERNEL__)
(hide-ifdef-define 'REISERFS_PREALLOCATE)
(hide-ifdef-undef 'CONFIG_REISERFS_CHECK)
(hide-ifdef-undef 'REISERFS_CHECK))

(push '(".*/linux.*/fs/reiserfs/[^/]+\\.[ch]\\'" . reiserfs-c-mode) auto-mode-alist)


-Andi

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/