Feeds:
Posts
Comments

Posts Tagged ‘c++ styles’

Useful Blog Comments

Nachopp demonstrates some emacs lisp that inserts a commonly used find command in a shell buffer. And Ian Eure has a great follow-up comment which demonstrates the more typical way of defining emacs lisp functions; talks about alternatives such as abbrev mode and yasnippet and finally mentions the best solution, the built-in rgrep.

Defining C++ styles

David Ha has a gallery of some of the built-in C++ styles. None of the styles suit me exactly so I have accreted a fair amount of C++ configuration code over the years. I must admit, I haven’t audited for ages so I’m not sure which bits are necessary and which are not.

(defconst *my-cc-style*
  '((c-basic-offset . 4)
    (c-comment-only-line-offset . 0)
    (c-hanging-braces-alist . ((brace-list-open)
                               (brace-entry-open)
                               (substatement-open after)
                               (block-close . c-snug-do-while)))
    (c-cleanup-list . (brace-else-brace))
    (c-offsets-alist . ((statement-block-intro . +)
                        (knr-argdecl-intro     . 0)
                        (substatement-open     . 0)
                        (substatement-label    . 0)
                        (innamespace           . 0)
                        (case-label            . +)
                        (statement-cont        . +)))))

(defun my-c-initialization-hook ()
  (define-key c-mode-base-map "\C-m" 'c-context-line-break)
  (define-key c-mode-base-map (kbd "RET") 'newline-and-indent)
  (define-key c-mode-base-map [f7] 'run-compile))

(add-hook 'c-initialization-hook 'my-c-initialization-hook)
(setq c-offsets-alist '((member-init-intro . ++)))

(c-add-style "PERSONAL" *my-cc-style*)

(defun my-c-mode-common-hook ()
  (c-set-style "PERSONAL")
  (setq tab-width 4
        indent-tabs-mode nil
        c-hungry-delete-key t)
  (c-toggle-auto-newline 1))

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

The most useful commands for finding out which of the variables to set are C-c C-o (c-set-offset) and C-c C-s (c-show-syntactic-information)

This is kinda interesting where Ronnie Collinson (from the NotThinking blog)
removes the *compilation* buffer if the compile is successful. It isn’t something I personally would use as I like the feedback, but I wasn’t previously thinking about compilation-finish-functions and I have a few ideas of things I would like to run after a successful compile.

Perennial Emacs Blog Topics

There are a few perennial blog topics in the emacs world – I mentioned a smooth scrolling post in my links from 2009/17 and here is Da Zhang’s take (does anyone like the default behaviour by the way?). I included a link to a post on the incredibly useful mark ring in emacs-links-2009-09 and here is another from yesterday.

Proposed solutions – fix the smooth scrolling behaviour so it works nicely out of the box and… well, perhaps blogs are not a great way of educating the masses after all. Pity.

Read Full Post »

Follow

Get every new post delivered to your Inbox.