Unify mouse-highlight code for all GUI and TTY sessions.
[bpt/emacs.git] / lisp / progmodes / octave-mod.el
1 ;;; octave-mod.el --- editing Octave source files under Emacs
2
3 ;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 ;; Free Software Foundation, Inc.
5
6 ;; Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>
7 ;; Author: John Eaton <jwe@octave.org>
8 ;; Maintainer: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>
9 ;; Keywords: languages
10
11 ;; This file is part of GNU Emacs.
12
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
17
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25
26 ;;; Commentary:
27
28 ;; This package provides Emacs support for Octave.
29 ;; It defines Octave mode, a major mode for editing
30 ;; Octave code.
31
32 ;; The file octave-inf.el contains code for interacting with an inferior
33 ;; Octave process using comint.
34
35 ;; See the documentation of `octave-mode' and
36 ;; `run-octave' for further information on usage and customization.
37
38 ;;; Code:
39 (require 'custom)
40
41 (defgroup octave nil
42 "Major mode for editing Octave source files."
43 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
44 :group 'languages)
45
46 (defvar inferior-octave-output-list nil)
47 (defvar inferior-octave-output-string nil)
48 (defvar inferior-octave-receive-in-progress nil)
49
50 (declare-function inferior-octave-send-list-and-digest "octave-inf" (list))
51
52 (defconst octave-maintainer-address
53 "Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>, bug-gnu-emacs@gnu.org"
54 "Current maintainer of the Emacs Octave package.")
55
56 (define-abbrev-table 'octave-abbrev-table
57 (mapcar (lambda (e) (append e '(nil 0 t)))
58 '(("`a" "all_va_args")
59 ("`b" "break")
60 ("`cs" "case")
61 ("`ca" "catch")
62 ("`c" "continue")
63 ("`el" "else")
64 ("`eli" "elseif")
65 ("`et" "end_try_catch")
66 ("`eu" "end_unwind_protect")
67 ("`ef" "endfor")
68 ("`efu" "endfunction")
69 ("`ei" "endif")
70 ("`es" "endswitch")
71 ("`ew" "endwhile")
72 ("`f" "for")
73 ("`fu" "function")
74 ("`gl" "global")
75 ("`gp" "gplot")
76 ("`gs" "gsplot")
77 ("`if" "if ()")
78 ("`o" "otherwise")
79 ("`rp" "replot")
80 ("`r" "return")
81 ("`s" "switch")
82 ("`t" "try")
83 ("`u" "until ()")
84 ("`up" "unwind_protect")
85 ("`upc" "unwind_protect_cleanup")
86 ("`w" "while ()")))
87 "Abbrev table for Octave's reserved words.
88 Used in `octave-mode' and inferior-octave-mode buffers.
89 All Octave abbrevs start with a grave accent (`)."
90 :regexp "\\(?:[^`]\\|^\\)\\(\\(?:\\<\\|`\\)\\w+\\)\\W*")
91
92 (defvar octave-comment-char ?#
93 "Character to start an Octave comment.")
94 (defvar octave-comment-start
95 (string octave-comment-char ?\s)
96 "String to insert to start a new Octave in-line comment.")
97 (defvar octave-comment-start-skip "\\s<+\\s-*"
98 "Regexp to match the start of an Octave comment up to its body.")
99
100 (defvar octave-begin-keywords
101 '("do" "for" "function" "if" "switch" "try" "unwind_protect" "while"))
102 (defvar octave-else-keywords
103 '("case" "catch" "else" "elseif" "otherwise" "unwind_protect_cleanup"))
104 (defvar octave-end-keywords
105 '("endfor" "endfunction" "endif" "endswitch" "end_try_catch"
106 "end_unwind_protect" "endwhile" "until" "end"))
107
108 (defvar octave-reserved-words
109 (append octave-begin-keywords
110 octave-else-keywords
111 octave-end-keywords
112 '("break" "continue" "end" "global" "persistent" "return"))
113 "Reserved words in Octave.")
114
115 (defvar octave-text-functions
116 '("casesen" "cd" "chdir" "clear" "diary" "dir" "document" "echo"
117 "edit_history" "format" "help" "history" "hold"
118 "load" "ls" "more" "run_history" "save" "type"
119 "which" "who" "whos")
120 "Text functions in Octave.")
121
122 (defvar octave-variables
123 '("DEFAULT_EXEC_PATH" "DEFAULT_LOADPATH"
124 "EDITOR" "EXEC_PATH" "F_DUPFD" "F_GETFD" "F_GETFL" "F_SETFD"
125 "F_SETFL" "I" "IMAGE_PATH" "Inf" "J"
126 "NaN" "OCTAVE_VERSION" "O_APPEND" "O_CREAT" "O_EXCL"
127 "O_NONBLOCK" "O_RDONLY" "O_RDWR" "O_TRUNC" "O_WRONLY" "PAGER" "PS1"
128 "PS2" "PS4" "PWD" "SEEK_CUR" "SEEK_END" "SEEK_SET" "__F_DUPFD__"
129 "__F_GETFD__" "__F_GETFL__" "__F_SETFD__" "__F_SETFL__" "__I__"
130 "__Inf__" "__J__" "__NaN__" "__OCTAVE_VERSION__" "__O_APPEND__"
131 "__O_CREAT__" "__O_EXCL__" "__O_NONBLOCK__" "__O_RDONLY__"
132 "__O_RDWR__" "__O_TRUNC__" "__O_WRONLY__" "__PWD__" "__SEEK_CUR__"
133 "__SEEK_END__" "__SEEK_SET__" "__argv__" "__e__" "__eps__"
134 "__i__" "__inf__" "__j__" "__nan__" "__pi__"
135 "__program_invocation_name__" "__program_name__" "__realmax__"
136 "__realmin__" "__stderr__" "__stdin__" "__stdout__" "ans" "argv"
137 "beep_on_error" "completion_append_char"
138 "crash_dumps_octave_core" "default_save_format"
139 "e" "echo_executing_commands" "eps"
140 "error_text" "gnuplot_binary" "history_file"
141 "history_size" "ignore_function_time_stamp"
142 "inf" "nan" "nargin" "output_max_field_width" "output_precision"
143 "page_output_immediately" "page_screen_output" "pi"
144 "print_answer_id_name" "print_empty_dimensions"
145 "program_invocation_name" "program_name"
146 "realmax" "realmin" "return_last_computed_value" "save_precision"
147 "saving_history" "sighup_dumps_octave_core" "sigterm_dumps_octave_core"
148 "silent_functions" "split_long_rows" "stderr" "stdin" "stdout"
149 "string_fill_char" "struct_levels_to_print"
150 "suppress_verbose_help_message")
151 "Builtin variables in Octave.")
152
153 (defvar octave-function-header-regexp
154 (concat "^\\s-*\\<\\(function\\)\\>"
155 "\\([^=;\n]*=[ \t]*\\|[ \t]*\\)\\(\\w+\\)\\>")
156 "Regexp to match an Octave function header.
157 The string `function' and its name are given by the first and third
158 parenthetical grouping.")
159
160 (defvar octave-font-lock-keywords
161 (list
162 ;; Fontify all builtin keywords.
163 (cons (concat "\\<\\("
164 (regexp-opt (append octave-reserved-words
165 octave-text-functions))
166 "\\)\\>")
167 'font-lock-keyword-face)
168 ;; Fontify all builtin operators.
169 (cons "\\(&\\||\\|<=\\|>=\\|==\\|<\\|>\\|!=\\|!\\)"
170 (if (boundp 'font-lock-builtin-face)
171 'font-lock-builtin-face
172 'font-lock-preprocessor-face))
173 ;; Fontify all builtin variables.
174 (cons (concat "\\<" (regexp-opt octave-variables) "\\>")
175 'font-lock-variable-name-face)
176 ;; Fontify all function declarations.
177 (list octave-function-header-regexp
178 '(1 font-lock-keyword-face)
179 '(3 font-lock-function-name-face nil t)))
180 "Additional Octave expressions to highlight.")
181
182 (defun octave-syntax-propertize-function (start end)
183 (goto-char start)
184 (octave-syntax-propertize-sqs end)
185 (funcall (syntax-propertize-rules
186 ;; Try to distinguish the string-quotes from the transpose-quotes.
187 ("[[({,; ]\\('\\)"
188 (1 (prog1 "\"'" (octave-syntax-propertize-sqs end)))))
189 (point) end))
190
191 (defun octave-syntax-propertize-sqs (end)
192 "Propertize the content/end of single-quote strings."
193 (when (eq (nth 3 (syntax-ppss)) ?\')
194 ;; A '..' string.
195 (when (re-search-forward
196 "\\(?:\\=\\|[^']\\)\\(?:''\\)*\\('\\)\\($\\|[^']\\)" end 'move)
197 (goto-char (match-beginning 2))
198 (when (eq (char-before (match-beginning 1)) ?\\)
199 ;; Backslash cannot escape a single quote.
200 (put-text-property (1- (match-beginning 1)) (match-beginning 1)
201 'syntax-table (string-to-syntax ".")))
202 (put-text-property (match-beginning 1) (match-end 1)
203 'syntax-table (string-to-syntax "\"'")))))
204
205 (defcustom inferior-octave-buffer "*Inferior Octave*"
206 "Name of buffer for running an inferior Octave process."
207 :type 'string
208 :group 'octave-inferior)
209
210 (defvar inferior-octave-process nil)
211 \f
212 (defvar octave-mode-map
213 (let ((map (make-sparse-keymap)))
214 (define-key map "`" 'octave-abbrev-start)
215 (define-key map ";" 'octave-electric-semi)
216 (define-key map " " 'octave-electric-space)
217 (define-key map "\n" 'octave-reindent-then-newline-and-indent)
218 (define-key map "\e\n" 'octave-indent-new-comment-line)
219 (define-key map "\M-\C-q" 'octave-indent-defun)
220 (define-key map "\C-c\C-b" 'octave-submit-bug-report)
221 (define-key map "\C-c\C-p" 'octave-previous-code-line)
222 (define-key map "\C-c\C-n" 'octave-next-code-line)
223 (define-key map "\C-c\C-a" 'octave-beginning-of-line)
224 (define-key map "\C-c\C-e" 'octave-end-of-line)
225 (define-key map [remap down-list] 'smie-down-list)
226 (define-key map "\C-c\M-\C-h" 'octave-mark-block)
227 (define-key map "\C-c]" 'smie-close-block)
228 (define-key map "\C-c/" 'smie-close-block)
229 (define-key map "\C-c\C-f" 'octave-insert-defun)
230 (define-key map "\C-c\C-h" 'octave-help)
231 (define-key map "\C-c\C-il" 'octave-send-line)
232 (define-key map "\C-c\C-ib" 'octave-send-block)
233 (define-key map "\C-c\C-if" 'octave-send-defun)
234 (define-key map "\C-c\C-ir" 'octave-send-region)
235 (define-key map "\C-c\C-is" 'octave-show-process-buffer)
236 (define-key map "\C-c\C-ih" 'octave-hide-process-buffer)
237 (define-key map "\C-c\C-ik" 'octave-kill-process)
238 (define-key map "\C-c\C-i\C-l" 'octave-send-line)
239 (define-key map "\C-c\C-i\C-b" 'octave-send-block)
240 (define-key map "\C-c\C-i\C-f" 'octave-send-defun)
241 (define-key map "\C-c\C-i\C-r" 'octave-send-region)
242 (define-key map "\C-c\C-i\C-s" 'octave-show-process-buffer)
243 (define-key map "\C-c\C-i\C-h" 'octave-hide-process-buffer)
244 (define-key map "\C-c\C-i\C-k" 'octave-kill-process)
245 map)
246 "Keymap used in Octave mode.")
247
248
249
250 (easy-menu-define octave-mode-menu octave-mode-map
251 "Menu for Octave mode."
252 '("Octave"
253 ("Lines"
254 ["Previous Code Line" octave-previous-code-line t]
255 ["Next Code Line" octave-next-code-line t]
256 ["Begin of Continuation" octave-beginning-of-line t]
257 ["End of Continuation" octave-end-of-line t]
258 ["Split Line at Point" octave-indent-new-comment-line t])
259 ("Blocks"
260 ["Mark Block" octave-mark-block t]
261 ["Close Block" smie-close-block t])
262 ("Functions"
263 ["Indent Function" octave-indent-defun t]
264 ["Insert Function" octave-insert-defun t])
265 "-"
266 ("Debug"
267 ["Send Current Line" octave-send-line t]
268 ["Send Current Block" octave-send-block t]
269 ["Send Current Function" octave-send-defun t]
270 ["Send Region" octave-send-region t]
271 ["Show Process Buffer" octave-show-process-buffer t]
272 ["Hide Process Buffer" octave-hide-process-buffer t]
273 ["Kill Process" octave-kill-process t])
274 "-"
275 ["Indent Line" indent-according-to-mode t]
276 ["Complete Symbol" completion-at-point t]
277 "-"
278 ["Toggle Abbrev Mode" abbrev-mode
279 :style toggle :selected abbrev-mode]
280 ["Toggle Auto-Fill Mode" auto-fill-mode
281 :style toggle :selected auto-fill-function]
282 "-"
283 ["Submit Bug Report" octave-submit-bug-report t]
284 "-"
285 ["Describe Octave Mode" describe-mode t]
286 ["Lookup Octave Index" info-lookup-symbol t]))
287
288 (defvar octave-mode-syntax-table
289 (let ((table (make-syntax-table)))
290 (modify-syntax-entry ?\r " " table)
291 (modify-syntax-entry ?+ "." table)
292 (modify-syntax-entry ?- "." table)
293 (modify-syntax-entry ?= "." table)
294 (modify-syntax-entry ?* "." table)
295 (modify-syntax-entry ?/ "." table)
296 (modify-syntax-entry ?> "." table)
297 (modify-syntax-entry ?< "." 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 ;; Was "w" for abbrevs, but now that it's not necessary any more,
304 (modify-syntax-entry ?\` "." table)
305 (modify-syntax-entry ?\" "\"" table)
306 (modify-syntax-entry ?. "w" table)
307 (modify-syntax-entry ?_ "w" table)
308 ;; The "b" flag only applies to the second letter of the comstart
309 ;; and the first letter of the comend, i.e. the "4b" below is ineffective.
310 ;; If we try to put `b' on the single-line comments, we get a similar
311 ;; problem where the % and # chars appear as first chars of the 2-char
312 ;; comend, so the multi-line ender is also turned into style-b.
313 ;; So we need the new "c" comment style.
314 (modify-syntax-entry ?\% "< 13" table)
315 (modify-syntax-entry ?\# "< 13" table)
316 (modify-syntax-entry ?\{ "(} 2c" table)
317 (modify-syntax-entry ?\} "){ 4c" table)
318 (modify-syntax-entry ?\n ">" table)
319 table)
320 "Syntax table in use in `octave-mode' buffers.")
321
322 (defcustom octave-auto-indent nil
323 "Non-nil means indent line after a semicolon or space in Octave mode."
324 :type 'boolean
325 :group 'octave)
326
327 (defcustom octave-auto-newline nil
328 "Non-nil means automatically newline after a semicolon in Octave mode."
329 :type 'boolean
330 :group 'octave)
331
332 (defcustom octave-blink-matching-block t
333 "Control the blinking of matching Octave block keywords.
334 Non-nil means show matching begin of block when inserting a space,
335 newline or semicolon after an else or end keyword."
336 :type 'boolean
337 :group 'octave)
338
339 (defcustom octave-block-offset 2
340 "Extra indentation applied to statements in Octave block structures."
341 :type 'integer
342 :group 'octave)
343
344 (defvar octave-block-comment-start
345 (concat (make-string 2 octave-comment-char) " ")
346 "String to insert to start a new Octave comment on an empty line.")
347
348 (defcustom octave-continuation-offset 4
349 "Extra indentation applied to Octave continuation lines."
350 :type 'integer
351 :group 'octave)
352 (eval-and-compile
353 (defconst octave-continuation-marker-regexp "\\\\\\|\\.\\.\\."))
354 (defvar octave-continuation-regexp
355 (concat "[^#%\n]*\\(" octave-continuation-marker-regexp
356 "\\)\\s-*\\(\\s<.*\\)?$"))
357 (defcustom octave-continuation-string "\\"
358 "Character string used for Octave continuation lines. Normally \\."
359 :type 'string
360 :group 'octave)
361
362 (defvar octave-completion-alist nil
363 "Alist of Octave symbols for completion in Octave mode.
364 Each element looks like (VAR . VAR), where the car and cdr are the same
365 symbol (an Octave command or variable name).
366 Currently, only builtin variables can be completed.")
367
368 (defvar octave-mode-imenu-generic-expression
369 (list
370 ;; Functions
371 (list nil octave-function-header-regexp 3))
372 "Imenu expression for Octave mode. See `imenu-generic-expression'.")
373
374 (defcustom octave-mode-hook nil
375 "Hook to be run when Octave mode is started."
376 :type 'hook
377 :group 'octave)
378
379 (defcustom octave-send-show-buffer t
380 "Non-nil means display `inferior-octave-buffer' after sending to it."
381 :type 'boolean
382 :group 'octave)
383 (defcustom octave-send-line-auto-forward t
384 "Control auto-forward after sending to the inferior Octave process.
385 Non-nil means always go to the next Octave code line after sending."
386 :type 'boolean
387 :group 'octave)
388 (defcustom octave-send-echo-input t
389 "Non-nil means echo input sent to the inferior Octave process."
390 :type 'boolean
391 :group 'octave)
392
393 \f
394 ;;; SMIE indentation
395
396 (require 'smie)
397
398 (defconst octave-operator-table
399 '((assoc ";" "\n") (assoc ",") ; The doc claims they have equal precedence!?
400 (right "=" "+=" "-=" "*=" "/=")
401 (assoc "&&") (assoc "||") ; The doc claims they have equal precedence!?
402 (assoc "&") (assoc "|") ; The doc claims they have equal precedence!?
403 (nonassoc "<" "<=" "==" ">=" ">" "!=" "~=")
404 (nonassoc ":") ;No idea what this is.
405 (assoc "+" "-")
406 (assoc "*" "/" "\\" ".\\" ".*" "./")
407 (nonassoc "'" ".'")
408 (nonassoc "++" "--" "!" "~") ;And unary "+" and "-".
409 (right "^" "**" ".^" ".**")
410 ;; It's not really an operator, but for indentation purposes it
411 ;; could be convenient to treat it as one.
412 (assoc "...")))
413
414 (defconst octave-smie-bnf-table
415 '((atom)
416 ;; We can't distinguish the first element in a sequence with
417 ;; precedence grammars, so we can't distinguish the condition
418 ;; if the `if' from the subsequent body, for example.
419 ;; This has to be done later in the indentation rules.
420 (exp (exp "\n" exp)
421 ;; We need to mention at least one of the operators in this part
422 ;; of the grammar: if the BNF and the operator table have
423 ;; no overlap, SMIE can't know how they relate.
424 (exp ";" exp)
425 ("try" exp "catch" exp "end_try_catch")
426 ("try" exp "catch" exp "end")
427 ("unwind_protect" exp
428 "unwind_protect_cleanup" exp "end_unwind_protect")
429 ("unwind_protect" exp "unwind_protect_cleanup" exp "end")
430 ("for" exp "endfor")
431 ("for" exp "end")
432 ("do" exp "until" atom)
433 ("while" exp "endwhile")
434 ("while" exp "end")
435 ("if" exp "endif")
436 ("if" exp "else" exp "endif")
437 ("if" exp "elseif" exp "else" exp "endif")
438 ("if" exp "elseif" exp "elseif" exp "else" exp "endif")
439 ("if" exp "elseif" exp "elseif" exp "else" exp "end")
440 ("switch" exp "case" exp "endswitch")
441 ("switch" exp "case" exp "otherwise" exp "endswitch")
442 ("switch" exp "case" exp "case" exp "otherwise" exp "endswitch")
443 ("switch" exp "case" exp "case" exp "otherwise" exp "end")
444 ("function" exp "endfunction")
445 ("function" exp "end"))
446 ;; (fundesc (atom "=" atom))
447 ))
448
449 (defconst octave-smie-op-levels
450 (smie-prec2-levels
451 (smie-merge-prec2s
452 (smie-bnf-precedence-table
453 octave-smie-bnf-table
454 '((assoc "\n" ";")))
455
456 (smie-precs-precedence-table octave-operator-table))))
457
458 ;; Tokenizing needs to be refined so that ";;" is treated as two
459 ;; tokens and also so as to recognize the \n separator (and
460 ;; corresponding continuation lines).
461
462 (defconst octave-operator-regexp
463 (regexp-opt (apply 'append (mapcar 'cdr octave-operator-table))))
464
465 (defun octave-smie-backward-token ()
466 (let ((pos (point)))
467 (forward-comment (- (point)))
468 (cond
469 ((and (not (eq (char-before) ?\;)) ;Coalesce ";" and "\n".
470 (> pos (line-end-position))
471 (if (looking-back octave-continuation-marker-regexp (- (point) 3))
472 (progn
473 (goto-char (match-beginning 0))
474 (forward-comment (- (point)))
475 nil)
476 t)
477 ;; Ignore it if it's within parentheses.
478 (let ((ppss (syntax-ppss)))
479 (not (and (nth 1 ppss)
480 (eq ?\( (char-after (nth 1 ppss)))))))
481 (skip-chars-forward " \t")
482 ;; Why bother distinguishing \n and ;?
483 ";") ;;"\n"
484 ((and (looking-back octave-operator-regexp (- (point) 3) 'greedy)
485 ;; Don't mistake a string quote for a transpose.
486 (not (looking-back "\\s\"" (1- (point)))))
487 (goto-char (match-beginning 0))
488 (match-string-no-properties 0))
489 (t
490 (smie-default-backward-token)))))
491
492 (defun octave-smie-forward-token ()
493 (skip-chars-forward " \t")
494 (when (looking-at (eval-when-compile
495 (concat "\\(" octave-continuation-marker-regexp
496 "\\)[ \t]*\\($\\|[%#]\\)")))
497 (goto-char (match-end 1))
498 (forward-comment 1))
499 (cond
500 ((and (looking-at "$\\|[%#]")
501 ;; Ignore it if it's within parentheses.
502 (prog1 (let ((ppss (syntax-ppss)))
503 (not (and (nth 1 ppss)
504 (eq ?\( (char-after (nth 1 ppss))))))
505 (forward-comment (point-max))))
506 ;; Why bother distinguishing \n and ;?
507 ";") ;;"\n"
508 ((looking-at ";[ \t]*\\($\\|[%#]\\)")
509 ;; Combine the ; with the subsequent \n.
510 (goto-char (match-beginning 1))
511 (forward-comment 1)
512 ";")
513 ((and (looking-at octave-operator-regexp)
514 ;; Don't mistake a string quote for a transpose.
515 (not (looking-at "\\s\"")))
516 (goto-char (match-end 0))
517 (match-string-no-properties 0))
518 (t
519 (smie-default-forward-token))))
520
521 (defun octave-smie-rules (kind token)
522 (pcase (cons kind token)
523 (`(:elem . basic) octave-block-offset)
524 (`(:before . "case") octave-block-offset)
525 (`(:after . ";")
526 (if (smie-parent-p "function" "if" "while" "else" "elseif" "for"
527 "otherwise" "case" "try" "catch" "unwind_protect"
528 "unwind_protect_cleanup")
529 '(+ parent octave-block-offset)
530 ;; For (invalid) code between switch and case.
531 ;; (if (smie-parent-p "switch") 4)
532 0))))
533
534 (defvar electric-indent-chars)
535
536 ;;;###autoload
537 (define-derived-mode octave-mode prog-mode "Octave"
538 "Major mode for editing Octave code.
539
540 This mode makes it easier to write Octave code by helping with
541 indentation, doing some of the typing for you (with Abbrev mode) and by
542 showing keywords, comments, strings, etc. in different faces (with
543 Font Lock mode on terminals that support it).
544
545 Octave itself is a high-level language, primarily intended for numerical
546 computations. It provides a convenient command line interface for
547 solving linear and nonlinear problems numerically. Function definitions
548 can also be stored in files, and it can be used in a batch mode (which
549 is why you need this mode!).
550
551 The latest released version of Octave is always available via anonymous
552 ftp from ftp.octave.org in the directory `/pub/octave'. Complete
553 source and binaries for several popular systems are available.
554
555 Type \\[list-abbrevs] to display the built-in abbrevs for Octave keywords.
556
557 Keybindings
558 ===========
559
560 \\{octave-mode-map}
561
562 Variables you can use to customize Octave mode
563 ==============================================
564
565 `octave-auto-indent'
566 Non-nil means indent current line after a semicolon or space.
567 Default is nil.
568
569 `octave-auto-newline'
570 Non-nil means auto-insert a newline and indent after a semicolon.
571 Default is nil.
572
573 `octave-blink-matching-block'
574 Non-nil means show matching begin of block when inserting a space,
575 newline or semicolon after an else or end keyword. Default is t.
576
577 `octave-block-offset'
578 Extra indentation applied to statements in block structures.
579 Default is 2.
580
581 `octave-continuation-offset'
582 Extra indentation applied to Octave continuation lines.
583 Default is 4.
584
585 `octave-continuation-string'
586 String used for Octave continuation lines.
587 Default is a backslash.
588
589 `octave-send-echo-input'
590 Non-nil means always display `inferior-octave-buffer' after sending a
591 command to the inferior Octave process.
592
593 `octave-send-line-auto-forward'
594 Non-nil means always go to the next unsent line of Octave code after
595 sending a line to the inferior Octave process.
596
597 `octave-send-echo-input'
598 Non-nil means echo input sent to the inferior Octave process.
599
600 Turning on Octave mode runs the hook `octave-mode-hook'.
601
602 To begin using this mode for all `.m' files that you edit, add the
603 following lines to your `.emacs' file:
604
605 (add-to-list 'auto-mode-alist '(\"\\\\.m\\\\'\" . octave-mode))
606
607 To automatically turn on the abbrev and auto-fill features,
608 add the following lines to your `.emacs' file as well:
609
610 (add-hook 'octave-mode-hook
611 (lambda ()
612 (abbrev-mode 1)
613 (auto-fill-mode 1)))
614
615 To submit a problem report, enter \\[octave-submit-bug-report] from \
616 an Octave mode buffer.
617 This automatically sets up a mail buffer with version information
618 already added. You just need to add a description of the problem,
619 including a reproducible test case and send the message."
620 (setq local-abbrev-table octave-abbrev-table)
621
622 (smie-setup octave-smie-op-levels #'octave-smie-rules
623 :forward-token #'octave-smie-forward-token
624 :backward-token #'octave-smie-backward-token)
625 (set (make-local-variable 'smie-indent-basic) 'octave-block-offset)
626
627 (set (make-local-variable 'smie-blink-matching-triggers)
628 (cons ?\; smie-blink-matching-triggers))
629 (unless octave-blink-matching-block
630 (remove-hook 'post-self-insert-hook #'smie-blink-matching-open 'local))
631
632 (set (make-local-variable 'electric-indent-chars)
633 (cons ?\; electric-indent-chars))
634
635 (set (make-local-variable 'comment-start) octave-comment-start)
636 (set (make-local-variable 'comment-end) "")
637 ;; Don't set it here: it's not really a property of the language,
638 ;; just a personal preference of the author.
639 ;; (set (make-local-variable 'comment-column) 32)
640 (set (make-local-variable 'comment-start-skip) "\\s<+\\s-*")
641 (set (make-local-variable 'comment-add) 1)
642
643 (set (make-local-variable 'parse-sexp-ignore-comments) t)
644 (set (make-local-variable 'paragraph-start)
645 (concat "\\s-*$\\|" page-delimiter))
646 (set (make-local-variable 'paragraph-separate) paragraph-start)
647 (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
648 (set (make-local-variable 'fill-paragraph-function) 'octave-fill-paragraph)
649 ;; FIXME: Why disable it?
650 ;; (set (make-local-variable 'adaptive-fill-regexp) nil)
651 ;; Again, this is not a property of the language, don't set it here.
652 ;; (set (make-local-variable 'fill-column) 72)
653 (set (make-local-variable 'normal-auto-fill-function) 'octave-auto-fill)
654
655 (set (make-local-variable 'font-lock-defaults)
656 '(octave-font-lock-keywords))
657
658 (set (make-local-variable 'syntax-propertize-function)
659 #'octave-syntax-propertize-function)
660
661 (set (make-local-variable 'imenu-generic-expression)
662 octave-mode-imenu-generic-expression)
663 (set (make-local-variable 'imenu-case-fold-search) nil)
664
665 (add-hook 'completion-at-point-functions
666 'octave-completion-at-point-function nil t)
667 (set (make-local-variable 'beginning-of-defun-function)
668 'octave-beginning-of-defun)
669
670 (easy-menu-add octave-mode-menu)
671 (octave-initialize-completions)
672 (run-mode-hooks 'octave-mode-hook))
673
674 (defvar info-lookup-mode)
675
676 (defun octave-help ()
677 "Get help on Octave symbols from the Octave info files.
678 Look up symbol in the function, operator and variable indices of the info files."
679 (let ((info-lookup-mode 'octave-mode))
680 (call-interactively 'info-lookup-symbol)))
681 \f
682 ;;; Miscellaneous useful functions
683
684 (defsubst octave-in-comment-p ()
685 "Return t if point is inside an Octave comment."
686 (save-excursion
687 ;; FIXME: use syntax-ppss?
688 (nth 4 (parse-partial-sexp (line-beginning-position) (point)))))
689
690 (defsubst octave-in-string-p ()
691 "Return t if point is inside an Octave string."
692 (save-excursion
693 ;; FIXME: use syntax-ppss?
694 (nth 3 (parse-partial-sexp (line-beginning-position) (point)))))
695
696 (defsubst octave-not-in-string-or-comment-p ()
697 "Return t if point is not inside an Octave string or comment."
698 ;; FIXME: Use syntax-ppss?
699 (let ((pps (parse-partial-sexp (line-beginning-position) (point))))
700 (not (or (nth 3 pps) (nth 4 pps)))))
701
702
703 (defun octave-looking-at-kw (regexp)
704 "Like `looking-at', but sets `case-fold-search' nil."
705 (let ((case-fold-search nil))
706 (looking-at regexp)))
707
708 (defun octave-maybe-insert-continuation-string ()
709 (if (or (octave-in-comment-p)
710 (save-excursion
711 (beginning-of-line)
712 (looking-at octave-continuation-regexp)))
713 nil
714 (delete-horizontal-space)
715 (insert (concat " " octave-continuation-string))))
716
717 \f
718 ;;; Indentation
719
720 (defun octave-indent-new-comment-line ()
721 "Break Octave line at point, continuing comment if within one.
722 If within code, insert `octave-continuation-string' before breaking the
723 line. If within a string, signal an error.
724 The new line is properly indented."
725 (interactive)
726 (delete-horizontal-space)
727 (cond
728 ((octave-in-comment-p)
729 (indent-new-comment-line))
730 ((octave-in-string-p)
731 (error "Cannot split a code line inside a string"))
732 (t
733 (insert (concat " " octave-continuation-string))
734 (octave-reindent-then-newline-and-indent))))
735
736 (defun octave-indent-defun ()
737 "Properly indent the Octave function which contains point."
738 (interactive)
739 (save-excursion
740 (mark-defun)
741 (message "Indenting function...")
742 (indent-region (point) (mark) nil))
743 (message "Indenting function...done."))
744
745 \f
746 ;;; Motion
747 (defun octave-next-code-line (&optional arg)
748 "Move ARG lines of Octave code forward (backward if ARG is negative).
749 Skips past all empty and comment lines. Default for ARG is 1.
750
751 On success, return 0. Otherwise, go as far as possible and return -1."
752 (interactive "p")
753 (or arg (setq arg 1))
754 (beginning-of-line)
755 (let ((n 0)
756 (inc (if (> arg 0) 1 -1)))
757 (while (and (/= arg 0) (= n 0))
758 (setq n (forward-line inc))
759 (while (and (= n 0)
760 (looking-at "\\s-*\\($\\|\\s<\\)"))
761 (setq n (forward-line inc)))
762 (setq arg (- arg inc)))
763 n))
764
765 (defun octave-previous-code-line (&optional arg)
766 "Move ARG lines of Octave code backward (forward if ARG is negative).
767 Skips past all empty and comment lines. Default for ARG is 1.
768
769 On success, return 0. Otherwise, go as far as possible and return -1."
770 (interactive "p")
771 (or arg (setq arg 1))
772 (octave-next-code-line (- arg)))
773
774 (defun octave-beginning-of-line ()
775 "Move point to beginning of current Octave line.
776 If on an empty or comment line, go to the beginning of that line.
777 Otherwise, move backward to the beginning of the first Octave code line
778 which is not inside a continuation statement, i.e., which does not
779 follow a code line ending in `...' or `\\', or is inside an open
780 parenthesis list."
781 (interactive)
782 (beginning-of-line)
783 (if (not (looking-at "\\s-*\\($\\|\\s<\\)"))
784 (while (or (condition-case nil
785 (progn
786 (up-list -1)
787 (beginning-of-line)
788 t)
789 (error nil))
790 (and (or (looking-at "\\s-*\\($\\|\\s<\\)")
791 (save-excursion
792 (if (zerop (octave-previous-code-line))
793 (looking-at octave-continuation-regexp))))
794 (zerop (forward-line -1)))))))
795
796 (defun octave-end-of-line ()
797 "Move point to end of current Octave line.
798 If on an empty or comment line, go to the end of that line.
799 Otherwise, move forward to the end of the first Octave code line which
800 does not end in `...' or `\\' or is inside an open parenthesis list."
801 (interactive)
802 (end-of-line)
803 (if (save-excursion
804 (beginning-of-line)
805 (looking-at "\\s-*\\($\\|\\s<\\)"))
806 ()
807 (while (or (condition-case nil
808 (progn
809 (up-list 1)
810 (end-of-line)
811 t)
812 (error nil))
813 (and (save-excursion
814 (beginning-of-line)
815 (or (looking-at "\\s-*\\($\\|\\s<\\)")
816 (looking-at octave-continuation-regexp)))
817 (zerop (forward-line 1)))))
818 (end-of-line)))
819
820 (defun octave-mark-block ()
821 "Put point at the beginning of this Octave block, mark at the end.
822 The block marked is the one that contains point or follows point."
823 (interactive)
824 (unless (or (looking-at "\\s(")
825 (save-excursion
826 (let* ((token (funcall smie-forward-token-function))
827 (level (assoc token smie-op-levels)))
828 (and level (null (cadr level))))))
829 (backward-up-list 1))
830 (mark-sexp))
831
832 (defun octave-beginning-of-defun (&optional arg)
833 "Move backward to the beginning of an Octave function.
834 With positive ARG, do it that many times. Negative argument -N means
835 move forward to Nth following beginning of a function.
836 Returns t unless search stops at the beginning or end of the buffer."
837 (let* ((arg (or arg 1))
838 (inc (if (> arg 0) 1 -1))
839 (found nil)
840 (case-fold-search nil))
841 (and (not (eobp))
842 (not (and (> arg 0) (looking-at "\\<function\\>")))
843 (skip-syntax-forward "w"))
844 (while (and (/= arg 0)
845 (setq found
846 (re-search-backward "\\<function\\>" inc)))
847 (if (octave-not-in-string-or-comment-p)
848 (setq arg (- arg inc))))
849 (if found
850 (progn
851 (and (< inc 0) (goto-char (match-beginning 0)))
852 t))))
853
854 \f
855 ;;; Filling
856 (defun octave-auto-fill ()
857 "Perform auto-fill in Octave mode.
858 Returns nil if no feasible place to break the line could be found, and t
859 otherwise."
860 (let (fc give-up)
861 (if (or (null (setq fc (current-fill-column)))
862 (save-excursion
863 (beginning-of-line)
864 (and auto-fill-inhibit-regexp
865 (octave-looking-at-kw auto-fill-inhibit-regexp))))
866 nil ; Can't do anything
867 (if (and (not (octave-in-comment-p))
868 (> (current-column) fc))
869 (setq fc (- fc (+ (length octave-continuation-string) 1))))
870 (while (and (not give-up) (> (current-column) fc))
871 (let* ((opoint (point))
872 (fpoint
873 (save-excursion
874 (move-to-column (+ fc 1))
875 (skip-chars-backward "^ \t\n")
876 ;; If we're at the beginning of the line, break after
877 ;; the first word
878 (if (bolp)
879 (re-search-forward "[ \t]" opoint t))
880 ;; If we're in a comment line, don't break after the
881 ;; comment chars
882 (if (save-excursion
883 (skip-syntax-backward " <")
884 (bolp))
885 (re-search-forward "[ \t]" (line-end-position)
886 'move))
887 ;; If we're not in a comment line and just ahead the
888 ;; continuation string, don't break here.
889 (if (and (not (octave-in-comment-p))
890 (looking-at
891 (concat "\\s-*"
892 (regexp-quote
893 octave-continuation-string)
894 "\\s-*$")))
895 (end-of-line))
896 (skip-chars-backward " \t")
897 (point))))
898 (if (save-excursion
899 (goto-char fpoint)
900 (not (or (bolp) (eolp))))
901 (let ((prev-column (current-column)))
902 (if (save-excursion
903 (skip-chars-backward " \t")
904 (= (point) fpoint))
905 (progn
906 (octave-maybe-insert-continuation-string)
907 (indent-new-comment-line t))
908 (save-excursion
909 (goto-char fpoint)
910 (octave-maybe-insert-continuation-string)
911 (indent-new-comment-line t)))
912 (if (>= (current-column) prev-column)
913 (setq give-up t)))
914 (setq give-up t))))
915 (not give-up))))
916
917 (defun octave-fill-paragraph (&optional arg)
918 "Fill paragraph of Octave code, handling Octave comments."
919 ;; FIXME: difference with generic fill-paragraph:
920 ;; - code lines are only split, never joined.
921 ;; - \n that end comments are never removed.
922 ;; - insert continuation marker when splitting code lines.
923 (interactive "P")
924 (save-excursion
925 (let ((end (progn (forward-paragraph) (copy-marker (point) t)))
926 (beg (progn
927 (forward-paragraph -1)
928 (skip-chars-forward " \t\n")
929 (beginning-of-line)
930 (point)))
931 (cfc (current-fill-column))
932 comment-prefix)
933 (goto-char beg)
934 (while (< (point) end)
935 (condition-case nil
936 (indent-according-to-mode)
937 (error nil))
938 (move-to-column cfc)
939 ;; First check whether we need to combine non-empty comment lines
940 (if (and (< (current-column) cfc)
941 (octave-in-comment-p)
942 (not (save-excursion
943 (beginning-of-line)
944 (looking-at "^\\s-*\\s<+\\s-*$"))))
945 ;; This is a nonempty comment line which does not extend
946 ;; past the fill column. If it is followed by a nonempty
947 ;; comment line with the same comment prefix, try to
948 ;; combine them, and repeat this until either we reach the
949 ;; fill-column or there is nothing more to combine.
950 (progn
951 ;; Get the comment prefix
952 (save-excursion
953 (beginning-of-line)
954 (while (and (re-search-forward "\\s<+")
955 (not (octave-in-comment-p))))
956 (setq comment-prefix (match-string 0)))
957 ;; And keep combining ...
958 (while (and (< (current-column) cfc)
959 (save-excursion
960 (forward-line 1)
961 (and (looking-at
962 (concat "^\\s-*"
963 comment-prefix
964 "\\S<"))
965 (not (looking-at
966 (concat "^\\s-*"
967 comment-prefix
968 "\\s-*$"))))))
969 (delete-char 1)
970 (re-search-forward comment-prefix)
971 (delete-region (match-beginning 0) (match-end 0))
972 (fixup-whitespace)
973 (move-to-column cfc))))
974 ;; We might also try to combine continued code lines> Perhaps
975 ;; some other time ...
976 (skip-chars-forward "^ \t\n")
977 (delete-horizontal-space)
978 (if (or (< (current-column) cfc)
979 (and (= (current-column) cfc) (eolp)))
980 (forward-line 1)
981 (if (not (eolp)) (insert " "))
982 (or (octave-auto-fill)
983 (forward-line 1))))
984 t)))
985
986 \f
987 ;;; Completions
988 (defun octave-initialize-completions ()
989 "Create an alist for Octave completions."
990 (if octave-completion-alist
991 ()
992 (setq octave-completion-alist
993 (append octave-reserved-words
994 octave-text-functions
995 octave-variables))))
996
997 (defun octave-completion-at-point-function ()
998 "Find the text to complete and the corresponding table."
999 (let* ((beg (save-excursion (backward-sexp 1) (point)))
1000 (end (point)))
1001 (if (< beg (point))
1002 ;; Extend region past point, if applicable.
1003 (save-excursion (goto-char beg) (forward-sexp 1)
1004 (setq end (max end (point)))))
1005 (list beg end octave-completion-alist)))
1006
1007 (defun octave-complete-symbol ()
1008 "Perform completion on Octave symbol preceding point.
1009 Compare that symbol against Octave's reserved words and builtin
1010 variables."
1011 (interactive)
1012 (apply 'completion-in-region (octave-completion-at-point-function)))
1013 \f
1014 ;;; Electric characters && friends
1015 (defun octave-reindent-then-newline-and-indent ()
1016 "Reindent current Octave line, insert newline, and indent the new line.
1017 If Abbrev mode is on, expand abbrevs first."
1018 ;; FIXME: None of this is Octave-specific.
1019 (interactive)
1020 (reindent-then-newline-and-indent))
1021
1022 (defun octave-electric-semi ()
1023 "Insert a semicolon in Octave mode.
1024 Maybe expand abbrevs and blink matching block open keywords.
1025 Reindent the line if `octave-auto-indent' is non-nil.
1026 Insert a newline if `octave-auto-newline' is non-nil."
1027 (interactive)
1028 (setq last-command-event ?\;)
1029 (if (not (octave-not-in-string-or-comment-p))
1030 (self-insert-command 1)
1031 (if octave-auto-indent
1032 (indent-according-to-mode))
1033 (self-insert-command 1)
1034 (if octave-auto-newline
1035 (newline-and-indent))))
1036
1037 (defun octave-electric-space ()
1038 "Insert a space in Octave mode.
1039 Maybe expand abbrevs and blink matching block open keywords.
1040 Reindent the line if `octave-auto-indent' is non-nil."
1041 (interactive)
1042 (setq last-command-event ? )
1043 (if (and octave-auto-indent
1044 (not (octave-not-in-string-or-comment-p)))
1045 (progn
1046 (indent-according-to-mode)
1047 (self-insert-command 1))
1048 (if (and octave-auto-indent
1049 (save-excursion
1050 (skip-syntax-backward " ")
1051 (not (bolp))))
1052 (indent-according-to-mode))
1053 (self-insert-command 1)))
1054
1055 (defun octave-abbrev-start ()
1056 "Start entering an Octave abbreviation.
1057 If Abbrev mode is turned on, typing ` (grave accent) followed by ? or
1058 \\[help-command] lists all Octave abbrevs. Any other key combination is
1059 executed normally.
1060 Note that all Octave mode abbrevs start with a grave accent."
1061 (interactive)
1062 (if (not abbrev-mode)
1063 (self-insert-command 1)
1064 (let (c)
1065 (insert last-command-event)
1066 (if (if (featurep 'xemacs)
1067 (or (eq (event-to-character (setq c (next-event))) ??)
1068 (eq (event-to-character c) help-char))
1069 (or (eq (setq c (read-event)) ??)
1070 (eq c help-char)))
1071 (let ((abbrev-table-name-list '(octave-abbrev-table)))
1072 (list-abbrevs))
1073 (setq unread-command-events (list c))))))
1074
1075 (define-skeleton octave-insert-defun
1076 "Insert an Octave function skeleton.
1077 Prompt for the function's name, arguments and return values (to be
1078 entered without parens)."
1079 (let* ((defname (substring (buffer-name) 0 -2))
1080 (name (read-string (format "Function name (default %s): " defname)
1081 nil nil defname))
1082 (args (read-string "Arguments: "))
1083 (vals (read-string "Return values: ")))
1084 (format "%s%s (%s)"
1085 (cond
1086 ((string-equal vals "") vals)
1087 ((string-match "[ ,]" vals) (concat "[" vals "] = "))
1088 (t (concat vals " = ")))
1089 name
1090 args))
1091 \n "function " > str \n \n
1092 octave-block-comment-start "usage: " str \n
1093 octave-block-comment-start \n octave-block-comment-start
1094 \n _ \n
1095 "endfunction" > \n)
1096 \f
1097 ;;; Communication with the inferior Octave process
1098 (defun octave-kill-process ()
1099 "Kill inferior Octave process and its buffer."
1100 (interactive)
1101 (if inferior-octave-process
1102 (progn
1103 (process-send-string inferior-octave-process "quit;\n")
1104 (accept-process-output inferior-octave-process)))
1105 (if inferior-octave-buffer
1106 (kill-buffer inferior-octave-buffer)))
1107
1108 (defun octave-show-process-buffer ()
1109 "Make sure that `inferior-octave-buffer' is displayed."
1110 (interactive)
1111 (if (get-buffer inferior-octave-buffer)
1112 (display-buffer inferior-octave-buffer)
1113 (message "No buffer named %s" inferior-octave-buffer)))
1114
1115 (defun octave-hide-process-buffer ()
1116 "Delete all windows that display `inferior-octave-buffer'."
1117 (interactive)
1118 (if (get-buffer inferior-octave-buffer)
1119 (delete-windows-on inferior-octave-buffer)
1120 (message "No buffer named %s" inferior-octave-buffer)))
1121
1122 (defun octave-send-region (beg end)
1123 "Send current region to the inferior Octave process."
1124 (interactive "r")
1125 (inferior-octave t)
1126 (let ((proc inferior-octave-process)
1127 (string (buffer-substring-no-properties beg end))
1128 line)
1129 (with-current-buffer inferior-octave-buffer
1130 (setq inferior-octave-output-list nil)
1131 (while (not (string-equal string ""))
1132 (if (string-match "\n" string)
1133 (setq line (substring string 0 (match-beginning 0))
1134 string (substring string (match-end 0)))
1135 (setq line string string ""))
1136 (setq inferior-octave-receive-in-progress t)
1137 (inferior-octave-send-list-and-digest (list (concat line "\n")))
1138 (while inferior-octave-receive-in-progress
1139 (accept-process-output proc))
1140 (insert-before-markers
1141 (mapconcat 'identity
1142 (append
1143 (if octave-send-echo-input (list line) (list ""))
1144 (mapcar 'inferior-octave-strip-ctrl-g
1145 inferior-octave-output-list)
1146 (list inferior-octave-output-string))
1147 "\n")))))
1148 (if octave-send-show-buffer
1149 (display-buffer inferior-octave-buffer)))
1150
1151 (defun octave-send-block ()
1152 "Send current Octave block to the inferior Octave process."
1153 (interactive)
1154 (save-excursion
1155 (octave-mark-block)
1156 (octave-send-region (point) (mark))))
1157
1158 (defun octave-send-defun ()
1159 "Send current Octave function to the inferior Octave process."
1160 (interactive)
1161 (save-excursion
1162 (mark-defun)
1163 (octave-send-region (point) (mark))))
1164
1165 (defun octave-send-line (&optional arg)
1166 "Send current Octave code line to the inferior Octave process.
1167 With positive prefix ARG, send that many lines.
1168 If `octave-send-line-auto-forward' is non-nil, go to the next unsent
1169 code line."
1170 (interactive "P")
1171 (or arg (setq arg 1))
1172 (if (> arg 0)
1173 (let (beg end)
1174 (beginning-of-line)
1175 (setq beg (point))
1176 (octave-next-code-line (- arg 1))
1177 (end-of-line)
1178 (setq end (point))
1179 (if octave-send-line-auto-forward
1180 (octave-next-code-line 1))
1181 (octave-send-region beg end))))
1182
1183 (defun octave-eval-print-last-sexp ()
1184 "Evaluate Octave sexp before point and print value into current buffer."
1185 (interactive)
1186 (inferior-octave t)
1187 (let ((standard-output (current-buffer))
1188 (print-escape-newlines nil)
1189 (opoint (point)))
1190 (terpri)
1191 (prin1
1192 (save-excursion
1193 (forward-sexp -1)
1194 (inferior-octave-send-list-and-digest
1195 (list (concat (buffer-substring-no-properties (point) opoint)
1196 "\n")))
1197 (mapconcat 'identity inferior-octave-output-list "\n")))
1198 (terpri)))
1199 \f
1200 ;;; Bug reporting
1201 (defun octave-submit-bug-report ()
1202 "Submit a bug report on the Emacs Octave package via mail."
1203 (interactive)
1204 (require 'reporter)
1205 (and
1206 (y-or-n-p "Do you want to submit a bug report? ")
1207 (reporter-submit-bug-report
1208 octave-maintainer-address
1209 (concat "Emacs version " emacs-version)
1210 (list
1211 'octave-auto-indent
1212 'octave-auto-newline
1213 'octave-blink-matching-block
1214 'octave-block-offset
1215 'octave-comment-char
1216 'octave-continuation-offset
1217 'octave-continuation-string
1218 'octave-send-echo-input
1219 'octave-send-line-auto-forward
1220 'octave-send-show-buffer))))
1221
1222 ;; provide ourself
1223
1224 (provide 'octave-mod)
1225
1226 ;; arch-tag: 05f1ce09-be87-4c00-803e-4919ffa26c23
1227 ;;; octave-mod.el ends here