-
Notifications
You must be signed in to change notification settings - Fork 0
/
funcs.el
172 lines (153 loc) · 4.19 KB
/
funcs.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
;;; funcs.el --- Octave Layer functions File for Spacemacs
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
;;;; functions for toggles
(defun spacemacs/toggle-octave-echo-input ()
"Toggle whether input sent to Octave is echoed."
(interactive)
(if octave-send-echo-input
(progn
(setq octave-send-echo-input nil)
(message "Won't echo submissions to Octave RELP."))
(progn
(setq octave-send-echo-input t)
(message "Will echo submissions to Octave RELP."))))
(defun spacemacs/toggle-octave-show-on-input ()
"Toggle whether sending input to Octave reveals its buffer."
(interactive)
(if octave-send-show-buffer
(progn
(setq octave-send-show-buffer nil)
(message "Won't show Octave RELP on send."))
(progn
(setq octave-send-show-buffer t)
(message "Will show Octave REPL on send."))))
(defun spacemacs/toggle-octave-matlab-syntax-compatibility ()
"Toggle whether input sent to Octave is echoed."
(interactive)
(if spacemacs-octave-matlab-syntax-compatibility
(progn
(setq spacemacs-octave-matlab-syntax-compatibility
nil)
(message "Won't echo submissions to Octave RELP."))
(progn
(setq spacemacs-octave-matlab-syntax-compatibility
t)
(message "Will echo submissions to Octave RELP."))))
;;;; functions to enable auto-complete
(defun spacemacs//octave-switch-company-to-auto-complete ()
(if (bound-and-true-p company-mode) (company-mode -1))
(auto-complete-mode 1))
;;;; repl controls
(defun spacemacs/octave-switch-to-octave ()
"Switch buffer focus to Octave REPL"
(interactive)
(switch-to-buffer "*Inferior Octave*"))
;;;; Functions to insert text
(defun spacemacs/octave-insert-if ()
"Insert an 'if' block."
(interactive)
(end-of-line)
(newline)
(insert "if ")
(prog-indent-sexp)
(setq-local current-cursor-position
(point))
(newline)
(if spacemacs-octave-matlab-syntax-compatibility
(progn
(insert "end")
(prog-indent-sexp))
(smie-close-block))
(goto-char current-cursor-position)
(evil-append))
(defun spacemacs/octave-insert-if-else ()
"Insert an 'if-else' block."
(interactive)
(end-of-line)
(newline)
(insert "if ")
(prog-indent-sexp)
(setq-local current-cursor-position
(point))
(newline)
(insert "else")
(prog-indent-sexp)
(newline)
(if spacemacs-octave-matlab-syntax-compatibility
(progn
(insert "end")
(prog-indent-sexp))
(smie-close-block))
(goto-char current-cursor-position)
(evil-append))
(defun spacemacs/octave-insert-switch ()
"Insert an 'switch' block."
(interactive)
(end-of-line)
(newline)
(insert "switch ")
(prog-indent-sexp)
(setq-local current-cursor-position
(point))
(newline)
(insert "otherwise")
(prog-indent-sexp)
(newline)
(if spacemacs-octave-matlab-syntax-compatibility
(progn
(insert "end")
(prog-indent-sexp))
(smie-close-block))
(goto-char current-cursor-position)
(evil-append))
(defun spacemacs/octave-insert-case ()
"Insert a 'case' stament."
(interactive)
(end-of-line)
(newline)
(insert "case ")
(prog-indent-sexp)
(evil-append))
(defun spacemacs/octave-insert-for ()
"Insert a 'for' block."
(interactive)
(end-of-line)
(newline)
(insert "for ")
(prog-indent-sexp)
(setq-local current-cursor-position
(point))
(insert " = ")
(newline)
(if spacemacs-octave-matlab-syntax-compatibility
(progn
(insert "end")
(prog-indent-sexp))
(smie-close-block))
(goto-char current-cursor-position)
(evil-append))
(defun spacemacs/octave-insert-while ()
"Insert a 'while' block."
(interactive)
(end-of-line)
(newline)
(insert "while ")
(prog-indent-sexp)
(setq-local current-cursor-position
(point))
(newline)
(if spacemacs-octave-matlab-syntax-compatibility
(progn
(insert "end")
(prog-indent-sexp))
(smie-close-block))
(goto-char current-cursor-position)
(evil-append))