Fix GLPK linking (#7357)
[cvc5.git] / contrib / cvc-devel.el
1 ;;;; Add to your ~/.emacs the following lines:
2 ;;;;
3 ;;;; (load-path "/full/path/to/this/file")
4 ;;;; (require 'cvc-devel)
5 ;;;;
6 ;;;; If you want to modify the key binding for inserting the comment,
7 ;;;; add also something like this:
8 ;;;;
9 ;;;; (setq cvc-devel-comment-key "\M-/")
10 ;;;;
11
12 (defvar cvc-devel-comment-key "\C-c\C-h"
13 "The hot key binding to insert an appropriate comment in C++ header
14 in CVC code")
15
16 (require 'cc-mode)
17 (add-to-list 'c++-mode-hook
18 '(lambda ()
19 (local-set-key cvc-devel-comment-key
20 'insert-comment-template)))
21
22 (defun insert-comment-template ()
23 "Insert a comment template into C++ file in the CVC style. The
24 comment is different depending on where it is inserted. For example,
25 inserting it in the empty file will produce a file comment, a class
26 comment will be inserted before a class definition, and so on."
27 (interactive)
28 ; Check for macro
29 (cond
30 ((catch 'not-macro
31 (progn
32 (set-mark (point))
33 (cond ((not (search-forward "#define" nil t))
34 (throw 'not-macro t)))
35 (beginning-of-line)
36 (cond ((not (= (mark) (point)))
37 (progn
38 (goto-char (mark))
39 (throw 'not-macro t))))
40 ; It's a macro: insert the comment template
41 (forward-char 7)
42 (re-search-forward "[^ ]")
43 (backward-char)
44 (set-mark (point))
45 (re-search-forward " \\|(\\|^")
46 (backward-char)
47 (copy-region-as-kill (mark) (point))
48 (beginning-of-line)
49 (insert-string
50 "/*****************************************************************************/
51 /*!
52 *\\def ")
53 (yank)
54 (insert-string "
55 *
56 * Author: ")
57 (insert-string (user-full-name))
58 (insert-string "
59 *
60 * Created: ")
61 (insert-string (current-time-string))
62 (insert-string "
63 *
64 *
65 */
66 /*****************************************************************************/
67 ")
68 (forward-line -3)
69 (search-forward "* ")
70 ()
71 )
72 )
73 (cond
74 ((catch 'not-function
75 (progn
76 (set-mark (point))
77 (cond ((not (search-forward "(" nil t))
78 (throw 'not-function t)))
79 (beginning-of-line)
80 (cond ((not (= (mark) (point)))
81 (progn
82 (goto-char (mark))
83 (throw 'not-function t))))
84 ; It's a function: insert the comment template
85 (search-forward "(")
86 (re-search-backward "[^ ] *(")
87 (forward-char)
88 (set-mark (point))
89 (re-search-backward " \\|^.")
90 (re-search-forward "[^ ]")
91 (backward-char)
92 (copy-region-as-kill (mark) (point))
93 (beginning-of-line)
94 (insert-string
95 "/*****************************************************************************/
96 /*!
97 * Function: ")
98 (yank)
99 (insert-string "
100 *
101 * Author: ")
102 (insert-string (user-full-name))
103 (insert-string "
104 *
105 * Created: ")
106 (insert-string (current-time-string))
107 (insert-string "
108 *
109 *
110 */
111 /*****************************************************************************/
112 ")
113 (forward-line -3)
114 (search-forward "* ")
115 ()
116 )
117 )
118 (cond
119 ((catch 'not-class
120 (progn
121 (set-mark (point))
122 (cond ((not (search-forward "class" nil t))
123 (throw 'not-class t)))
124 (beginning-of-line)
125 (cond ((not (= (mark) (point)))
126 (progn
127 (goto-char (mark))
128 (throw 'not-class t))))
129 ; It's a class definition: insert the comment template
130 (forward-char 5)
131 (re-search-forward "[^ ]")
132 (backward-char)
133 (set-mark (point))
134 (re-search-forward "^\\| \\|{")
135 (backward-char)
136 (copy-region-as-kill (mark) (point))
137 (beginning-of-line)
138 (insert-string
139 "/*****************************************************************************/
140 /*!
141 *\\class ")
142 (yank)
143 (insert-string "
144 *\\brief ")
145 (yank)
146 (insert-string "
147 *
148 * Author: ")
149 (insert-string (user-full-name))
150 (insert-string "
151 *
152 * Created: ")
153 (insert-string (current-time-string))
154 (insert-string "
155 *
156 *
157 */
158 /*****************************************************************************/
159 ")
160 (forward-line -4)
161 (search-forward "* ")
162 ()
163 )
164 )
165 (cond
166 ((catch 'not-bof
167 (progn
168 (set-mark (point))
169 (beginning-of-buffer)
170 (cond ((not (= (mark) (point)))
171 (progn
172 (goto-char (mark))
173 (throw 'not-bof t))))
174 ; At beginning of file: insert beginning of file comment
175 (insert-string
176 "/*****************************************************************************/
177 /*!
178 *\\file ")
179 (insert-string (file-name-nondirectory (buffer-file-name)))
180 (insert-string "
181 *\\brief
182 *
183 * Author: ")
184 (insert-string (user-full-name))
185 (insert-string "
186 *
187 * Created: ")
188 (insert-string (current-time-string))
189 (insert-string "
190 */
191 /*****************************************************************************/
192 ")
193 (forward-line -7)
194 (search-forward "brief ")
195 ()
196 )
197 )
198 ; Insert default comment template
199 (insert-string
200 "/*****************************************************************************/
201 /*
202 *
203 */
204 /*****************************************************************************/
205 ")
206 (forward-line -3)
207 (search-forward "* ")
208 )
209 )
210 )
211 )
212 )
213 )
214 )
215 )
216 )
217
218 (provide 'cvc-devel)