-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
quantlib.el
109 lines (92 loc) · 3.33 KB
/
quantlib.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
(defvar ql-file-variables
"/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
")
(defvar ql-license
"
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<[email protected]>. The license is also available online at
<http://quantlib.org/license.shtml>.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
")
; skeleton for a new header file---you might want to bind this to some key
(defun ql-new-header ()
(interactive)
(insert ql-file-variables)
(ql-add-license)
(ql-add-file-description)
(insert "\n")
(ql-add-include-guard)
(ql-add-sample-header)
(insert "\n")
(ql-add-namespace))
; skeleton for a new source file---you might want to bind this to some key
(defun ql-new-source ()
(interactive)
(insert ql-file-variables)
(ql-add-license)
(insert "\n")
(ql-add-sample-header)
(insert "\n")
(ql-add-namespace))
(require 'cc-mode)
(defvar c++-font-lock-extra-types)
; A few types for syntax-highlighting
; from QuantLib:
(setq c++-font-lock-extra-types
(append c++-font-lock-extra-types
'("QuantLib"
"Integer" "BigInteger" "Natural" "BigNatural" "Real" "Decimal"
"Time" "Rate" "Spread" "DiscountFactor" "Size" "Volatility"
"Date" "Day" "Month" "Year" "Weekday"
"TimeUnit" "Frequency" "Compounding" "Period" "DayCounter"
"Calendar" "BusinessDayConvention"
"Currency" "ExchangeRate" "Money" "Rounding"
"InterestRate"
"History"
"Handle")))
; from Boost:
(setq c++-font-lock-extra-types
(append c++-font-lock-extra-types
'("Boost"
"shared_ptr" "format")))
; helper functions
(defun ql-add-license ()
(let ((holder (read-from-minibuffer "Copyright holder? ")))
(let ((copyright-notice
(apply 'string (append " Copyright (C) "
(substring (current-time-string) -4)
" "
holder
"\n"
()))))
(insert "\n/*\n"
copyright-notice
ql-license
"*/\n\n"))))
(defun ql-add-file-description ()
(let ((filename (buffer-name))
(description (read-from-minibuffer "Short file description? ")))
(insert "/*! \\file " filename "\n"
" \\brief " description "\n"
"*/\n")))
(defun ql-add-include-guard ()
(let ((guard (read-from-minibuffer "Include guard? ")))
(insert "#ifndef " guard "\n"
"#define " guard "\n"
"\n\n\n"
"#endif\n"))
(forward-line -3))
(defun ql-add-sample-header ()
(insert "#include <ql/qldefines.hpp>\n"))
(defun ql-add-namespace ()
(insert "namespace QuantLib {\n"
"\n\n\n"
"}\n")
(forward-line -3)
(c-indent-command))