| 1 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2 |
; ; |
| 3 |
; This file is part of Frama-C. ; |
| 4 |
; ; |
| 5 |
; Copyright (C) 2007-2022 ; |
| 6 |
; CEA (Commissariat à l'énergie atomique et aux énergies ; |
| 7 |
; alternatives) ; |
| 8 |
; ; |
| 9 |
; you can redistribute it and/or modify it under the terms of the GNU ; |
| 10 |
; Lesser General Public License as published by the Free Software ; |
| 11 |
; Foundation, version 2.1. ; |
| 12 |
; ; |
| 13 |
; It is distributed in the hope that it will be useful, ; |
| 14 |
; but WITHOUT ANY WARRANTY; without even the implied warranty of ; |
| 15 |
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; |
| 16 |
; GNU Lesser General Public License for more details. ; |
| 17 |
; ; |
| 18 |
; See the GNU Lesser General Public License version 2.1 ; |
| 19 |
; for more details (enclosed in the file licenses/LGPLv2.1). ; |
| 20 |
; ; |
| 21 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 22 |
|
| 23 |
;; *** Recommended Emacs settings for Frama-C developers *** |
| 24 |
;; |
| 25 |
;; This file should be loaded in the beginning of your .emacs file. |
| 26 |
;; |
| 27 |
;; 1. Include the directory containing this file in your Emacs load path; |
| 28 |
;; 2. Load this file as a library. |
| 29 |
;; |
| 30 |
;; You can do so by adding these lines in the beginning of your ~/.emacs file: |
| 31 |
;; |
| 32 |
;; (add-to-list 'load-path "path/to/this/file/") |
| 33 |
;; (load-library "frama-c-recommended") |
| 34 |
;; |
| 35 |
;; Note: 'frama-c-init.el' and 'frama-c-dev.el' must also be in the load path. |
| 36 |
|
| 37 |
;; ***** Initialization and configuration settings ***** |
| 38 |
(load-library "frama-c-init") |
| 39 |
(load-library "frama-c-dev") |
| 40 |
|
| 41 |
;; MELPA helps with the installation of several Emacs packages |
| 42 |
(safe-require package |
| 43 |
(add-to-list 'package-archives |
| 44 |
'("melpa-stable" . "https://stable.melpa.org/packages/")) |
| 45 |
) |
| 46 |
|
| 47 |
;; ***** OCaml settings ***** |
| 48 |
;; |
| 49 |
;; Load Tuareg (OCaml mode for Emacs) if installed |
| 50 |
(safe-load-library "tuareg-site-file") |
| 51 |
|
| 52 |
;; ***** End of OCaml settings ***** |
| 53 |
|
| 54 |
|
| 55 |
;; ***** Miscellaneous settings ***** |
| 56 |
;; |
| 57 |
;; fill-column-indicator adds a vertical line to help enforce the |
| 58 |
;; 80-characters-per-line rule |
| 59 |
;; Note: in some specific configurations (e.g. KDE, maximized window), |
| 60 |
;; this library may interfere with window redrawing when using e.g. some |
| 61 |
;; merlin functions. Try deactivating this extension if you have problems. |
| 62 |
(safe-require fill-column-indicator |
| 63 |
(setq-default fill-column 80) |
| 64 |
(setq fci-rule-color "#8f8f8f") |
| 65 |
(add-hook 'tuareg-mode-hook 'fci-mode t) |
| 66 |
) |
| 67 |
|
| 68 |
;; Disable insertion of tabs for indentation everywhere but in Makefiles |
| 69 |
;; (Emacs always inserts tabs in Makefiles, regardless of this option) |
| 70 |
(setq-default indent-tabs-mode nil) |
| 71 |
|
| 72 |
;; Disable overwrite mode, which is rarely used nowadays and can be annoying |
| 73 |
;; when enabled accidentally |
| 74 |
(global-unset-key [insert]) |
| 75 |
|
| 76 |
;; redo+ (needs to be installed via ELPA) enables a somewhat "standard" |
| 77 |
;; undo/redo mechanism, similar to most modern applications; |
| 78 |
;; these key settings bind Ctrl+Z and Ctrl+Shift+Z to undo/redo, respectively |
| 79 |
(safe-require redo+ |
| 80 |
(global-set-key (kbd "C-z") 'undo-only) |
| 81 |
(global-set-key (kbd "C-S-z") 'redo) |
| 82 |
; Avoid accidental minimization when pressing pressing C-z just after a 'C-x' |
| 83 |
(global-unset-key (kbd "C-x C-z")) |
| 84 |
) |
| 85 |
|
| 86 |
;; This hook removes trailing whitespace, which should always be avoided |
| 87 |
;; Note that, if applied to an existing file with trailing whitespace, this |
| 88 |
;; will remove it in *every* line. This can generate large diffs and is not |
| 89 |
;; always ideal. For new files, however, this should be on by default. |
| 90 |
;(add-hook 'before-save-hook 'delete-trailing-whitespace) |
| 91 |
|
| 92 |
;; Require a final newline in a file in order to avoid confusing some tools |
| 93 |
;; (also helps 'git diff') |
| 94 |
(setq require-final-newline t) |
| 95 |
|
| 96 |
;; whitespace-mode, when activated, displays several kinds of possibly |
| 97 |
;; undesirable whitespace. |
| 98 |
;; The settings below enable display of tabs, empty lines at the end of |
| 99 |
;; the file, and the most important one: trailing spaces |
| 100 |
;; It is also possible to use whitespace-mode to highlight long lines |
| 101 |
;; (over 80 characters, or the width that you prefer), but they are |
| 102 |
;; not activated in these settings. |
| 103 |
(global-whitespace-mode 1) |
| 104 |
(setq whitespace-style '(face empty tabs trailing)) |
| 105 |
|
| 106 |
;; Terminal Settings |
| 107 |
;; (related to colors in compilation mode; see MR frama-c/frama-c!300) |
| 108 |
(safe-require ansi-color |
| 109 |
(defun my-colorize-compilation-buffer () |
| 110 |
(ansi-color-apply-on-region (point-min) (point-max)) |
| 111 |
(goto-char (point-min)) |
| 112 |
(while (search-forward "\x0d" nil t) |
| 113 |
(delete-region (line-beginning-position) (point))) |
| 114 |
(goto-char (point-min)) |
| 115 |
(while (search-forward "\x1b[K" nil t) |
| 116 |
(replace-match "")) |
| 117 |
(goto-char (point-min)) |
| 118 |
) |
| 119 |
(add-hook 'compilation-filter-hook 'my-colorize-compilation-buffer) |
| 120 |
) |