emacs indenting howto
I don't think emacs understands tilda expansion. It didn't work for me.
regards,
dan carpenter
Documentation/CodingStyle +1 -1
@@ -488,7 +488,7 @@ (let ((filename (buffer-file-name))) ;; Enable kernel mode for the appropriate files (when (and filename - (string-match "~/src/linux-trees" filename)) + (string-match "/path/to/linux-trees" filename)) (setq indent-tabs-mode t) (c-set-style "linux") (c-set-offset 'arglist-cont-nonempty
Quoted 1 line · Dan Carpenter
I don't think emacs understands tilda expansion. It didn't work for me.
It does when you use expand-file-name
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Quoted 7 lines · Andi Kleen
Quoted 1 line · Dan Carpenter
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.
regards,
dan carpenter
Documentation/CodingStyle +2 -1
@@ -488,7 +488,8 @@ (let ((filename (buffer-file-name))) ;; Enable kernel mode for the appropriate files (when (and filename - (string-match "~/src/linux-trees" filename)) + (string-match (expand-file-name "~/src/linux-trees") + filename)) (setq indent-tabs-mode t) (c-set-style "linux") (c-set-offset 'arglist-cont-nonempty
Quoted 10 lines · Dan Carpenter
Quoted 7 lines · Andi Kleen
Quoted 1 line · Dan Carpenter
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