-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinsertion-setting.el
85 lines (83 loc) · 2.86 KB
/
insertion-setting.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
;; -*- coding: utf-8 -*-
;; File: insertion-setting.el -- utilites for intelligent insertion
;;
;; Author: Denny(https://www.dennyzhang.com/contact)
;;
;; Copyright 2020, https://DennyZhang.com
;; Created:2008-10-01
;; Updated: Time-stamp: <2020-02-03 15:37:47>
;;
;; --8<-------------------------- separator ------------------------>8--
(defun my-insert-time()
(interactive)
(let* ((insert_str
(format-time-string "<%Y-%m-%d %H:%M UTC +8>" (current-time))))
(insert insert_str)
))
;; --8<-------------------------- separator ------------------------>8--
(defun insert-c++-class-header ()
"Inserts a C++ class header which conforms to Oacis standards."
(interactive)
(insert
"//-----------------------------------------------------------------------------\n"
"// Class:\t\t_class_\n"
"// Purpose:\t\n"
"//-----------------------------------------------------------------------------\n"
"\n")
(message "Inserted C++ class header")
)
(defun insert-c++-class ()
"Inserts a C++ class which conforms to Oacis standards."
(interactive)
(insert-c++-class-header)
(insert
"class _class_\n"
"{\n"
"public:\n"
"\n"
" // Constructor/destructor.\n"
" _class_();\n"
" virtual ~_class_();\n"
"\n"
"private:\n"
"\n"
" // Unused ctor and assignment op.\n"
" _class_(const _class_&);\n"
" _class_& operator=(const _class_&);\n"
"};\n"
"\n")
(message "Inserted C++ class")
)
;; --8<-------------------------- separator ------------------------>8--
;;insert string: ;; --8<-------------------------- separator ------------------------>8--
(defun get-separator ()
"Get separator for different modes"
(cond
((string-equal mode-name "Emacs-Lisp") ";;")
((string-equal mode-name "Lisp") ";;")
((string-equal mode-name "Erlang") "%%")
(t (if comment-start comment-start ""))))
(global-set-key [(meta p)(s)]
(lambda ()
(interactive)
(move-beginning-of-line nil)
(cond
((and (string= "Org" mode-name) (org-current-level))
(insert (make-string (org-current-level) ?*) " "
(format "%s --8<-------------------------- separator ------------------------>8-- :noexport:\n"
(get-separator))))
(t
(insert
(format "%s --8<-------------------------- separator ------------------------>8-- :noexport:\n"
(get-separator)))))))
;; --8<-------------------------- separator ------------------------>8--
(defun insert-unicode-drawing-box ()
"Insert a drawing box of unicode chars."
(interactive)
(insert "┌─┬─┐
│ │ │
├─┼─┤
│ │ │
└─┴─┘"))
;; --8<-------------------------- separator ------------------------>8--
;; File: insertion-setting.el