Emacs settings

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:
  (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

(defun my-fill-sentence ()
  "Fill sentence separated by punctuation or blank lines."
  (let (start end)
      (re-search-backward "\\(^\\s-*$\\|[.?!]\\)" nil t)
      (skip-syntax-forward "^w")
      (setq start (point-at-bol)))
      (re-search-forward "\\(^\\s-*$\\|[.?!]\\)" nil t)
      (setq end (point-at-eol)))
      (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).

Last modified 10 years ago Last modified on 2009-07-05T08:19:16Z