Jose Abilio Oliveira Matos <[EMAIL PROTECTED]> writes:

| On Fri, Sep 01, 2000 at 10:03:39AM +0100, Angus Leeming wrote:
| > Is there anybody out there who uses emacs to edit the code and who has their
| > .emacs file set up to use tab-indenting correctly? 
| > 
| > I currently indent using the default 2 spaces.
| 
|   I have added a hook to my .emacs file. I barely know (emacs-)lisp to read
| such a thing. But, hey, it works for me.
|   If you want to you can add other options...
| 
| (add-hook 'c-mode-hook
|   (function (lambda ()
|                 (setq c-basic-offset 8))))
|                
| (setq c++-mode-hook c-mode-hook)
| 
| Comments from any expert? :-)

don't do it like this.

nicer with:

;;; Common hook
(defun my-c-mode-common-hook ()
  ;; Set return Style
  (local-set-key [return] 'newline-and-indent)
  (local-set-key [S-return] 'newline)
  (c-set-style "CC-MODE")
  (setq compile-command "make -k")
  )
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
                          
;; C mode hook
(defun my-c-mode-hook ()
  ;; Style parameters
  (setq c-basic-offset 2
        c-continued-statement-offset 2
        make-backup-files t)
  )
(add-hook 'c-mode-hook 'my-c-mode-hook)
                      
;; C++ mode hook
(defun my-c++-mode-hook ()
  ;; Style parameters
  (setq c-basic-offset 8)
  (imenu-add-to-menubar "Index")
  )
(add-hook 'c++-mode-hook 'my-c++-mode-hook)
                     
        Lgb

Reply via email to