|
|
|
|
|
To get an indentation style consistent with the project coding conventions in the Emacs editor, include the following in the .emacs file in your home directory:
|
|
|
|
|
|
```
|
|
|
(defun my-c-mode-common-hook ()
|
|
|
;; customizations of c-mode and related modes for Cloudy
|
|
|
;; could use c++ mode, but this would miss .h files
|
|
|
;; see also: http://student.northpark.edu/pemente/emacs_tabs.htm
|
|
|
(setq tab-width 3)
|
|
|
(c-set-style "linux")
|
|
|
(setq c-basic-offset 3)
|
|
|
(setq tab-stop-list '(3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69))
|
|
|
)
|
|
|
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
|
|
|
```
|
|
|
|
|
|
The default whole-paragraph wrap style in Emacs makes it easy to keep lines to within a reasonable width, but hard to identify changes under version control.
|
|
|
To define a wrap command to act on individual sentences, try the following (from [a Stack Overflow query](http://stackoverflow.com/questions/539984/how-do-i-get-emacs-to-fill-sentences-but-not-paragraphs)
|
|
|
```
|
|
|
(defun my-fill-sentence ()
|
|
|
"Fill sentence separated by punctuation or blank lines."
|
|
|
(interactive)
|
|
|
(let (start end)
|
|
|
(save-excursion
|
|
|
(re-search-backward "\\(^\\s-*$\\|[.?!]\\)" nil t)
|
|
|
(skip-syntax-forward "^w")
|
|
|
(setq start (point-at-bol)))
|
|
|
(save-excursion
|
|
|
(re-search-forward "\\(^\\s-*$\\|[.?!]\\)" nil t)
|
|
|
(setq end (point-at-eol)))
|
|
|
(save-restriction
|
|
|
(narrow-to-region start end)
|
|
|
(fill-paragraph nil))))
|
|
|
|
|
|
(global-set-key (kbd "M-j") 'my-fill-sentence)
|
|
|
```
|
|
|
Then typing M-j will fill sentences (as opposed to M-q for paragraphs). |