1 | |
---|
2 | ;;----------------------------------------------------------- |
---|
3 | ;; Copyright Christian Arnault LAL-Orsay CNRS |
---|
4 | ;; arnault@lal.in2p3.fr |
---|
5 | ;; See the complete license in cmt_license.txt "http://www.cecill.info". |
---|
6 | ;;----------------------------------------------------------- |
---|
7 | |
---|
8 | ;;---------------------------------- |
---|
9 | ;; Local organization |
---|
10 | ;; |
---|
11 | (defvar my-xemacs-dir |
---|
12 | (expand-file-name "~/.xemacs") |
---|
13 | "The directory where all the XEmacs configuration (and more) goes." |
---|
14 | ) |
---|
15 | |
---|
16 | (setq load-path |
---|
17 | (append |
---|
18 | (list my-xemacs-dir) |
---|
19 | load-path |
---|
20 | )) |
---|
21 | |
---|
22 | |
---|
23 | ;;---------------------------------- |
---|
24 | ;; Local key binding |
---|
25 | ;; |
---|
26 | ;; The local prefix for globally available commands: C-b |
---|
27 | ;; (just like C-x and C-c for xemacs' defaults) |
---|
28 | (global-unset-key '[(control b)]) |
---|
29 | |
---|
30 | (defun my-coding-keys (map) |
---|
31 | "Sets the key bindings which shall be available in all programming |
---|
32 | languages. Argument MAP is the local keymap (e.g. cmt-mode-map)." |
---|
33 | (define-key map '[(control b) (\;)] 'my-comment-region-or-line) |
---|
34 | (define-key map '[(control b) (\:)] 'my-uncomment-region-or-line) |
---|
35 | ) |
---|
36 | |
---|
37 | ;;---------------------------------- |
---|
38 | ;; Comment in and out |
---|
39 | ;; |
---|
40 | (defun my-comment-region-or-line () |
---|
41 | (interactive) |
---|
42 | (let ((beg 0) |
---|
43 | (end 0)) |
---|
44 | (if (region-exists-p) |
---|
45 | (setq beg (region-beginning) |
---|
46 | end (region-end)) |
---|
47 | (save-excursion |
---|
48 | (beginning-of-line) |
---|
49 | (setq beg (point)) |
---|
50 | (forward-line) |
---|
51 | (setq end (point)))) |
---|
52 | (comment-region beg end))) |
---|
53 | |
---|
54 | (defun my-uncomment-region-or-line () |
---|
55 | (interactive) |
---|
56 | (let ((beg 0) |
---|
57 | (end 0)) |
---|
58 | (if (region-exists-p) |
---|
59 | (setq beg (region-beginning) |
---|
60 | end (region-end)) |
---|
61 | (save-excursion |
---|
62 | (beginning-of-line) |
---|
63 | (setq beg (point)) |
---|
64 | (forward-line) |
---|
65 | (setq end (point)))) |
---|
66 | (comment-region beg end -1))) |
---|
67 | |
---|
68 | |
---|
69 | ;;---------------------------------- |
---|
70 | ;; Load CMT mode |
---|
71 | ;; |
---|
72 | (autoload 'cmt-mode "cmt-mode" "CMT requirements file editing mode." t) |
---|
73 | |
---|
74 | (setq auto-mode-alist |
---|
75 | (append (list (cons "requirements$" 'cmt-mode)) |
---|
76 | auto-mode-alist)) |
---|
77 | |
---|
78 | (add-hook 'cmt-mode-hook |
---|
79 | '(lambda () |
---|
80 | (turn-on-font-lock) |
---|
81 | (my-coding-keys cmt-mode-map) |
---|
82 | )) |
---|