Debian Codegraph @

share/emacs/frama-c-dev.el

raw
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 ;; *** Mandatory Emacs settings for Frama-C developers ***
24 ;;
25 ;; If you are using 'frama-c-recommended.el', ignore these instructions
26 ;; (this file is already included by frama-c-recommended.el).
27 ;;
28 ;; Otherwise, do the following:
29 ;; 1. Include the directory containing this file in your Emacs load path;
30 ;; 2. Load this file as a library.
31 ;;
32 ;; You can do so by adding these lines in the beginning of your ~/.emacs file:
33 ;;
34 ;; (add-to-list 'load-path "path/to/this/file/")
35 ;; (load-library "frama-c-dev")
36 ;;
37 ;; tuareg and ocp-indent must be installed (e.g. via their OPAM packages).
38 ;;
39 ;; Note: 'frama-c-init.el' must also be in the load path.
40
41 (load-library "frama-c-init")
42
43 ;; ocp-indent should always be used
44 (safe-require ocp-indent
45 (add-hook 'tuareg-mode-hook (lambda ()
46 (setq indent-line-function 'ocp-indent-line)))
47 )
48
49 ;; Never indent Caml files using tabs
50 (defun no-tabs-hook ()
51 (setq indent-tabs-mode nil))
52 (add-hook 'tuareg-mode-hook 'no-tabs-hook)
53 (add-hook 'caml-mode-hook 'no-tabs-hook)
54
55 ;; Load Merlin (IDE features for OCaml, such as type info and code navigation)
56 (safe-require merlin
57 ;; Start merlin on ocaml files
58 (add-hook 'tuareg-mode-hook 'merlin-mode t)
59 (add-hook 'caml-mode-hook 'merlin-mode t)
60 ;; Enable auto-completion: definitions for company-mode
61 (set (make-local-variable 'company-backends) '(company-predictive))
62 (global-set-key (kbd "<C-tab>") 'company-complete-common)
63 (add-to-list 'company-backends 'merlin-company-backend)
64 ;; Enable company on merlin managed buffers
65 (add-hook 'merlin-mode-hook 'company-mode)
66 ;; Or enable it globally:
67 ;(add-hook 'after-init-hook 'global-company-mode)
68 ;; If you do not want to use company-mode, you can use auto-complete mode
69 ;; (setq merlin-use-auto-complete-mode 'easy)
70
71 ;; This hook avoids accidents with merlin's "C-c C-x", which often quits
72 ;; Emacs without confirmation when the user presses "C-x C-c" by accident.
73 ;; This hook is local to merlin-mode: Emacs will quit normally in non-ML
74 ;; files. It is also only displayed when the keyboard shortcut is used,
75 ;; but not when the user clicks the Close button on Emacs' window.
76 (defun confirm-before-save-kill-emacs ()
77 (interactive)
78 (let ((confirm-kill-emacs 'y-or-n-p))
79 (save-buffers-kill-emacs)))
80 (add-hook 'merlin-mode-hook
81 (lambda ()
82 (local-set-key (kbd "C-x C-c") 'confirm-before-save-kill-emacs)))
83 )