3093
|
1 ;;; octave-mod.el --- editing Octave source files under Emacs |
2617
|
2 |
3093
|
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. |
2617
|
4 |
|
5 ;; Author: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> |
|
6 ;; Author: John Eaton <jwe@bevo.che.wisc.edu> |
|
7 ;; Maintainer: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> |
|
8 ;; Keywords: languages |
|
9 |
|
10 ;; This file is part of GNU Emacs. |
|
11 |
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
|
13 ;; it under the terms of the GNU General Public License as published by |
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
|
15 ;; any later version. |
|
16 |
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 ;; GNU General Public License for more details. |
|
21 |
|
22 ;; You should have received a copy of the GNU General Public License |
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
|
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
25 ;; Boston, MA 02111-1307, USA. |
|
26 |
|
27 ;;; Commentary: |
|
28 |
|
29 ;; This package provides Emacs support for Octave. |
|
30 ;; It defines Octave mode, a major mode for editing |
|
31 ;; Octave code. |
|
32 |
|
33 ;; The file octave-hlp.el provides `octave-help', a facility for looking up |
|
34 ;; documentation on a symbol in the Octave info files. |
|
35 |
|
36 ;; The file octave-inf.el contains code for interacting with an inferior |
|
37 ;; Octave process using comint. |
|
38 |
|
39 ;; See the documentation of `octave-mode', `octave-help' and |
|
40 ;; `run-octave' for further information on usage and customization. |
|
41 |
|
42 ;;; Code: |
3323
|
43 (require 'custom) |
2617
|
44 |
3270
|
45 (defgroup octave nil |
|
46 "Major mode for editing Octave source files." |
|
47 :group 'languages) |
|
48 |
3093
|
49 (defvar inferior-octave-output-list nil) |
|
50 (defvar inferior-octave-output-string nil) |
|
51 (defvar inferior-octave-receive-in-progress nil) |
|
52 |
2617
|
53 (defconst octave-maintainer-address |
3270
|
54 "Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at>, bug-gnu-emacs@gnu.org" |
2617
|
55 "Current maintainer of the Emacs Octave package.") |
|
56 |
|
57 (defvar octave-abbrev-table nil |
|
58 "Abbrev table for Octave's reserved words. |
|
59 Used in octave-mode and inferior-octave-mode buffers. |
|
60 All Octave abbrevs start with a grave accent (`).") |
|
61 (if octave-abbrev-table |
|
62 () |
|
63 (let ((ac abbrevs-changed)) |
|
64 (define-abbrev-table 'octave-abbrev-table ()) |
|
65 (define-abbrev octave-abbrev-table "`a" "all_va_args" nil) |
|
66 (define-abbrev octave-abbrev-table "`b" "break" nil) |
2775
|
67 (define-abbrev octave-abbrev-table "`cs" "case" nil) |
2617
|
68 (define-abbrev octave-abbrev-table "`ca" "catch" nil) |
|
69 (define-abbrev octave-abbrev-table "`c" "continue" nil) |
|
70 (define-abbrev octave-abbrev-table "`el" "else" nil) |
|
71 (define-abbrev octave-abbrev-table "`eli" "elseif" nil) |
|
72 (define-abbrev octave-abbrev-table "`et" "end_try_catch" nil) |
|
73 (define-abbrev octave-abbrev-table "`eu" "end_unwind_protect" nil) |
|
74 (define-abbrev octave-abbrev-table "`ef" "endfor" nil) |
|
75 (define-abbrev octave-abbrev-table "`efu" "endfunction" nil) |
|
76 (define-abbrev octave-abbrev-table "`ei" "endif" nil) |
2775
|
77 (define-abbrev octave-abbrev-table "`es" "endswitch" nil) |
2617
|
78 (define-abbrev octave-abbrev-table "`ew" "endwhile" nil) |
|
79 (define-abbrev octave-abbrev-table "`f" "for" nil) |
|
80 (define-abbrev octave-abbrev-table "`fu" "function" nil) |
|
81 (define-abbrev octave-abbrev-table "`gl" "global" nil) |
|
82 (define-abbrev octave-abbrev-table "`gp" "gplot" nil) |
|
83 (define-abbrev octave-abbrev-table "`gs" "gsplot" nil) |
|
84 (define-abbrev octave-abbrev-table "`if" "if ()" nil) |
2775
|
85 (define-abbrev octave-abbrev-table "`o" "otherwise" nil) |
2617
|
86 (define-abbrev octave-abbrev-table "`rp" "replot" nil) |
|
87 (define-abbrev octave-abbrev-table "`r" "return" nil) |
2775
|
88 (define-abbrev octave-abbrev-table "`s" "switch" nil) |
2617
|
89 (define-abbrev octave-abbrev-table "`t" "try" nil) |
3485
|
90 (define-abbrev octave-abbrev-table "`u" "until ()" nil) |
2617
|
91 (define-abbrev octave-abbrev-table "`up" "unwind_protect" nil) |
|
92 (define-abbrev octave-abbrev-table "`upc" "unwind_protect_cleanup" nil) |
|
93 (define-abbrev octave-abbrev-table "`w" "while ()" nil) |
|
94 (setq abbrevs-changed ac))) |
|
95 |
|
96 (defvar octave-comment-char ?# |
|
97 "Character to start an Octave comment.") |
|
98 (defvar octave-comment-start |
4570
|
99 (string octave-comment-char ?\ ) |
2617
|
100 "String to insert to start a new Octave in-line comment.") |
|
101 (defvar octave-comment-start-skip "\\s<+\\s-*" |
|
102 "Regexp to match the start of an Octave comment up to its body.") |
|
103 |
|
104 (defvar octave-begin-keywords |
3485
|
105 '("do" "for" "function" "if" "switch" "try" "unwind_protect" "while")) |
2617
|
106 (defvar octave-else-keywords |
2775
|
107 '("case" "catch" "else" "elseif" "otherwise" "unwind_protect_cleanup")) |
2617
|
108 (defvar octave-end-keywords |
2775
|
109 '("end" "endfor" "endfunction" "endif" "endswitch" "end_try_catch" |
3485
|
110 "end_unwind_protect" "endwhile" "until")) |
2617
|
111 |
|
112 (defvar octave-reserved-words |
2788
|
113 (append octave-begin-keywords |
|
114 octave-else-keywords |
|
115 octave-end-keywords |
2617
|
116 '("all_va_args" "break" "continue" "global" "gplot" "gsplot" |
|
117 "replot" "return")) |
|
118 "Reserved words in Octave.") |
|
119 |
|
120 (defvar octave-text-functions |
|
121 '("casesen" "cd" "chdir" "clear" "diary" "dir" "document" "echo" |
5014
|
122 "edit_history" "format" "graw" "gset" "gshow" "help" "history" "hold" |
2617
|
123 "load" "ls" "more" "run_history" "save" "set" "show" "type" |
|
124 "which" "who" "whos") |
|
125 "Text functions in Octave (these names are also reserved).") |
|
126 |
|
127 (defvar octave-variables |
4451
|
128 '("DEFAULT_EXEC_PATH" "DEFAULT_LOADPATH" |
|
129 "EDITOR" "EXEC_PATH" "F_DUPFD" "F_GETFD" "F_GETFL" "F_SETFD" |
2617
|
130 "F_SETFL" "I" "IMAGEPATH" "INFO_FILE" "INFO_PROGRAM" "Inf" "J" |
|
131 "LOADPATH" "NaN" "OCTAVE_VERSION" "O_APPEND" "O_CREAT" "O_EXCL" |
|
132 "O_NONBLOCK" "O_RDONLY" "O_RDWR" "O_TRUNC" "O_WRONLY" "PAGER" "PS1" |
|
133 "PS2" "PS4" "PWD" "SEEK_CUR" "SEEK_END" "SEEK_SET" "__F_DUPFD__" |
|
134 "__F_GETFD__" "__F_GETFL__" "__F_SETFD__" "__F_SETFL__" "__I__" |
|
135 "__Inf__" "__J__" "__NaN__" "__OCTAVE_VERSION__" "__O_APPEND__" |
|
136 "__O_CREAT__" "__O_EXCL__" "__O_NONBLOCK__" "__O_RDONLY__" |
|
137 "__O_RDWR__" "__O_TRUNC__" "__O_WRONLY__" "__PWD__" "__SEEK_CUR__" |
|
138 "__SEEK_END__" "__SEEK_SET__" "__argv__" "__e__" "__eps__" |
4699
|
139 "__i__" "__inf__" "__j__" "__nan__" "__pi__" |
2617
|
140 "__program_invocation_name__" "__program_name__" "__realmax__" |
|
141 "__realmin__" "__stderr__" "__stdin__" "__stdout__" "ans" "argv" |
|
142 "automatic_replot" "beep_on_error" "completion_append_char" |
4466
|
143 "crash_dumps_octave_core" "default_save_format" |
|
144 "e" "echo_executing_commands" "eps" |
4422
|
145 "error_text" "gnuplot_binary" "history_file" |
4452
|
146 "history_size" "ignore_function_time_stamp" |
4460
|
147 "inf" "nan" "nargin" "output_max_field_width" "output_precision" |
2617
|
148 "page_output_immediately" "page_screen_output" "pi" |
|
149 "print_answer_id_name" "print_empty_dimensions" |
4478
|
150 "program_invocation_name" "program_name" |
4461
|
151 "realmax" "realmin" "return_last_computed_value" "save_precision" |
|
152 "saving_history" "sighup_dumps_octave_core" "sigterm_dumps_octave_core" |
2617
|
153 "silent_functions" "split_long_rows" "stderr" "stdin" "stdout" |
|
154 "string_fill_char" "struct_levels_to_print" |
4457
|
155 "suppress_verbose_help_message" "warn_assign_as_truth_value" |
4461
|
156 "warn_divide_by_zero" "warn_empty_list_elements" |
|
157 "warn_fortran_indexing" "warn_function_name_clash" |
|
158 "warn_future_time_stamp" "warn_imag_to_real" |
|
159 "warn_matlab_incompatible" "warn_missing_semicolon" |
|
160 "warn_neg_dim_as_zero" "warn_num_to_str" "warn_precedence_change" |
|
161 "warn_reload_forces_clear" "warn_separator_insert" |
|
162 "warn_single_quote_string" "warn_str_to_num" |
4466
|
163 "warn_undefined_return_values" "warn_variable_switch_label") |
2617
|
164 "Builtin variables in Octave.") |
|
165 |
|
166 (defvar octave-function-header-regexp |
|
167 (concat "^\\s-*\\<\\(function\\)\\>" |
|
168 "\\([^=;\n]*=[ \t]*\\|[ \t]*\\)\\(\\w+\\)\\>") |
|
169 "Regexp to match an Octave function header. |
|
170 The string `function' and its name are given by the first and third |
|
171 parenthetical grouping.") |
|
172 |
|
173 (defvar octave-font-lock-keywords |
|
174 (list |
|
175 ;; Fontify all builtin keywords. |
|
176 (cons (concat "\\<\\(" |
|
177 (mapconcat 'identity octave-reserved-words "\\|") |
|
178 (mapconcat 'identity octave-text-functions "\\|") |
|
179 "\\)\\>") |
|
180 'font-lock-keyword-face) |
|
181 ;; Fontify all builtin operators. |
|
182 (cons "\\(&\\||\\|<=\\|>=\\|==\\|<\\|>\\|!=\\|!\\)" |
3607
|
183 (if (boundp 'font-lock-builtin-face) |
|
184 'font-lock-builtin-face |
|
185 'font-lock-preprocessor-face)) |
2617
|
186 ;; Fontify all builtin variables. |
|
187 (cons (concat "\\<\\(" |
|
188 (mapconcat 'identity octave-variables "\\|") |
|
189 "\\)\\>") |
|
190 'font-lock-variable-name-face) |
|
191 ;; Fontify all function declarations. |
|
192 (list octave-function-header-regexp |
|
193 '(1 font-lock-keyword-face) |
|
194 '(3 font-lock-function-name-face nil t))) |
|
195 "Additional Octave expressions to highlight.") |
|
196 |
3270
|
197 (defcustom inferior-octave-buffer "*Inferior Octave*" |
|
198 "*Name of buffer for running an inferior Octave process." |
|
199 :type 'string |
|
200 :group 'octave-inferior) |
2617
|
201 |
|
202 (defvar inferior-octave-process nil) |
|
203 |
|
204 (defvar octave-mode-map nil |
|
205 "Keymap used in Octave mode.") |
|
206 (if octave-mode-map |
|
207 () |
|
208 (let ((map (make-sparse-keymap))) |
|
209 (define-key map "`" 'octave-abbrev-start) |
|
210 (define-key map ";" 'octave-electric-semi) |
|
211 (define-key map " " 'octave-electric-space) |
|
212 (define-key map "\n" 'octave-reindent-then-newline-and-indent) |
|
213 (define-key map "\t" 'indent-according-to-mode) |
|
214 (define-key map "\e;" 'octave-indent-for-comment) |
|
215 (define-key map "\e\n" 'octave-indent-new-comment-line) |
|
216 (define-key map "\e\t" 'octave-complete-symbol) |
|
217 (define-key map "\M-\C-a" 'octave-beginning-of-defun) |
|
218 (define-key map "\M-\C-e" 'octave-end-of-defun) |
|
219 (define-key map "\M-\C-h" 'octave-mark-defun) |
|
220 (define-key map "\M-\C-q" 'octave-indent-defun) |
|
221 (define-key map "\C-c;" 'octave-comment-region) |
|
222 (define-key map "\C-c:" 'octave-uncomment-region) |
|
223 (define-key map "\C-c\C-b" 'octave-submit-bug-report) |
|
224 (define-key map "\C-c\C-p" 'octave-previous-code-line) |
|
225 (define-key map "\C-c\C-n" 'octave-next-code-line) |
|
226 (define-key map "\C-c\C-a" 'octave-beginning-of-line) |
|
227 (define-key map "\C-c\C-e" 'octave-end-of-line) |
|
228 (define-key map "\C-c\M-\C-n" 'octave-forward-block) |
|
229 (define-key map "\C-c\M-\C-p" 'octave-backward-block) |
|
230 (define-key map "\C-c\M-\C-u" 'octave-backward-up-block) |
|
231 (define-key map "\C-c\M-\C-d" 'octave-down-block) |
|
232 (define-key map "\C-c\M-\C-h" 'octave-mark-block) |
|
233 (define-key map "\C-c]" 'octave-close-block) |
4304
|
234 (define-key map "\C-c\C-f" 'octave-insert-defun) |
2617
|
235 (define-key map "\C-c\C-h" 'octave-help) |
4304
|
236 (define-key map "\C-c\C-il" 'octave-send-line) |
|
237 (define-key map "\C-c\C-ib" 'octave-send-block) |
|
238 (define-key map "\C-c\C-if" 'octave-send-defun) |
|
239 (define-key map "\C-c\C-ir" 'octave-send-region) |
|
240 (define-key map "\C-c\C-is" 'octave-show-process-buffer) |
|
241 (define-key map "\C-c\C-ih" 'octave-hide-process-buffer) |
|
242 (define-key map "\C-c\C-ik" 'octave-kill-process) |
|
243 (define-key map "\C-c\C-i\C-l" 'octave-send-line) |
|
244 (define-key map "\C-c\C-i\C-b" 'octave-send-block) |
|
245 (define-key map "\C-c\C-i\C-f" 'octave-send-defun) |
|
246 (define-key map "\C-c\C-i\C-r" 'octave-send-region) |
|
247 (define-key map "\C-c\C-i\C-s" 'octave-show-process-buffer) |
|
248 (define-key map "\C-c\C-i\C-h" 'octave-hide-process-buffer) |
|
249 (define-key map "\C-c\C-i\C-k" 'octave-kill-process) |
2617
|
250 (setq octave-mode-map map))) |
|
251 |
|
252 (defvar octave-mode-menu |
|
253 (list "Octave" |
|
254 (list "Lines" |
|
255 ["Previous Code Line" octave-previous-code-line t] |
|
256 ["Next Code Line" octave-next-code-line t] |
|
257 ["Begin of Continuation" octave-beginning-of-line t] |
|
258 ["End of Continuation" octave-end-of-line t] |
|
259 ["Split Line at Point" octave-indent-new-comment-line t]) |
|
260 (list "Blocks" |
|
261 ["Next Block" octave-forward-block t] |
|
262 ["Previous Block" octave-backward-block t] |
|
263 ["Down Block" octave-down-block t] |
|
264 ["Up Block" octave-backward-up-block t] |
|
265 ["Mark Block" octave-mark-block t] |
|
266 ["Close Block" octave-close-block t]) |
|
267 (list "Functions" |
|
268 ["Begin of Function" octave-beginning-of-defun t] |
|
269 ["End of Function" octave-end-of-defun t] |
|
270 ["Mark Function" octave-mark-defun t] |
|
271 ["Indent Function" octave-indent-defun t] |
|
272 ["Insert Function" octave-insert-defun t]) |
|
273 "-" |
|
274 (list "Debug" |
|
275 ["Send Current Line" octave-send-line t] |
|
276 ["Send Current Block" octave-send-block t] |
|
277 ["Send Current Function" octave-send-defun t] |
|
278 ["Send Region" octave-send-region t] |
|
279 ["Show Process Buffer" octave-show-process-buffer t] |
|
280 ["Hide Process Buffer" octave-hide-process-buffer t] |
|
281 ["Kill Process" octave-kill-process t]) |
|
282 "-" |
|
283 ["Indent Line" indent-according-to-mode t] |
|
284 ["Complete Symbol" octave-complete-symbol t] |
|
285 "-" |
|
286 ["Toggle Abbrev Mode" abbrev-mode t] |
|
287 ["Toggle Auto-Fill Mode" auto-fill-mode t] |
|
288 "-" |
|
289 ["Submit Bug Report" octave-submit-bug-report t] |
|
290 "-" |
|
291 ["Describe Octave Mode" octave-describe-major-mode t] |
|
292 ["Lookup Octave Index" octave-help t]) |
|
293 "Menu for Octave mode.") |
|
294 |
4570
|
295 (defvar octave-mode-syntax-table |
2617
|
296 (let ((table (make-syntax-table))) |
|
297 (modify-syntax-entry ?\r " " table) |
|
298 (modify-syntax-entry ?+ "." table) |
|
299 (modify-syntax-entry ?- "." table) |
|
300 (modify-syntax-entry ?= "." table) |
|
301 (modify-syntax-entry ?* "." table) |
|
302 (modify-syntax-entry ?/ "." table) |
|
303 (modify-syntax-entry ?> "." table) |
|
304 (modify-syntax-entry ?< "." table) |
|
305 (modify-syntax-entry ?& "." table) |
|
306 (modify-syntax-entry ?| "." table) |
|
307 (modify-syntax-entry ?! "." table) |
|
308 (modify-syntax-entry ?\\ "\\" table) |
|
309 (modify-syntax-entry ?\' "." table) |
|
310 (modify-syntax-entry ?\` "w" table) |
|
311 (modify-syntax-entry ?\" "\"" table) |
|
312 (modify-syntax-entry ?. "w" table) |
|
313 (modify-syntax-entry ?_ "w" table) |
4546
|
314 (modify-syntax-entry ?\% "<" table) |
2617
|
315 (modify-syntax-entry ?\# "<" table) |
|
316 (modify-syntax-entry ?\n ">" table) |
4570
|
317 table) |
|
318 "Syntax table in use in `octave-mode' buffers.") |
2617
|
319 |
3270
|
320 (defcustom octave-auto-indent nil |
|
321 "*Non-nil means indent line after a semicolon or space in Octave mode." |
|
322 :type 'boolean |
|
323 :group 'octave) |
3069
|
324 |
3270
|
325 (defcustom octave-auto-newline nil |
|
326 "*Non-nil means automatically newline after a semicolon in Octave mode." |
|
327 :type 'boolean |
|
328 :group 'octave) |
2617
|
329 |
3270
|
330 (defcustom octave-blink-matching-block t |
2617
|
331 "*Control the blinking of matching Octave block keywords. |
|
332 Non-nil means show matching begin of block when inserting a space, |
3270
|
333 newline or semicolon after an else or end keyword." |
|
334 :type 'boolean |
|
335 :group 'octave) |
|
336 (defcustom octave-block-offset 2 |
|
337 "*Extra indentation applied to statements in Octave block structures." |
|
338 :type 'integer |
|
339 :group 'octave) |
2617
|
340 |
|
341 (defvar octave-block-begin-regexp |
|
342 (concat "\\<\\(" |
|
343 (mapconcat 'identity octave-begin-keywords "\\|") |
|
344 "\\)\\>")) |
|
345 (defvar octave-block-else-regexp |
|
346 (concat "\\<\\(" |
|
347 (mapconcat 'identity octave-else-keywords "\\|") |
|
348 "\\)\\>")) |
|
349 (defvar octave-block-end-regexp |
|
350 (concat "\\<\\(" |
|
351 (mapconcat 'identity octave-end-keywords "\\|") |
|
352 "\\)\\>")) |
|
353 (defvar octave-block-begin-or-end-regexp |
|
354 (concat octave-block-begin-regexp "\\|" octave-block-end-regexp)) |
|
355 (defvar octave-block-else-or-end-regexp |
|
356 (concat octave-block-else-regexp "\\|" octave-block-end-regexp)) |
|
357 (defvar octave-block-match-alist |
3485
|
358 '(("do" . ("until")) |
|
359 ("for" . ("end" "endfor")) |
2617
|
360 ("function" . ("end" "endfunction")) |
|
361 ("if" . ("else" "elseif" "end" "endif")) |
3092
|
362 ("switch" . ("case" "otherwise" "end" "endswitch")) |
2617
|
363 ("try" . ("catch" "end" "end_try_catch")) |
|
364 ("unwind_protect" . ("unwind_protect_cleanup" "end" |
|
365 "end_unwind_protect")) |
|
366 ("while" . ("end" "endwhile"))) |
|
367 "Alist with Octave's matching block keywords. |
|
368 Has Octave's begin keywords as keys and a list of the matching else or |
|
369 end keywords as associated values.") |
|
370 |
|
371 (defvar octave-block-comment-start |
|
372 (concat (make-string 2 octave-comment-char) " ") |
|
373 "String to insert to start a new Octave comment on an empty line.") |
|
374 |
3270
|
375 (defcustom octave-continuation-offset 4 |
|
376 "*Extra indentation applied to Octave continuation lines." |
|
377 :type 'integer |
|
378 :group 'octave) |
2617
|
379 (defvar octave-continuation-regexp |
|
380 "[^#%\n]*\\(\\\\\\|\\.\\.\\.\\)\\s-*\\(\\s<.*\\)?$") |
3270
|
381 (defcustom octave-continuation-string "\\" |
|
382 "*Character string used for Octave continuation lines. Normally \\." |
|
383 :type 'string |
|
384 :group 'octave) |
2617
|
385 |
|
386 (defvar octave-completion-alist nil |
|
387 "Alist of Octave symbols for completion in Octave mode. |
|
388 Each element looks like (VAR . VAR), where the car and cdr are the same |
|
389 symbol (an Octave command or variable name). |
|
390 Currently, only builtin variables can be completed.") |
|
391 |
|
392 (defvar octave-mode-imenu-generic-expression |
|
393 (list |
|
394 ;; Functions |
|
395 (list nil octave-function-header-regexp 3)) |
|
396 "Imenu expression for Octave mode. See `imenu-generic-expression'.") |
|
397 |
3270
|
398 (defcustom octave-mode-startup-message t |
|
399 "*Nil means do not display the Octave mode startup message." |
|
400 :type 'boolean |
|
401 :group 'octave) |
2617
|
402 |
3270
|
403 (defcustom octave-mode-hook nil |
|
404 "*Hook to be run when Octave mode is started." |
|
405 :type 'hook |
|
406 :group 'octave) |
2617
|
407 |
3270
|
408 (defcustom octave-send-show-buffer t |
|
409 "*Non-nil means display `inferior-octave-buffer' after sending to it." |
|
410 :type 'boolean |
|
411 :group 'octave) |
|
412 (defcustom octave-send-line-auto-forward t |
2617
|
413 "*Control auto-forward after sending to the inferior Octave process. |
3270
|
414 Non-nil means always go to the next Octave code line after sending." |
|
415 :type 'boolean |
|
416 :group 'octave) |
|
417 (defcustom octave-send-echo-input t |
|
418 "*Non-nil means echo input sent to the inferior Octave process." |
|
419 :type 'boolean |
|
420 :group 'octave) |
2617
|
421 |
|
422 |
|
423 ;;;###autoload |
|
424 (defun octave-mode () |
|
425 "Major mode for editing Octave code. |
|
426 |
|
427 This mode makes it easier to write Octave code by helping with |
|
428 indentation, doing some of the typing for you (with Abbrev mode) and by |
|
429 showing keywords, comments, strings, etc. in different faces (with |
|
430 Font Lock mode on terminals that support it). |
|
431 |
|
432 Octave itself is a high-level language, primarily intended for numerical |
|
433 computations. It provides a convenient command line interface for |
|
434 solving linear and nonlinear problems numerically. Function definitions |
|
435 can also be stored in files, and it can be used in a batch mode (which |
|
436 is why you need this mode!). |
|
437 |
|
438 The latest released version of Octave is always available via anonymous |
|
439 ftp from bevo.che.wisc.edu in the directory `/pub/octave'. Complete |
|
440 source and binaries for several popular systems are available. |
|
441 |
|
442 Type \\[list-abbrevs] to display the built-in abbrevs for Octave keywords. |
|
443 |
|
444 Keybindings |
|
445 =========== |
|
446 |
|
447 \\{octave-mode-map} |
|
448 |
|
449 Variables you can use to customize Octave mode |
|
450 ============================================== |
|
451 |
3069
|
452 octave-auto-indent |
|
453 Non-nil means indent current line after a semicolon or space. |
|
454 Default is nil. |
|
455 |
2617
|
456 octave-auto-newline |
|
457 Non-nil means auto-insert a newline and indent after a semicolon. |
|
458 Default is nil. |
|
459 |
|
460 octave-blink-matching-block |
|
461 Non-nil means show matching begin of block when inserting a space, |
|
462 newline or semicolon after an else or end keyword. Default is t. |
|
463 |
|
464 octave-block-offset |
|
465 Extra indentation applied to statements in block structures. |
|
466 Default is 2. |
|
467 |
|
468 octave-continuation-offset |
|
469 Extra indentation applied to Octave continuation lines. |
|
470 Default is 4. |
|
471 |
|
472 octave-continuation-string |
|
473 String used for Octave continuation lines. |
|
474 Default is a backslash. |
|
475 |
|
476 octave-mode-startup-message |
|
477 Nil means do not display the Octave mode startup message. |
|
478 Default is t. |
|
479 |
|
480 octave-send-echo-input |
|
481 Non-nil means always display `inferior-octave-buffer' after sending a |
|
482 command to the inferior Octave process. |
|
483 |
|
484 octave-send-line-auto-forward |
|
485 Non-nil means always go to the next unsent line of Octave code after |
|
486 sending a line to the inferior Octave process. |
|
487 |
|
488 octave-send-echo-input |
|
489 Non-nil means echo input sent to the inferior Octave process. |
|
490 |
|
491 Turning on Octave mode runs the hook `octave-mode-hook'. |
|
492 |
|
493 To begin using this mode for all `.m' files that you edit, add the |
|
494 following lines to your `.emacs' file: |
|
495 |
|
496 (autoload 'octave-mode \"octave-mod\" nil t) |
|
497 (setq auto-mode-alist |
|
498 (cons '(\"\\\\.m$\" . octave-mode) auto-mode-alist)) |
|
499 |
|
500 To automatically turn on the abbrev, auto-fill and font-lock features, |
|
501 add the following lines to your `.emacs' file as well: |
|
502 |
|
503 (add-hook 'octave-mode-hook |
|
504 (lambda () |
|
505 (abbrev-mode 1) |
|
506 (auto-fill-mode 1) |
|
507 (if (eq window-system 'x) |
|
508 (font-lock-mode 1)))) |
|
509 |
|
510 To submit a problem report, enter \\[octave-submit-bug-report] from \ |
|
511 an Octave mode buffer. |
|
512 This automatically sets up a mail buffer with version information |
|
513 already added. You just need to add a description of the problem, |
|
514 including a reproducible test case and send the message." |
|
515 (interactive) |
|
516 (kill-all-local-variables) |
|
517 |
|
518 (use-local-map octave-mode-map) |
|
519 (setq major-mode 'octave-mode) |
|
520 (setq mode-name "Octave") |
|
521 (setq local-abbrev-table octave-abbrev-table) |
|
522 (set-syntax-table octave-mode-syntax-table) |
|
523 |
|
524 (make-local-variable 'indent-line-function) |
|
525 (setq indent-line-function 'octave-indent-line) |
|
526 |
|
527 (make-local-variable 'comment-start) |
|
528 (setq comment-start octave-comment-start) |
|
529 (make-local-variable 'comment-end) |
|
530 (setq comment-end "") |
|
531 (make-local-variable 'comment-column) |
|
532 (setq comment-column 32) |
|
533 (make-local-variable 'comment-start-skip) |
|
534 (setq comment-start-skip "\\s<+\\s-*") |
|
535 (make-local-variable 'comment-indent-function) |
|
536 (setq comment-indent-function 'octave-comment-indent) |
|
537 |
|
538 (make-local-variable 'parse-sexp-ignore-comments) |
|
539 (setq parse-sexp-ignore-comments t) |
|
540 (make-local-variable 'paragraph-start) |
|
541 (setq paragraph-start (concat "\\s-*$\\|" page-delimiter)) |
|
542 (make-local-variable 'paragraph-separate) |
|
543 (setq paragraph-separate paragraph-start) |
|
544 (make-local-variable 'paragraph-ignore-fill-prefix) |
|
545 (setq paragraph-ignore-fill-prefix t) |
|
546 (make-local-variable 'fill-paragraph-function) |
|
547 (setq fill-paragraph-function 'octave-fill-paragraph) |
|
548 (make-local-variable 'adaptive-fill-regexp) |
|
549 (setq adaptive-fill-regexp nil) |
|
550 (make-local-variable 'fill-column) |
|
551 (setq fill-column 72) |
|
552 (make-local-variable 'normal-auto-fill-function) |
|
553 (setq normal-auto-fill-function 'octave-auto-fill) |
|
554 |
|
555 (make-local-variable 'font-lock-defaults) |
|
556 (setq font-lock-defaults '(octave-font-lock-keywords nil nil)) |
|
557 |
|
558 (make-local-variable 'imenu-generic-expression) |
3270
|
559 (setq imenu-generic-expression octave-mode-imenu-generic-expression |
|
560 imenu-case-fold-search nil) |
3176
|
561 |
2617
|
562 (octave-add-octave-menu) |
|
563 (octave-initialize-completions) |
|
564 (run-hooks 'octave-mode-hook)) |
|
565 |
|
566 ;;; Miscellaneous useful functions |
4728
|
567 |
|
568 (unless (fboundp 'line-beginning-position) |
|
569 (defalias 'line-beginning-position 'point-at-bol)) |
|
570 |
|
571 (unless (fboundp 'line-end-position) |
|
572 (defalias 'line-end-position 'point-at-eol)) |
|
573 |
2617
|
574 (defun octave-describe-major-mode () |
|
575 "Describe the current major mode." |
|
576 (interactive) |
|
577 (describe-function major-mode)) |
|
578 |
|
579 (defsubst octave-in-comment-p () |
|
580 "Returns t if point is inside an Octave comment, nil otherwise." |
|
581 (interactive) |
|
582 (save-excursion |
4570
|
583 (nth 4 (parse-partial-sexp (line-beginning-position) (point))))) |
2617
|
584 |
|
585 (defsubst octave-in-string-p () |
|
586 "Returns t if point is inside an Octave string, nil otherwise." |
|
587 (interactive) |
|
588 (save-excursion |
4570
|
589 (nth 3 (parse-partial-sexp (line-beginning-position) (point))))) |
2617
|
590 |
|
591 (defsubst octave-not-in-string-or-comment-p () |
|
592 "Returns t iff point is not inside an Octave string or comment." |
4570
|
593 (let ((pps (parse-partial-sexp (line-beginning-position) (point)))) |
2617
|
594 (not (or (nth 3 pps) (nth 4 pps))))) |
|
595 |
|
596 (defun octave-in-block-p () |
|
597 "Returns t if point is inside an Octave block, nil otherwise. |
|
598 The block is taken to start at the first letter of the begin keyword and |
|
599 to end after the end keyword." |
|
600 (let ((pos (point))) |
|
601 (save-excursion |
|
602 (condition-case nil |
|
603 (progn |
|
604 (skip-syntax-forward "w") |
|
605 (octave-up-block -1) |
|
606 (octave-forward-block) |
|
607 t) |
|
608 (error nil)) |
|
609 (< pos (point))))) |
|
610 |
|
611 (defun octave-in-defun-p () |
|
612 "Returns t iff point is inside an Octave function declaration. |
|
613 The function is taken to start at the `f' of `function' and to end after |
|
614 the end keyword." |
|
615 (let ((pos (point))) |
|
616 (save-excursion |
|
617 (or (and (looking-at "\\<function\\>") |
|
618 (octave-not-in-string-or-comment-p)) |
|
619 (and (octave-beginning-of-defun) |
|
620 (condition-case nil |
|
621 (progn |
|
622 (octave-forward-block) |
|
623 t) |
|
624 (error nil)) |
|
625 (< pos (point))))))) |
|
626 |
3083
|
627 (defun octave-maybe-insert-continuation-string () |
|
628 (if (or (octave-in-comment-p) |
|
629 (save-excursion |
|
630 (beginning-of-line) |
|
631 (looking-at octave-continuation-regexp))) |
|
632 nil |
|
633 (delete-horizontal-space) |
|
634 (insert (concat " " octave-continuation-string)))) |
|
635 |
3225
|
636 (defvar octave-xemacs-p |
|
637 (string-match "XEmacs\\|Lucid" emacs-version)) |
|
638 |
2617
|
639 ;;; Comments |
|
640 (defun octave-comment-region (beg end &optional arg) |
|
641 "Comment or uncomment each line in the region as Octave code. |
|
642 See `comment-region'." |
|
643 (interactive "r\nP") |
|
644 (let ((comment-start (char-to-string octave-comment-char))) |
|
645 (comment-region beg end arg))) |
|
646 |
|
647 (defun octave-uncomment-region (beg end &optional arg) |
|
648 "Uncomment each line in the region as Octave code." |
|
649 (interactive "r\nP") |
|
650 (or arg (setq arg 1)) |
|
651 (octave-comment-region beg end (- arg))) |
|
652 |
|
653 |
|
654 ;;; Indentation |
|
655 (defun calculate-octave-indent () |
|
656 "Return appropriate indentation for current line as Octave code. |
|
657 Returns an integer (the column to indent to) unless the line is a |
|
658 comment line with fixed goal golumn. In that case, returns a list whose |
|
659 car is the column to indent to, and whose cdr is the current indentation |
|
660 level." |
|
661 (let ((is-continuation-line |
|
662 (save-excursion |
|
663 (if (zerop (octave-previous-code-line)) |
|
664 (looking-at octave-continuation-regexp)))) |
|
665 (icol 0)) |
|
666 (save-excursion |
|
667 (beginning-of-line) |
|
668 ;; If we can move backward out one level of parentheses, take 1 |
|
669 ;; plus the indentation of that parenthesis. Otherwise, go back |
|
670 ;; to the beginning of the previous code line, and compute the |
|
671 ;; offset this line gives. |
|
672 (if (condition-case nil |
|
673 (progn |
|
674 (up-list -1) |
|
675 t) |
|
676 (error nil)) |
|
677 (setq icol (+ 1 (current-column))) |
|
678 (if (zerop (octave-previous-code-line)) |
|
679 (progn |
|
680 (octave-beginning-of-line) |
|
681 (back-to-indentation) |
|
682 (setq icol (current-column)) |
|
683 (let ((bot (point)) |
4570
|
684 (eol (line-end-position))) |
2617
|
685 (while (< (point) eol) |
|
686 (if (octave-not-in-string-or-comment-p) |
|
687 (cond |
2788
|
688 ((looking-at "\\<switch\\>") |
|
689 (setq icol (+ icol (* 2 octave-block-offset)))) |
2617
|
690 ((looking-at octave-block-begin-regexp) |
|
691 (setq icol (+ icol octave-block-offset))) |
|
692 ((looking-at octave-block-else-regexp) |
|
693 (if (= bot (point)) |
|
694 (setq icol (+ icol octave-block-offset)))) |
|
695 ((looking-at octave-block-end-regexp) |
|
696 (if (not (= bot (point))) |
2788
|
697 (setq icol (- icol |
|
698 (octave-block-end-offset))))))) |
2617
|
699 (forward-char))) |
|
700 (if is-continuation-line |
|
701 (setq icol (+ icol octave-continuation-offset))))))) |
|
702 (save-excursion |
|
703 (back-to-indentation) |
|
704 (cond |
2788
|
705 ((and (looking-at octave-block-else-regexp) |
2617
|
706 (octave-not-in-string-or-comment-p)) |
|
707 (setq icol (- icol octave-block-offset))) |
2788
|
708 ((and (looking-at octave-block-end-regexp) |
|
709 (octave-not-in-string-or-comment-p)) |
|
710 (setq icol (- icol (octave-block-end-offset)))) |
3081
|
711 ((or (looking-at "\\s<\\s<\\s<\\S<") |
|
712 (octave-before-magic-comment-p)) |
2617
|
713 (setq icol (list 0 icol))) |
|
714 ((looking-at "\\s<\\S<") |
|
715 (setq icol (list comment-column icol))))) |
|
716 icol)) |
|
717 |
2788
|
718 (defun octave-block-end-offset () |
|
719 (save-excursion |
|
720 (octave-backward-up-block 1) |
|
721 (* octave-block-offset |
|
722 (if (string-match (match-string 0) "switch") 2 1)))) |
|
723 |
3081
|
724 (defun octave-before-magic-comment-p () |
|
725 (save-excursion |
|
726 (beginning-of-line) |
|
727 (and (bobp) (looking-at "\\s-*#!")))) |
|
728 |
2617
|
729 (defun octave-comment-indent () |
3081
|
730 (if (or (looking-at "\\s<\\s<\\s<") |
|
731 (octave-before-magic-comment-p)) |
2617
|
732 0 |
|
733 (if (looking-at "\\s<\\s<") |
|
734 (calculate-octave-indent) |
|
735 (skip-syntax-backward " ") |
2788
|
736 (max (if (bolp) 0 (+ 1 (current-column))) |
2617
|
737 comment-column)))) |
|
738 |
|
739 (defun octave-indent-for-comment () |
|
740 "Maybe insert and indent an Octave comment. |
|
741 If there is no comment already on this line, create a code-level comment |
|
742 (started by two comment characters) if the line is empty, or an in-line |
|
743 comment (started by one comment character) otherwise. |
|
744 Point is left after the start of the comment which is properly aligned." |
|
745 (interactive) |
|
746 (indent-for-comment) |
|
747 (indent-according-to-mode)) |
|
748 |
|
749 (defun octave-indent-line (&optional arg) |
|
750 "Indent current line as Octave code. |
|
751 With optional ARG, use this as offset unless this line is a comment with |
|
752 fixed goal column." |
|
753 (interactive) |
|
754 (or arg (setq arg 0)) |
|
755 (let ((icol (calculate-octave-indent)) |
|
756 (relpos (- (current-column) (current-indentation)))) |
|
757 (if (listp icol) |
|
758 (setq icol (car icol)) |
|
759 (setq icol (+ icol arg))) |
|
760 (if (< icol 0) |
|
761 (error "Unmatched end keyword") |
|
762 (indent-line-to icol) |
|
763 (if (> relpos 0) |
|
764 (move-to-column (+ icol relpos)))))) |
|
765 |
|
766 (defun octave-indent-new-comment-line () |
|
767 "Break Octave line at point, continuing comment if within one. |
|
768 If within code, insert `octave-continuation-string' before breaking the |
|
769 line. If within a string, signal an error. |
|
770 The new line is properly indented." |
|
771 (interactive) |
|
772 (delete-horizontal-space) |
|
773 (cond |
|
774 ((octave-in-comment-p) |
|
775 (indent-new-comment-line)) |
|
776 ((octave-in-string-p) |
|
777 (error "Cannot split a code line inside a string")) |
|
778 (t |
|
779 (insert (concat " " octave-continuation-string)) |
|
780 (octave-reindent-then-newline-and-indent)))) |
|
781 |
|
782 (defun octave-indent-defun () |
|
783 "Properly indents the Octave function which contains point." |
|
784 (interactive) |
|
785 (save-excursion |
|
786 (octave-mark-defun) |
|
787 (message "Indenting function...") |
|
788 (indent-region (point) (mark) nil)) |
|
789 (message "Indenting function...done.")) |
|
790 |
|
791 |
|
792 ;;; Motion |
|
793 (defun octave-next-code-line (&optional arg) |
|
794 "Move ARG lines of Octave code forward (backward if ARG is negative). |
|
795 Skips past all empty and comment lines. Default for ARG is 1. |
|
796 |
|
797 On success, return 0. Otherwise, go as far as possible and return -1." |
|
798 (interactive "p") |
|
799 (or arg (setq arg 1)) |
|
800 (beginning-of-line) |
|
801 (let ((n 0) |
|
802 (inc (if (> arg 0) 1 -1))) |
|
803 (while (and (/= arg 0) (= n 0)) |
|
804 (setq n (forward-line inc)) |
|
805 (while (and (= n 0) |
|
806 (looking-at "\\s-*\\($\\|\\s<\\)")) |
|
807 (setq n (forward-line inc))) |
|
808 (setq arg (- arg inc))) |
|
809 n)) |
|
810 |
|
811 (defun octave-previous-code-line (&optional arg) |
|
812 "Move ARG lines of Octave code backward (forward if ARG is negative). |
|
813 Skips past all empty and comment lines. Default for ARG is 1. |
|
814 |
|
815 On success, return 0. Otherwise, go as far as possible and return -1." |
|
816 (interactive "p") |
|
817 (or arg (setq arg 1)) |
|
818 (octave-next-code-line (- arg))) |
|
819 |
|
820 (defun octave-beginning-of-line () |
|
821 "Move point to beginning of current Octave line. |
|
822 If on an empty or comment line, go to the beginning of that line. |
|
823 Otherwise, move backward to the beginning of the first Octave code line |
|
824 which is not inside a continuation statement, i.e., which does not |
|
825 follow a code line ending in `...' or `\\', or is inside an open |
|
826 parenthesis list." |
|
827 (interactive) |
|
828 (beginning-of-line) |
|
829 (if (not (looking-at "\\s-*\\($\\|\\s<\\)")) |
|
830 (while (or (condition-case nil |
|
831 (progn |
|
832 (up-list -1) |
|
833 (beginning-of-line) |
|
834 t) |
|
835 (error nil)) |
|
836 (and (or (looking-at "\\s-*\\($\\|\\s<\\)") |
|
837 (save-excursion |
|
838 (if (zerop (octave-previous-code-line)) |
|
839 (looking-at octave-continuation-regexp)))) |
|
840 (zerop (forward-line -1))))))) |
|
841 |
|
842 (defun octave-end-of-line () |
|
843 "Move point to end of current Octave line. |
|
844 If on an empty or comment line, go to the end of that line. |
|
845 Otherwise, move forward to the end of the first Octave code line which |
|
846 does not end in `...' or `\\' or is inside an open parenthesis list." |
|
847 (interactive) |
|
848 (end-of-line) |
|
849 (if (save-excursion |
|
850 (beginning-of-line) |
|
851 (looking-at "\\s-*\\($\\|\\s<\\)")) |
|
852 () |
|
853 (while (or (condition-case nil |
|
854 (progn |
|
855 (up-list 1) |
|
856 (end-of-line) |
|
857 t) |
|
858 (error nil)) |
|
859 (and (save-excursion |
|
860 (beginning-of-line) |
|
861 (or (looking-at "\\s-*\\($\\|\\s<\\)") |
|
862 (looking-at octave-continuation-regexp))) |
|
863 (zerop (forward-line 1))))) |
|
864 (end-of-line))) |
|
865 |
|
866 (defun octave-scan-blocks (from count depth) |
|
867 "Scan from character number FROM by COUNT Octave begin-end blocks. |
|
868 Returns the character number of the position thus found. |
|
869 |
|
870 If DEPTH is nonzero, block depth begins counting from that value. |
|
871 Only places where the depth in blocks becomes zero are candidates for |
|
872 stopping; COUNT such places are counted. |
|
873 |
|
874 If the beginning or end of the buffer is reached and the depth is wrong, |
|
875 an error is signaled." |
|
876 (let ((min-depth (if (> depth 0) 0 depth)) |
|
877 (inc (if (> count 0) 1 -1))) |
|
878 (save-excursion |
|
879 (while (/= count 0) |
|
880 (catch 'foo |
|
881 (while (or (re-search-forward |
|
882 octave-block-begin-or-end-regexp nil 'move inc) |
|
883 (if (/= depth 0) |
|
884 (error "Unbalanced block"))) |
|
885 (if (octave-not-in-string-or-comment-p) |
|
886 (progn |
|
887 (cond |
|
888 ((match-end 1) |
|
889 (setq depth (+ depth inc))) |
|
890 ((match-end 2) |
|
891 (setq depth (- depth inc)))) |
|
892 (if (< depth min-depth) |
|
893 (error "Containing expression ends prematurely")) |
|
894 (if (= depth 0) |
|
895 (throw 'foo nil)))))) |
|
896 (setq count (- count inc))) |
|
897 (point)))) |
|
898 |
|
899 (defun octave-forward-block (&optional arg) |
|
900 "Move forward across one balanced Octave begin-end block. |
|
901 With argument, do it that many times. |
|
902 Negative arg -N means move backward across N blocks." |
|
903 (interactive "p") |
|
904 (or arg (setq arg 1)) |
|
905 (goto-char (or (octave-scan-blocks (point) arg 0) (buffer-end arg)))) |
|
906 |
|
907 (defun octave-backward-block (&optional arg) |
|
908 "Move backward across one balanced Octave begin-end block. |
|
909 With argument, do it that many times. |
|
910 Negative arg -N means move forward across N blocks." |
|
911 (interactive "p") |
|
912 (or arg (setq arg 1)) |
|
913 (octave-forward-block (- arg))) |
|
914 |
|
915 (defun octave-down-block (arg) |
|
916 "Move forward down one begin-end block level of Octave code. |
|
917 With argument, do this that many times. |
|
918 A negative argument means move backward but still go down a level. |
|
919 In Lisp programs, an argument is required." |
|
920 (interactive "p") |
|
921 (let ((inc (if (> arg 0) 1 -1))) |
|
922 (while (/= arg 0) |
|
923 (goto-char (or (octave-scan-blocks (point) inc -1) |
|
924 (buffer-end arg))) |
|
925 (setq arg (- arg inc))))) |
|
926 |
|
927 (defun octave-backward-up-block (arg) |
|
928 "Move backward out of one begin-end block level of Octave code. |
|
929 With argument, do this that many times. |
|
930 A negative argument means move forward but still to a less deep spot. |
|
931 In Lisp programs, an argument is required." |
|
932 (interactive "p") |
|
933 (octave-up-block (- arg))) |
|
934 |
|
935 (defun octave-up-block (arg) |
|
936 "Move forward out of one begin-end block level of Octave code. |
|
937 With argument, do this that many times. |
|
938 A negative argument means move backward but still to a less deep spot. |
|
939 In Lisp programs, an argument is required." |
|
940 (interactive "p") |
|
941 (let ((inc (if (> arg 0) 1 -1))) |
|
942 (while (/= arg 0) |
|
943 (goto-char (or (octave-scan-blocks (point) inc 1) |
|
944 (buffer-end arg))) |
|
945 (setq arg (- arg inc))))) |
|
946 |
|
947 (defun octave-mark-block () |
|
948 "Put point at the beginning of this Octave block, mark at the end. |
|
949 The block marked is the one that contains point or follows point." |
|
950 (interactive) |
|
951 (let ((pos (point))) |
|
952 (if (or (and (octave-in-block-p) |
|
953 (skip-syntax-forward "w")) |
|
954 (condition-case nil |
|
955 (progn |
|
956 (octave-down-block 1) |
|
957 (octave-in-block-p)) |
|
958 (error nil))) |
|
959 (progn |
|
960 (octave-up-block -1) |
|
961 (push-mark (point)) |
|
962 (octave-forward-block) |
|
963 (exchange-point-and-mark)) |
|
964 (goto-char pos) |
|
965 (message "No block to mark found")))) |
|
966 |
|
967 (defun octave-close-block () |
|
968 "Close the current Octave block on a separate line. |
|
969 An error is signaled if no block to close is found." |
|
970 (interactive) |
|
971 (let (bb-keyword) |
|
972 (condition-case nil |
|
973 (progn |
|
974 (save-excursion |
|
975 (octave-backward-up-block 1) |
|
976 (setq bb-keyword (buffer-substring-no-properties |
|
977 (match-beginning 1) (match-end 1)))) |
|
978 (if (save-excursion |
|
979 (beginning-of-line) |
|
980 (looking-at "^\\s-*$")) |
|
981 (indent-according-to-mode) |
|
982 (octave-reindent-then-newline-and-indent)) |
|
983 (insert (car (reverse |
|
984 (assoc bb-keyword |
|
985 octave-block-match-alist)))) |
|
986 (octave-reindent-then-newline-and-indent) |
|
987 t) |
|
988 (error (message "No block to close found"))))) |
|
989 |
|
990 (defun octave-blink-matching-block-open () |
|
991 "Blink the matching Octave begin block keyword. |
|
992 If point is right after an Octave else or end type block keyword, move |
|
993 cursor momentarily to the corresponding begin keyword. |
|
994 Signal an error if the keywords are incompatible." |
|
995 (interactive) |
|
996 (let (bb-keyword bb-arg eb-keyword pos eol) |
|
997 (if (and (octave-not-in-string-or-comment-p) |
|
998 (looking-at "\\>") |
|
999 (save-excursion |
|
1000 (skip-syntax-backward "w") |
|
1001 (looking-at octave-block-else-or-end-regexp))) |
|
1002 (save-excursion |
|
1003 (cond |
|
1004 ((match-end 1) |
|
1005 (setq eb-keyword |
|
1006 (buffer-substring-no-properties |
|
1007 (match-beginning 1) (match-end 1))) |
|
1008 (octave-backward-up-block 1)) |
|
1009 ((match-end 2) |
|
1010 (setq eb-keyword |
|
1011 (buffer-substring-no-properties |
|
1012 (match-beginning 2) (match-end 2))) |
|
1013 (octave-backward-block))) |
|
1014 (setq pos (match-end 0) |
|
1015 bb-keyword |
|
1016 (buffer-substring-no-properties |
|
1017 (match-beginning 0) pos) |
|
1018 pos (+ pos 1) |
4570
|
1019 eol (line-end-position) |
2617
|
1020 bb-arg |
|
1021 (save-excursion |
|
1022 (save-restriction |
|
1023 (goto-char pos) |
|
1024 (while (and (skip-syntax-forward "^<" eol) |
|
1025 (octave-in-string-p) |
|
1026 (not (forward-char 1)))) |
|
1027 (skip-syntax-backward " ") |
|
1028 (buffer-substring-no-properties pos (point))))) |
|
1029 (if (member eb-keyword |
|
1030 (cdr (assoc bb-keyword octave-block-match-alist))) |
|
1031 (progn |
|
1032 (message "Matches `%s %s'" bb-keyword bb-arg) |
|
1033 (if (pos-visible-in-window-p) |
|
1034 (sit-for blink-matching-delay))) |
|
1035 (error "Block keywords `%s' and `%s' do not match" |
|
1036 bb-keyword eb-keyword)))))) |
|
1037 |
|
1038 (defun octave-beginning-of-defun (&optional arg) |
|
1039 "Move backward to the beginning of an Octave function. |
|
1040 With positive ARG, do it that many times. Negative argument -N means |
|
1041 move forward to Nth following beginning of a function. |
|
1042 Returns t unless search stops at the beginning or end of the buffer." |
|
1043 (interactive "p") |
|
1044 (let* ((arg (or arg 1)) |
|
1045 (inc (if (> arg 0) 1 -1)) |
|
1046 (found)) |
|
1047 (and (not (eobp)) |
|
1048 (not (and (> arg 0) (looking-at "\\<function\\>"))) |
|
1049 (skip-syntax-forward "w")) |
|
1050 (while (and (/= arg 0) |
|
1051 (setq found |
|
1052 (re-search-backward "\\<function\\>" nil 'move inc))) |
|
1053 (if (octave-not-in-string-or-comment-p) |
|
1054 (setq arg (- arg inc)))) |
|
1055 (if found |
|
1056 (progn |
|
1057 (and (< inc 0) (goto-char (match-beginning 0))) |
|
1058 t)))) |
|
1059 |
|
1060 (defun octave-end-of-defun (&optional arg) |
|
1061 "Move forward to the end of an Octave function. |
|
1062 With positive ARG, do it that many times. Negative argument -N means |
|
1063 move back to Nth preceding end of a function. |
|
1064 |
|
1065 An end of a function occurs right after the end keyword matching the |
|
1066 `function' keyword that starts the function." |
|
1067 (interactive "p") |
|
1068 (or arg (setq arg 1)) |
|
1069 (and (< arg 0) (skip-syntax-backward "w")) |
|
1070 (and (> arg 0) (skip-syntax-forward "w")) |
|
1071 (if (octave-in-defun-p) |
|
1072 (setq arg (- arg 1))) |
|
1073 (if (= arg 0) (setq arg -1)) |
|
1074 (if (octave-beginning-of-defun (- arg)) |
|
1075 (octave-forward-block))) |
|
1076 |
|
1077 (defun octave-mark-defun () |
|
1078 "Put point at the beginning of this Octave function, mark at its end. |
|
1079 The function marked is the one containing point or following point." |
|
1080 (interactive) |
|
1081 (let ((pos (point))) |
|
1082 (if (or (octave-in-defun-p) |
|
1083 (and (octave-beginning-of-defun -1) |
|
1084 (octave-in-defun-p))) |
|
1085 (progn |
|
1086 (skip-syntax-forward "w") |
|
1087 (octave-beginning-of-defun) |
|
1088 (push-mark (point)) |
|
1089 (octave-end-of-defun) |
|
1090 (exchange-point-and-mark)) |
|
1091 (goto-char pos) |
|
1092 (message "No function to mark found")))) |
|
1093 |
|
1094 |
|
1095 ;;; Filling |
|
1096 (defun octave-auto-fill () |
3083
|
1097 "Perform auto-fill in Octave mode. |
|
1098 Returns nil if no feasible place to break the line could be found, and t |
|
1099 otherwise." |
|
1100 (let (fc give-up) |
|
1101 (if (or (null (setq fc (current-fill-column))) |
|
1102 (save-excursion |
|
1103 (beginning-of-line) |
|
1104 (and auto-fill-inhibit-regexp |
|
1105 (looking-at auto-fill-inhibit-regexp)))) |
|
1106 nil ; Can't do anything |
|
1107 (if (and (not (octave-in-comment-p)) |
|
1108 (> (current-column) fc)) |
|
1109 (setq fc (- fc (+ (length octave-continuation-string) 1)))) |
|
1110 (while (and (not give-up) (> (current-column) fc)) |
|
1111 (let* ((opoint (point)) |
|
1112 (fpoint |
|
1113 (save-excursion |
|
1114 (move-to-column (+ fc 1)) |
|
1115 (skip-chars-backward "^ \t\n") |
|
1116 ;; If we're at the beginning of the line, break after |
|
1117 ;; the first word |
|
1118 (if (bolp) |
|
1119 (re-search-forward "[ \t]" opoint t)) |
|
1120 ;; If we're in a comment line, don't break after the |
|
1121 ;; comment chars |
|
1122 (if (save-excursion |
|
1123 (skip-syntax-backward " <") |
|
1124 (bolp)) |
4570
|
1125 (re-search-forward "[ \t]" (line-end-position) |
3083
|
1126 'move)) |
|
1127 ;; If we're not in a comment line and just ahead the |
|
1128 ;; continuation string, don't break here. |
|
1129 (if (and (not (octave-in-comment-p)) |
|
1130 (looking-at |
|
1131 (concat "\\s-*" |
|
1132 (regexp-quote |
|
1133 octave-continuation-string) |
|
1134 "\\s-*$"))) |
|
1135 (end-of-line)) |
|
1136 (skip-chars-backward " \t") |
|
1137 (point)))) |
|
1138 (if (save-excursion |
|
1139 (goto-char fpoint) |
|
1140 (not (or (bolp) (eolp)))) |
|
1141 (let ((prev-column (current-column))) |
|
1142 (if (save-excursion |
|
1143 (skip-chars-backward " \t") |
|
1144 (= (point) fpoint)) |
|
1145 (progn |
|
1146 (octave-maybe-insert-continuation-string) |
|
1147 (indent-new-comment-line t)) |
|
1148 (save-excursion |
|
1149 (goto-char fpoint) |
|
1150 (octave-maybe-insert-continuation-string) |
|
1151 (indent-new-comment-line t))) |
|
1152 (if (>= (current-column) prev-column) |
|
1153 (setq give-up t))) |
|
1154 (setq give-up t)))) |
|
1155 (not give-up)))) |
2617
|
1156 |
|
1157 (defun octave-fill-paragraph (&optional arg) |
|
1158 "Fill paragraph of Octave code, handling Octave comments." |
|
1159 (interactive "P") |
|
1160 (save-excursion |
|
1161 (let ((end (progn (forward-paragraph) (point))) |
|
1162 (beg (progn |
|
1163 (forward-paragraph -1) |
|
1164 (skip-chars-forward " \t\n") |
|
1165 (beginning-of-line) |
|
1166 (point))) |
|
1167 (cfc (current-fill-column)) |
|
1168 (ind (calculate-octave-indent)) |
|
1169 comment-prefix) |
|
1170 (save-restriction |
|
1171 (goto-char beg) |
|
1172 (narrow-to-region beg end) |
|
1173 (if (listp ind) (setq ind (nth 1 ind))) |
|
1174 (while (not (eobp)) |
|
1175 (condition-case nil |
|
1176 (octave-indent-line ind) |
|
1177 (error nil)) |
|
1178 (if (and (> ind 0) |
|
1179 (not |
|
1180 (save-excursion |
|
1181 (beginning-of-line) |
|
1182 (looking-at "^\\s-*\\($\\|\\s<+\\)")))) |
|
1183 (setq ind 0)) |
|
1184 (move-to-column cfc) |
|
1185 ;; First check whether we need to combine non-empty comment lines |
|
1186 (if (and (< (current-column) cfc) |
|
1187 (octave-in-comment-p) |
|
1188 (not (save-excursion |
|
1189 (beginning-of-line) |
|
1190 (looking-at "^\\s-*\\s<+\\s-*$")))) |
|
1191 ;; This is a nonempty comment line which does not extend |
|
1192 ;; past the fill column. If it is followed by an nonempty |
|
1193 ;; comment line with the same comment prefix, try to |
|
1194 ;; combine them, and repeat this until either we reach the |
|
1195 ;; fill-column or there is nothing more to combine. |
|
1196 (progn |
|
1197 ;; Get the comment prefix |
|
1198 (save-excursion |
|
1199 (beginning-of-line) |
|
1200 (while (and (re-search-forward "\\s<+") |
|
1201 (not (octave-in-comment-p)))) |
|
1202 (setq comment-prefix (match-string 0))) |
|
1203 ;; And keep combining ... |
|
1204 (while (and (< (current-column) cfc) |
|
1205 (save-excursion |
|
1206 (forward-line 1) |
|
1207 (and (looking-at |
|
1208 (concat "^\\s-*" |
|
1209 comment-prefix |
|
1210 "\\S<")) |
|
1211 (not (looking-at |
|
1212 (concat "^\\s-*" |
|
1213 comment-prefix |
|
1214 "\\s-*$")))))) |
|
1215 (delete-char 1) |
|
1216 (re-search-forward comment-prefix) |
|
1217 (delete-region (match-beginning 0) (match-end 0)) |
|
1218 (fixup-whitespace) |
|
1219 (move-to-column cfc)))) |
3083
|
1220 ;; We might also try to combine continued code lines> Perhaps |
|
1221 ;; some other time ... |
2617
|
1222 (skip-chars-forward "^ \t\n") |
|
1223 (delete-horizontal-space) |
|
1224 (if (or (< (current-column) cfc) |
|
1225 (and (= (current-column) cfc) (eolp))) |
|
1226 (forward-line 1) |
|
1227 (if (not (eolp)) (insert " ")) |
3083
|
1228 (or (octave-auto-fill) |
|
1229 (forward-line 1))))) |
2617
|
1230 t))) |
|
1231 |
|
1232 |
|
1233 ;;; Completions |
|
1234 (defun octave-initialize-completions () |
|
1235 "Create an alist for Octave completions." |
|
1236 (if octave-completion-alist |
|
1237 () |
|
1238 (setq octave-completion-alist |
|
1239 (mapcar '(lambda (var) (cons var var)) |
|
1240 (append octave-reserved-words |
|
1241 octave-text-functions |
|
1242 octave-variables))))) |
|
1243 |
|
1244 (defun octave-complete-symbol () |
|
1245 "Perform completion on Octave symbol preceding point. |
|
1246 Compare that symbol against Octave's reserved words and builtin |
|
1247 variables." |
|
1248 ;; This code taken from lisp-complete-symbol |
|
1249 (interactive) |
|
1250 (let* ((end (point)) |
|
1251 (beg (save-excursion (backward-sexp 1) (point))) |
|
1252 (string (buffer-substring-no-properties beg end)) |
|
1253 (completion (try-completion string octave-completion-alist))) |
|
1254 (cond ((eq completion t)) ; ??? |
|
1255 ((null completion) |
|
1256 (message "Can't find completion for \"%s\"" string) |
|
1257 (ding)) |
|
1258 ((not (string= string completion)) |
|
1259 (delete-region beg end) |
|
1260 (insert completion)) |
|
1261 (t |
|
1262 (let ((list (all-completions string octave-completion-alist)) |
|
1263 (conf (current-window-configuration))) |
|
1264 ;; Taken from comint.el |
|
1265 (message "Making completion list...") |
|
1266 (with-output-to-temp-buffer "*Completions*" |
|
1267 (display-completion-list list)) |
|
1268 (message "Hit space to flush") |
|
1269 (let (key first) |
|
1270 (if (save-excursion |
|
1271 (set-buffer (get-buffer "*Completions*")) |
|
1272 (setq key (read-key-sequence nil) |
|
1273 first (aref key 0)) |
|
1274 (and (consp first) (consp (event-start first)) |
|
1275 (eq (window-buffer (posn-window (event-start |
|
1276 first))) |
|
1277 (get-buffer "*Completions*")) |
|
1278 (eq (key-binding key) 'mouse-choose-completion))) |
|
1279 (progn |
|
1280 (mouse-choose-completion first) |
|
1281 (set-window-configuration conf)) |
|
1282 (if (eq first ?\ ) |
|
1283 (set-window-configuration conf) |
|
1284 (setq unread-command-events |
|
1285 (listify-key-sequence key)))))))))) |
|
1286 |
|
1287 |
|
1288 ;;; Electric characters && friends |
|
1289 (defun octave-reindent-then-newline-and-indent () |
|
1290 "Reindent current Octave line, insert newline, and indent the new line. |
|
1291 If Abbrev mode is on, expand abbrevs first." |
|
1292 (interactive) |
|
1293 (if abbrev-mode (expand-abbrev)) |
|
1294 (if octave-blink-matching-block |
|
1295 (octave-blink-matching-block-open)) |
|
1296 (save-excursion |
|
1297 (delete-region (point) (progn (skip-chars-backward " \t") (point))) |
|
1298 (indent-according-to-mode)) |
|
1299 (insert "\n") |
|
1300 (indent-according-to-mode)) |
|
1301 |
|
1302 (defun octave-electric-semi () |
|
1303 "Insert a semicolon in Octave mode. |
3083
|
1304 Maybe expand abbrevs and blink matching block open keywords. |
|
1305 Reindent the line of `octave-auto-indent' is non-nil. |
|
1306 Insert a newline if `octave-auto-newline' is non-nil." |
2617
|
1307 (interactive) |
|
1308 (if (not (octave-not-in-string-or-comment-p)) |
|
1309 (insert ";") |
|
1310 (if abbrev-mode (expand-abbrev)) |
|
1311 (if octave-blink-matching-block |
|
1312 (octave-blink-matching-block-open)) |
3069
|
1313 (if octave-auto-indent |
|
1314 (indent-according-to-mode)) |
2617
|
1315 (insert ";") |
|
1316 (if octave-auto-newline |
|
1317 (newline-and-indent)))) |
|
1318 |
|
1319 (defun octave-electric-space () |
|
1320 "Insert a space in Octave mode. |
3083
|
1321 Maybe expand abbrevs and blink matching block open keywords. |
|
1322 Reindent the line of `octave-auto-indent' is non-nil." |
2617
|
1323 (interactive) |
|
1324 (setq last-command-char ? ) |
|
1325 (if (not (octave-not-in-string-or-comment-p)) |
|
1326 (progn |
|
1327 (indent-according-to-mode) |
|
1328 (self-insert-command 1)) |
|
1329 (if abbrev-mode (expand-abbrev)) |
|
1330 (if octave-blink-matching-block |
|
1331 (octave-blink-matching-block-open)) |
3069
|
1332 (if (and octave-auto-indent |
|
1333 (save-excursion |
|
1334 (skip-syntax-backward " ") |
|
1335 (not (bolp)))) |
2617
|
1336 (indent-according-to-mode)) |
|
1337 (self-insert-command 1))) |
|
1338 |
|
1339 (defun octave-abbrev-start () |
|
1340 "Start entering an Octave abbreviation. |
|
1341 If Abbrev mode is turned on, typing ` (grave accent) followed by ? or |
|
1342 \\[help-command] lists all Octave abbrevs. Any other key combination is |
|
1343 executed normally. |
|
1344 Note that all Octave mode abbrevs start with a grave accent." |
|
1345 (interactive) |
|
1346 (if (not abbrev-mode) |
|
1347 (self-insert-command 1) |
|
1348 (let (c) |
|
1349 (insert last-command-char) |
3225
|
1350 (if (if octave-xemacs-p |
|
1351 (or (eq (event-to-character (setq c (next-event))) ??) |
|
1352 (eq (event-to-character c) help-char)) |
|
1353 (or (eq (setq c (read-event)) ??) |
|
1354 (eq c help-char))) |
|
1355 (let ((abbrev-table-name-list '(octave-abbrev-table))) |
2617
|
1356 (list-abbrevs)) |
|
1357 (setq unread-command-events (list c)))))) |
|
1358 |
|
1359 (defun octave-insert-defun (name args vals) |
|
1360 "Insert an Octave function skeleton. |
|
1361 Prompt for the function's name, arguments and return values (to be |
|
1362 entered without parens)." |
|
1363 (interactive |
|
1364 (list |
|
1365 (read-from-minibuffer "Function name: " |
|
1366 (substring (buffer-name) 0 -2)) |
|
1367 (read-from-minibuffer "Arguments: ") |
|
1368 (read-from-minibuffer "Return values: "))) |
|
1369 (let ((string (format "%s %s (%s)" |
|
1370 (cond |
|
1371 ((string-equal vals "") |
|
1372 vals) |
|
1373 ((string-match "[ ,]" vals) |
|
1374 (concat " [" vals "] =")) |
|
1375 (t |
|
1376 (concat " " vals " ="))) |
|
1377 name |
|
1378 args)) |
|
1379 (prefix octave-block-comment-start)) |
|
1380 (if (not (bobp)) (newline)) |
|
1381 (insert "function" string) |
|
1382 (indent-according-to-mode) |
|
1383 (newline 2) |
|
1384 (insert prefix "usage: " string) |
|
1385 (reindent-then-newline-and-indent) |
|
1386 (insert prefix) |
|
1387 (reindent-then-newline-and-indent) |
|
1388 (insert prefix) |
|
1389 (indent-according-to-mode) |
|
1390 (save-excursion |
|
1391 (newline 2) |
|
1392 (insert "endfunction") |
|
1393 (indent-according-to-mode)))) |
|
1394 |
|
1395 |
|
1396 ;;; Menu |
|
1397 (defun octave-add-octave-menu () |
|
1398 "Adds the `Octave' menu to the menu bar in Octave mode." |
|
1399 (require 'easymenu) |
|
1400 (easy-menu-define octave-mode-menu-map octave-mode-map |
|
1401 "Menu keymap for Octave mode." octave-mode-menu) |
|
1402 (easy-menu-add octave-mode-menu-map octave-mode-map)) |
|
1403 |
|
1404 |
|
1405 ;;; Communication with the inferior Octave process |
|
1406 (defun octave-kill-process () |
|
1407 "Kill inferior Octave process and its buffer." |
|
1408 (interactive) |
|
1409 (if inferior-octave-process |
|
1410 (progn |
|
1411 (process-send-string inferior-octave-process "quit;\n") |
|
1412 (accept-process-output inferior-octave-process))) |
|
1413 (if inferior-octave-buffer |
|
1414 (kill-buffer inferior-octave-buffer))) |
|
1415 |
|
1416 (defun octave-show-process-buffer () |
|
1417 "Make sure that `inferior-octave-buffer' is displayed." |
|
1418 (interactive) |
|
1419 (if (get-buffer inferior-octave-buffer) |
|
1420 (display-buffer inferior-octave-buffer) |
|
1421 (message "No buffer named %s" inferior-octave-buffer))) |
|
1422 |
|
1423 (defun octave-hide-process-buffer () |
|
1424 "Delete all windows that display `inferior-octave-buffer'." |
|
1425 (interactive) |
|
1426 (if (get-buffer inferior-octave-buffer) |
|
1427 (delete-windows-on inferior-octave-buffer) |
|
1428 (message "No buffer named %s" inferior-octave-buffer))) |
|
1429 |
|
1430 (defun octave-send-region (beg end) |
|
1431 "Send current region to the inferior Octave process." |
|
1432 (interactive "r") |
|
1433 (inferior-octave t) |
|
1434 (let ((proc inferior-octave-process) |
|
1435 (string (buffer-substring-no-properties beg end)) |
|
1436 line) |
|
1437 (save-excursion |
|
1438 (set-buffer inferior-octave-buffer) |
|
1439 (setq inferior-octave-output-list nil) |
|
1440 (while (not (string-equal string "")) |
|
1441 (if (string-match "\n" string) |
|
1442 (setq line (substring string 0 (match-beginning 0)) |
|
1443 string (substring string (match-end 0))) |
|
1444 (setq line string string "")) |
|
1445 (setq inferior-octave-receive-in-progress t) |
|
1446 (inferior-octave-send-list-and-digest (list (concat line "\n"))) |
|
1447 (while inferior-octave-receive-in-progress |
|
1448 (accept-process-output proc)) |
|
1449 (insert-before-markers |
|
1450 (mapconcat 'identity |
|
1451 (append |
|
1452 (if octave-send-echo-input (list line) (list "")) |
|
1453 (mapcar 'inferior-octave-strip-ctrl-g |
|
1454 inferior-octave-output-list) |
|
1455 (list inferior-octave-output-string)) |
|
1456 "\n"))))) |
|
1457 (if octave-send-show-buffer |
|
1458 (display-buffer inferior-octave-buffer))) |
|
1459 |
|
1460 (defun octave-send-block () |
|
1461 "Send current Octave block to the inferior Octave process." |
|
1462 (interactive) |
|
1463 (save-excursion |
|
1464 (octave-mark-block) |
|
1465 (octave-send-region (point) (mark)))) |
|
1466 |
|
1467 (defun octave-send-defun () |
|
1468 "Send current Octave function to the inferior Octave process." |
|
1469 (interactive) |
|
1470 (save-excursion |
|
1471 (octave-mark-defun) |
|
1472 (octave-send-region (point) (mark)))) |
|
1473 |
|
1474 (defun octave-send-line (&optional arg) |
|
1475 "Send current Octave code line to the inferior Octave process. |
|
1476 With positive prefix ARG, send that many lines. |
|
1477 If `octave-send-line-auto-forward' is non-nil, go to the next unsent |
|
1478 code line." |
|
1479 (interactive "P") |
|
1480 (or arg (setq arg 1)) |
|
1481 (if (> arg 0) |
|
1482 (let (beg end) |
|
1483 (beginning-of-line) |
|
1484 (setq beg (point)) |
|
1485 (octave-next-code-line (- arg 1)) |
|
1486 (end-of-line) |
|
1487 (setq end (point)) |
|
1488 (if octave-send-line-auto-forward |
|
1489 (octave-next-code-line 1)) |
|
1490 (octave-send-region beg end)))) |
|
1491 |
|
1492 (defun octave-eval-print-last-sexp () |
|
1493 "Evaluate Octave sexp before point and print value into current buffer." |
|
1494 (interactive) |
|
1495 (inferior-octave t) |
|
1496 (let ((standard-output (current-buffer)) |
|
1497 (print-escape-newlines nil) |
|
1498 (opoint (point))) |
|
1499 (terpri) |
|
1500 (prin1 |
|
1501 (save-excursion |
|
1502 (forward-sexp -1) |
|
1503 (inferior-octave-send-list-and-digest |
|
1504 (list (concat (buffer-substring-no-properties (point) opoint) |
|
1505 "\n"))) |
|
1506 (mapconcat 'identity inferior-octave-output-list "\n"))) |
|
1507 (terpri))) |
|
1508 |
|
1509 ;;; Bug reporting |
|
1510 (defun octave-submit-bug-report () |
|
1511 "Submit a bug report on the Emacs Octave package via mail." |
|
1512 (interactive) |
|
1513 (require 'reporter) |
|
1514 (and |
|
1515 (y-or-n-p "Do you want to submit a bug report? ") |
|
1516 (reporter-submit-bug-report |
|
1517 octave-maintainer-address |
|
1518 (concat "Emacs version " emacs-version) |
|
1519 (list |
3069
|
1520 'octave-auto-indent |
2617
|
1521 'octave-auto-newline |
|
1522 'octave-blink-matching-block |
|
1523 'octave-block-offset |
|
1524 'octave-comment-char |
|
1525 'octave-continuation-offset |
|
1526 'octave-continuation-string |
|
1527 'octave-help-files |
|
1528 'octave-mode-startup-message |
|
1529 'octave-send-echo-input |
|
1530 'octave-send-line-auto-forward |
|
1531 'octave-send-show-buffer)))) |
|
1532 |
|
1533 ;;; provide ourself |
|
1534 |
|
1535 (provide 'octave-mod) |
|
1536 |
|
1537 ;;; octave-mod.el ends here |