← Back to team overview

dolfin team mailing list archive

Re: [noreply@xxxxxxxxxxxxx: [Branch ~dolfin-core/dolfin/error-control] Rev 5211: Add documentation (I think) and use the peculiar dolfin convention for]

 

On Sunday November 7 2010 14:13:42 Anders Logg wrote:
> On Sun, Nov 07, 2010 at 11:04:31PM +0100, Kristian Ølgaard wrote:
> > On 7 November 2010 21:41, Marie Rognes <meg@xxxxxxxxx> wrote:
> > > On 07. nov. 2010 21:27, Kristian Ølgaard wrote:
> > >> On 7 November 2010 11:59, Marie E. Rognes <meg@xxxxxxxxx> wrote:
> > >>> On 6. nov. 2010, at 00:17, Anders Logg <logg@xxxxxxxxx> wrote:
> > >>>> It is not peculiar, it's just the right way to brace!
> > >>> 
> > >>> No, it isn't.
> > >> 
> > >> Yes, it is!
> > >> 
> > >> http://www.fenicsproject.org/doc/styleguides/codestyleguides.html#plac
> > >> ement-of-brackets-and-indent-style
> > >> 
> > >> :)
> > >> 
> > >> Kristian
> > > 
> > > I fully agree that it is the DOLFIN way. Hence, my previous comment on
> > > adapting to the DOLFIN convention. However, that does not mean that it
> > > is not "peculiar" or that it is the right way. At least, it is not the
> > > true way ;)
> > 
> > I tend to disagree, I like BSD/Allman best.
> > 
> > > However, more importantly than discussing religion: how do you get your
> > > emacs to get the indentation right?
> > 
> > I don't know since I just use gedit, occasionally vi (we can disagree
> > on that too ;) ), but I found this page:
> > 
> > http://www.emacswiki.org/emacs/IndentingC
> > 
> > hope it helps.
> 
> Here's some useful Emacs stuff:
> 
> ;; --- Indentation of braces for C++ ---
> 
> (defun my-c++-mode-hook ()
>   (c-set-offset 'substatement-open 0))
> (add-hook 'c++-mode-hook 'my-c++-mode-hook)
> 
> ;; --- Indentation of braces for C ---
> 
> (defun my-c-mode-hook ()
>   (c-set-offset 'substatement-open 0))
> (add-hook 'c-mode-hook 'my-c-mode-hook)
> 
> ;; --- Convert all tabs to spaces ---
> (setq-default indent-tabs-mode nil)
> 
> ;; Update time stamp for DOLFIN source code
> (setq
>   time-stamp-start "Last changed:\\\\? "; start of pattern
>   time-stamp-end "\\\\?\n"              ; end of pattern
>   time-stamp-active t                   ; do enable time-stamps
>   time-stamp-line-limit 20              ; check first 10 lines
>   time-stamp-format "%04y-%02m-%02d")   ; date format
> 
> ;; Update timestamp before saving
> (add-hook 'before-save-hook 'time-stamp)
> 
> ;; Remove trailing whitespaces before saving
> (add-hook 'before-save-hook 'delete-trailing-whitespace)
> 
> ;; turn on interactive do
> (require 'ido)
> (ido-mode t)

If you add the time stamp stuff in your local c++ mode function you can add 
one for Python code too. 

Something like:

;; Local Python mode
(defun local-python-mode-hook ()
  (setq outline-regexp "[^ \t\n]\\|[ \t]*\\(def[ \t]+\\|class[ \t]+\\)")
  ; enable our level computation
  (setq outline-level 'py-outline-level)
  ; do not use their \C-c@ prefix, too hard to type. Note this overides
  ;some python mode bindings
  (setq outline-minor-mode-prefix "\C-c")
  ; turn on outline mode
  (outline-minor-mode t)
  ; initially hide all but the headers
  ;(hide-body)
  (show-paren-mode 1)

  ; Add information to time-stamp function
  (setq
   time-stamp-start "__date__ = .* -- "; start of pattern
   time-stamp-end "\""                   ; end of pattern
   time-stamp-active t                   ; do enable time-stamps
   time-stamp-line-limit 20              ; check first 20 lines
   time-stamp-format "%04y-%02m-%02d")   ; date format
)

; Local C++ mode
(defun local-c++-mode-hook ()
  ; Add information to time-stamp function
  (setq
   time-stamp-start "Last changed: "; start of pattern
   time-stamp-end "\n"              ; end of pattern
   time-stamp-active t                   ; do enable time-stamps
   time-stamp-line-limit 20              ; check first 20 lines
   time-stamp-format "%04y-%02m-%02d")   ; date format
)

;; Load local modes
(add-hook 'python-mode-hook 'local-python-mode-hook)
(add-hook 'c++-mode-hook 'local-c++-mode-hook)



> --
> Anders
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help   : https://help.launchpad.net/ListHelp



Follow ups

References