Mercurial > emacs
comparison lisp/progmodes/octave-mod.el @ 84655:4c09574b3527
Remove spurious * in docstrings.
(octave-mode-map): Move init into declaration and remove \t binding.
(octave-mode-startup-message): Remove unused var.
(octave-scan-blocks): Remove unused arg `from'.
(octave-forward-block, octave-down-block, octave-up-block): Update callers.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 19 Sep 2007 14:47:51 +0000 |
parents | 419c5c316b51 |
children | c25dd5c18af4 |
comparison
equal
deleted
inserted
replaced
84654:9b686572bf3f | 84655:4c09574b3527 |
---|---|
61 Used in `octave-mode' and inferior-octave-mode buffers. | 61 Used in `octave-mode' and inferior-octave-mode buffers. |
62 All Octave abbrevs start with a grave accent (`).") | 62 All Octave abbrevs start with a grave accent (`).") |
63 (unless octave-abbrev-table | 63 (unless octave-abbrev-table |
64 (define-abbrev-table 'octave-abbrev-table ())) | 64 (define-abbrev-table 'octave-abbrev-table ())) |
65 | 65 |
66 (let ((ac abbrevs-changed)) | 66 (let ((abbrevs-changed abbrevs-changed)) |
67 (define-abbrev octave-abbrev-table "`a" "all_va_args" nil 0 t) | 67 (define-abbrev octave-abbrev-table "`a" "all_va_args" nil 0 t) |
68 (define-abbrev octave-abbrev-table "`b" "break" nil 0 t) | 68 (define-abbrev octave-abbrev-table "`b" "break" nil 0 t) |
69 (define-abbrev octave-abbrev-table "`cs" "case" nil 0 t) | 69 (define-abbrev octave-abbrev-table "`cs" "case" nil 0 t) |
70 (define-abbrev octave-abbrev-table "`ca" "catch" nil 0 t) | 70 (define-abbrev octave-abbrev-table "`ca" "catch" nil 0 t) |
71 (define-abbrev octave-abbrev-table "`c" "continue" nil 0 t) | 71 (define-abbrev octave-abbrev-table "`c" "continue" nil 0 t) |
89 (define-abbrev octave-abbrev-table "`r" "return" nil 0 t) | 89 (define-abbrev octave-abbrev-table "`r" "return" nil 0 t) |
90 (define-abbrev octave-abbrev-table "`s" "switch" nil 0 t) | 90 (define-abbrev octave-abbrev-table "`s" "switch" nil 0 t) |
91 (define-abbrev octave-abbrev-table "`t" "try" nil 0 t) | 91 (define-abbrev octave-abbrev-table "`t" "try" nil 0 t) |
92 (define-abbrev octave-abbrev-table "`up" "unwind_protect" nil 0 t) | 92 (define-abbrev octave-abbrev-table "`up" "unwind_protect" nil 0 t) |
93 (define-abbrev octave-abbrev-table "`upc" "unwind_protect_cleanup" nil 0 t) | 93 (define-abbrev octave-abbrev-table "`upc" "unwind_protect_cleanup" nil 0 t) |
94 (define-abbrev octave-abbrev-table "`w" "while ()" nil 0 t) | 94 (define-abbrev octave-abbrev-table "`w" "while ()" nil 0 t)) |
95 (setq abbrevs-changed ac)) | |
96 | 95 |
97 (defvar octave-comment-char ?# | 96 (defvar octave-comment-char ?# |
98 "Character to start an Octave comment.") | 97 "Character to start an Octave comment.") |
99 (defvar octave-comment-start | 98 (defvar octave-comment-start |
100 (string octave-comment-char ?\ ) | 99 (string octave-comment-char ?\ ) |
191 '(1 font-lock-keyword-face) | 190 '(1 font-lock-keyword-face) |
192 '(3 font-lock-function-name-face nil t))) | 191 '(3 font-lock-function-name-face nil t))) |
193 "Additional Octave expressions to highlight.") | 192 "Additional Octave expressions to highlight.") |
194 | 193 |
195 (defcustom inferior-octave-buffer "*Inferior Octave*" | 194 (defcustom inferior-octave-buffer "*Inferior Octave*" |
196 "*Name of buffer for running an inferior Octave process." | 195 "Name of buffer for running an inferior Octave process." |
197 :type 'string | 196 :type 'string |
198 :group 'octave-inferior) | 197 :group 'octave-inferior) |
199 | 198 |
200 (defvar inferior-octave-process nil) | 199 (defvar inferior-octave-process nil) |
201 | 200 |
202 (defvar octave-mode-map nil | 201 (defvar octave-mode-map |
203 "Keymap used in Octave mode.") | |
204 (if octave-mode-map | |
205 () | |
206 (let ((map (make-sparse-keymap))) | 202 (let ((map (make-sparse-keymap))) |
207 (define-key map "`" 'octave-abbrev-start) | 203 (define-key map "`" 'octave-abbrev-start) |
208 (define-key map ";" 'octave-electric-semi) | 204 (define-key map ";" 'octave-electric-semi) |
209 (define-key map " " 'octave-electric-space) | 205 (define-key map " " 'octave-electric-space) |
210 (define-key map "\n" 'octave-reindent-then-newline-and-indent) | 206 (define-key map "\n" 'octave-reindent-then-newline-and-indent) |
211 (define-key map "\t" 'indent-according-to-mode) | |
212 (define-key map "\e;" 'octave-indent-for-comment) | 207 (define-key map "\e;" 'octave-indent-for-comment) |
213 (define-key map "\e\n" 'octave-indent-new-comment-line) | 208 (define-key map "\e\n" 'octave-indent-new-comment-line) |
214 (define-key map "\e\t" 'octave-complete-symbol) | 209 (define-key map "\e\t" 'octave-complete-symbol) |
215 (define-key map "\M-\C-a" 'octave-beginning-of-defun) | 210 (define-key map "\M-\C-a" 'octave-beginning-of-defun) |
216 (define-key map "\M-\C-e" 'octave-end-of-defun) | 211 (define-key map "\M-\C-e" 'octave-end-of-defun) |
243 (define-key map "\C-c\C-i\C-f" 'octave-send-defun) | 238 (define-key map "\C-c\C-i\C-f" 'octave-send-defun) |
244 (define-key map "\C-c\C-i\C-r" 'octave-send-region) | 239 (define-key map "\C-c\C-i\C-r" 'octave-send-region) |
245 (define-key map "\C-c\C-i\C-s" 'octave-show-process-buffer) | 240 (define-key map "\C-c\C-i\C-s" 'octave-show-process-buffer) |
246 (define-key map "\C-c\C-i\C-h" 'octave-hide-process-buffer) | 241 (define-key map "\C-c\C-i\C-h" 'octave-hide-process-buffer) |
247 (define-key map "\C-c\C-i\C-k" 'octave-kill-process) | 242 (define-key map "\C-c\C-i\C-k" 'octave-kill-process) |
248 (setq octave-mode-map map))) | 243 map) |
244 "Keymap used in Octave mode.") | |
245 | |
249 | 246 |
250 (defvar octave-mode-menu | 247 (defvar octave-mode-menu |
251 (list "Octave" | 248 '("Octave" |
252 (list "Lines" | 249 '("Lines" |
253 ["Previous Code Line" octave-previous-code-line t] | 250 ["Previous Code Line" octave-previous-code-line t] |
254 ["Next Code Line" octave-next-code-line t] | 251 ["Next Code Line" octave-next-code-line t] |
255 ["Begin of Continuation" octave-beginning-of-line t] | 252 ["Begin of Continuation" octave-beginning-of-line t] |
256 ["End of Continuation" octave-end-of-line t] | 253 ["End of Continuation" octave-end-of-line t] |
257 ["Split Line at Point" octave-indent-new-comment-line t]) | 254 ["Split Line at Point" octave-indent-new-comment-line t]) |
258 (list "Blocks" | 255 '("Blocks" |
259 ["Next Block" octave-forward-block t] | 256 ["Next Block" octave-forward-block t] |
260 ["Previous Block" octave-backward-block t] | 257 ["Previous Block" octave-backward-block t] |
261 ["Down Block" octave-down-block t] | 258 ["Down Block" octave-down-block t] |
262 ["Up Block" octave-backward-up-block t] | 259 ["Up Block" octave-backward-up-block t] |
263 ["Mark Block" octave-mark-block t] | 260 ["Mark Block" octave-mark-block t] |
264 ["Close Block" octave-close-block t]) | 261 ["Close Block" octave-close-block t]) |
265 (list "Functions" | 262 '("Functions" |
266 ["Begin of Function" octave-beginning-of-defun t] | 263 ["Begin of Function" octave-beginning-of-defun t] |
267 ["End of Function" octave-end-of-defun t] | 264 ["End of Function" octave-end-of-defun t] |
268 ["Mark Function" octave-mark-defun t] | 265 ["Mark Function" octave-mark-defun t] |
269 ["Indent Function" octave-indent-defun t] | 266 ["Indent Function" octave-indent-defun t] |
270 ["Insert Function" octave-insert-defun t]) | 267 ["Insert Function" octave-insert-defun t]) |
271 "-" | 268 "-" |
272 (list "Debug" | 269 '("Debug" |
273 ["Send Current Line" octave-send-line t] | 270 ["Send Current Line" octave-send-line t] |
274 ["Send Current Block" octave-send-block t] | 271 ["Send Current Block" octave-send-block t] |
275 ["Send Current Function" octave-send-defun t] | 272 ["Send Current Function" octave-send-defun t] |
276 ["Send Region" octave-send-region t] | 273 ["Send Region" octave-send-region t] |
277 ["Show Process Buffer" octave-show-process-buffer t] | 274 ["Show Process Buffer" octave-show-process-buffer t] |
278 ["Hide Process Buffer" octave-hide-process-buffer t] | 275 ["Hide Process Buffer" octave-hide-process-buffer t] |
279 ["Kill Process" octave-kill-process t]) | 276 ["Kill Process" octave-kill-process t]) |
280 "-" | 277 "-" |
281 ["Indent Line" indent-according-to-mode t] | 278 ["Indent Line" indent-according-to-mode t] |
282 ["Complete Symbol" octave-complete-symbol t] | 279 ["Complete Symbol" octave-complete-symbol t] |
283 "-" | 280 "-" |
284 ["Toggle Abbrev Mode" abbrev-mode t] | 281 ["Toggle Abbrev Mode" abbrev-mode t] |
285 ["Toggle Auto-Fill Mode" auto-fill-mode t] | 282 ["Toggle Auto-Fill Mode" auto-fill-mode t] |
286 "-" | 283 "-" |
287 ["Submit Bug Report" octave-submit-bug-report t] | 284 ["Submit Bug Report" octave-submit-bug-report t] |
288 "-" | 285 "-" |
289 ["Describe Octave Mode" octave-describe-major-mode t] | 286 ["Describe Octave Mode" octave-describe-major-mode t] |
290 ["Lookup Octave Index" octave-help t]) | 287 ["Lookup Octave Index" octave-help t]) |
291 "Menu for Octave mode.") | 288 "Menu for Octave mode.") |
292 | 289 |
293 (defvar octave-mode-syntax-table | 290 (defvar octave-mode-syntax-table |
294 (let ((table (make-syntax-table))) | 291 (let ((table (make-syntax-table))) |
295 (modify-syntax-entry ?\r " " table) | 292 (modify-syntax-entry ?\r " " table) |
314 (modify-syntax-entry ?\n ">" table) | 311 (modify-syntax-entry ?\n ">" table) |
315 table) | 312 table) |
316 "Syntax table in use in `octave-mode' buffers.") | 313 "Syntax table in use in `octave-mode' buffers.") |
317 | 314 |
318 (defcustom octave-auto-indent nil | 315 (defcustom octave-auto-indent nil |
319 "*Non-nil means indent line after a semicolon or space in Octave mode." | 316 "Non-nil means indent line after a semicolon or space in Octave mode." |
320 :type 'boolean | 317 :type 'boolean |
321 :group 'octave) | 318 :group 'octave) |
322 | 319 |
323 (defcustom octave-auto-newline nil | 320 (defcustom octave-auto-newline nil |
324 "*Non-nil means automatically newline after a semicolon in Octave mode." | 321 "Non-nil means automatically newline after a semicolon in Octave mode." |
325 :type 'boolean | 322 :type 'boolean |
326 :group 'octave) | 323 :group 'octave) |
327 | 324 |
328 (defcustom octave-blink-matching-block t | 325 (defcustom octave-blink-matching-block t |
329 "*Control the blinking of matching Octave block keywords. | 326 "Control the blinking of matching Octave block keywords. |
330 Non-nil means show matching begin of block when inserting a space, | 327 Non-nil means show matching begin of block when inserting a space, |
331 newline or semicolon after an else or end keyword." | 328 newline or semicolon after an else or end keyword." |
332 :type 'boolean | 329 :type 'boolean |
333 :group 'octave) | 330 :group 'octave) |
334 (defcustom octave-block-offset 2 | 331 (defcustom octave-block-offset 2 |
335 "*Extra indentation applied to statements in Octave block structures." | 332 "Extra indentation applied to statements in Octave block structures." |
336 :type 'integer | 333 :type 'integer |
337 :group 'octave) | 334 :group 'octave) |
338 | 335 |
339 (defvar octave-block-begin-regexp | 336 (defvar octave-block-begin-regexp |
340 (concat "\\<\\(" | 337 (concat "\\<\\(" |
368 (defvar octave-block-comment-start | 365 (defvar octave-block-comment-start |
369 (concat (make-string 2 octave-comment-char) " ") | 366 (concat (make-string 2 octave-comment-char) " ") |
370 "String to insert to start a new Octave comment on an empty line.") | 367 "String to insert to start a new Octave comment on an empty line.") |
371 | 368 |
372 (defcustom octave-continuation-offset 4 | 369 (defcustom octave-continuation-offset 4 |
373 "*Extra indentation applied to Octave continuation lines." | 370 "Extra indentation applied to Octave continuation lines." |
374 :type 'integer | 371 :type 'integer |
375 :group 'octave) | 372 :group 'octave) |
376 (defvar octave-continuation-regexp | 373 (defvar octave-continuation-regexp |
377 "[^#%\n]*\\(\\\\\\|\\.\\.\\.\\)\\s-*\\(\\s<.*\\)?$") | 374 "[^#%\n]*\\(\\\\\\|\\.\\.\\.\\)\\s-*\\(\\s<.*\\)?$") |
378 (defcustom octave-continuation-string "\\" | 375 (defcustom octave-continuation-string "\\" |
379 "*Character string used for Octave continuation lines. Normally \\." | 376 "Character string used for Octave continuation lines. Normally \\." |
380 :type 'string | 377 :type 'string |
381 :group 'octave) | 378 :group 'octave) |
382 | 379 |
383 (defvar octave-completion-alist nil | 380 (defvar octave-completion-alist nil |
384 "Alist of Octave symbols for completion in Octave mode. | 381 "Alist of Octave symbols for completion in Octave mode. |
390 (list | 387 (list |
391 ;; Functions | 388 ;; Functions |
392 (list nil octave-function-header-regexp 3)) | 389 (list nil octave-function-header-regexp 3)) |
393 "Imenu expression for Octave mode. See `imenu-generic-expression'.") | 390 "Imenu expression for Octave mode. See `imenu-generic-expression'.") |
394 | 391 |
395 (defcustom octave-mode-startup-message t | |
396 "*nil means do not display the Octave mode startup message." | |
397 :type 'boolean | |
398 :group 'octave) | |
399 | |
400 (defcustom octave-mode-hook nil | 392 (defcustom octave-mode-hook nil |
401 "*Hook to be run when Octave mode is started." | 393 "Hook to be run when Octave mode is started." |
402 :type 'hook | 394 :type 'hook |
403 :group 'octave) | 395 :group 'octave) |
404 | 396 |
405 (defcustom octave-send-show-buffer t | 397 (defcustom octave-send-show-buffer t |
406 "*Non-nil means display `inferior-octave-buffer' after sending to it." | 398 "Non-nil means display `inferior-octave-buffer' after sending to it." |
407 :type 'boolean | 399 :type 'boolean |
408 :group 'octave) | 400 :group 'octave) |
409 (defcustom octave-send-line-auto-forward t | 401 (defcustom octave-send-line-auto-forward t |
410 "*Control auto-forward after sending to the inferior Octave process. | 402 "Control auto-forward after sending to the inferior Octave process. |
411 Non-nil means always go to the next Octave code line after sending." | 403 Non-nil means always go to the next Octave code line after sending." |
412 :type 'boolean | 404 :type 'boolean |
413 :group 'octave) | 405 :group 'octave) |
414 (defcustom octave-send-echo-input t | 406 (defcustom octave-send-echo-input t |
415 "*Non-nil means echo input sent to the inferior Octave process." | 407 "Non-nil means echo input sent to the inferior Octave process." |
416 :type 'boolean | 408 :type 'boolean |
417 :group 'octave) | 409 :group 'octave) |
418 | 410 |
419 | 411 |
420 ;;;###autoload | 412 ;;;###autoload |
421 (defun octave-mode () | 413 (defun octave-mode () |
422 "Major mode for editing Octave code. | 414 "Major mode for editing Octave code. |
423 | 415 |
424 This mode makes it easier to write Octave code by helping with | 416 This mode makes it easier to write Octave code by helping with |
425 indentation, doing some of the typing for you (with Abbrev mode) and by | 417 indentation, doing some of the typing for you (with Abbrev mode) and by |
426 showing keywords, comments, strings, etc. in different faces (with | 418 showing keywords, comments, strings, etc.. in different faces (with |
427 Font Lock mode on terminals that support it). | 419 Font Lock mode on terminals that support it). |
428 | 420 |
429 Octave itself is a high-level language, primarily intended for numerical | 421 Octave itself is a high-level language, primarily intended for numerical |
430 computations. It provides a convenient command line interface for | 422 computations. It provides a convenient command line interface for |
431 solving linear and nonlinear problems numerically. Function definitions | 423 solving linear and nonlinear problems numerically. Function definitions |
444 \\{octave-mode-map} | 436 \\{octave-mode-map} |
445 | 437 |
446 Variables you can use to customize Octave mode | 438 Variables you can use to customize Octave mode |
447 ============================================== | 439 ============================================== |
448 | 440 |
449 octave-auto-indent | 441 `octave-auto-indent' |
450 Non-nil means indent current line after a semicolon or space. | 442 Non-nil means indent current line after a semicolon or space. |
451 Default is nil. | 443 Default is nil. |
452 | 444 |
453 octave-auto-newline | 445 `octave-auto-newline' |
454 Non-nil means auto-insert a newline and indent after a semicolon. | 446 Non-nil means auto-insert a newline and indent after a semicolon. |
455 Default is nil. | 447 Default is nil. |
456 | 448 |
457 octave-blink-matching-block | 449 `octave-blink-matching-block' |
458 Non-nil means show matching begin of block when inserting a space, | 450 Non-nil means show matching begin of block when inserting a space, |
459 newline or semicolon after an else or end keyword. Default is t. | 451 newline or semicolon after an else or end keyword. Default is t. |
460 | 452 |
461 octave-block-offset | 453 `octave-block-offset' |
462 Extra indentation applied to statements in block structures. | 454 Extra indentation applied to statements in block structures. |
463 Default is 2. | 455 Default is 2. |
464 | 456 |
465 octave-continuation-offset | 457 `octave-continuation-offset' |
466 Extra indentation applied to Octave continuation lines. | 458 Extra indentation applied to Octave continuation lines. |
467 Default is 4. | 459 Default is 4. |
468 | 460 |
469 octave-continuation-string | 461 `octave-continuation-string' |
470 String used for Octave continuation lines. | 462 String used for Octave continuation lines. |
471 Default is a backslash. | 463 Default is a backslash. |
472 | 464 |
473 octave-mode-startup-message | 465 `octave-send-echo-input' |
474 nil means do not display the Octave mode startup message. | |
475 Default is t. | |
476 | |
477 octave-send-echo-input | |
478 Non-nil means always display `inferior-octave-buffer' after sending a | 466 Non-nil means always display `inferior-octave-buffer' after sending a |
479 command to the inferior Octave process. | 467 command to the inferior Octave process. |
480 | 468 |
481 octave-send-line-auto-forward | 469 `octave-send-line-auto-forward' |
482 Non-nil means always go to the next unsent line of Octave code after | 470 Non-nil means always go to the next unsent line of Octave code after |
483 sending a line to the inferior Octave process. | 471 sending a line to the inferior Octave process. |
484 | 472 |
485 octave-send-echo-input | 473 `octave-send-echo-input' |
486 Non-nil means echo input sent to the inferior Octave process. | 474 Non-nil means echo input sent to the inferior Octave process. |
487 | 475 |
488 Turning on Octave mode runs the hook `octave-mode-hook'. | 476 Turning on Octave mode runs the hook `octave-mode-hook'. |
489 | 477 |
490 To begin using this mode for all `.m' files that you edit, add the | 478 To begin using this mode for all `.m' files that you edit, add the |
491 following lines to your `.emacs' file: | 479 following lines to your `.emacs' file: |
492 | 480 |
493 (autoload 'octave-mode \"octave-mod\" nil t) | 481 (add-to-list 'auto-mode-alist '(\"\\\\.m\\\\'\" . octave-mode)) |
494 (setq auto-mode-alist | 482 |
495 (cons '(\"\\\\.m$\" . octave-mode) auto-mode-alist)) | 483 To automatically turn on the abbrev and auto-fill, |
496 | |
497 To automatically turn on the abbrev, auto-fill and font-lock features, | |
498 add the following lines to your `.emacs' file as well: | 484 add the following lines to your `.emacs' file as well: |
499 | 485 |
500 (add-hook 'octave-mode-hook | 486 (add-hook 'octave-mode-hook |
501 (lambda () | 487 (lambda () |
502 (abbrev-mode 1) | 488 (abbrev-mode 1) |
503 (auto-fill-mode 1) | 489 (auto-fill-mode 1))) |
504 (if (eq window-system 'x) | |
505 (font-lock-mode 1)))) | |
506 | 490 |
507 To submit a problem report, enter \\[octave-submit-bug-report] from \ | 491 To submit a problem report, enter \\[octave-submit-bug-report] from \ |
508 an Octave mode buffer. | 492 an Octave mode buffer. |
509 This automatically sets up a mail buffer with version information | 493 This automatically sets up a mail buffer with version information |
510 already added. You just need to add a description of the problem, | 494 already added. You just need to add a description of the problem, |
771 (t | 755 (t |
772 (insert (concat " " octave-continuation-string)) | 756 (insert (concat " " octave-continuation-string)) |
773 (octave-reindent-then-newline-and-indent)))) | 757 (octave-reindent-then-newline-and-indent)))) |
774 | 758 |
775 (defun octave-indent-defun () | 759 (defun octave-indent-defun () |
776 "Properly indents the Octave function which contains point." | 760 "Properly indent the Octave function which contains point." |
777 (interactive) | 761 (interactive) |
778 (save-excursion | 762 (save-excursion |
779 (octave-mark-defun) | 763 (octave-mark-defun) |
780 (message "Indenting function...") | 764 (message "Indenting function...") |
781 (indent-region (point) (mark) nil)) | 765 (indent-region (point) (mark) nil)) |
854 (or (looking-at "\\s-*\\($\\|\\s<\\)") | 838 (or (looking-at "\\s-*\\($\\|\\s<\\)") |
855 (looking-at octave-continuation-regexp))) | 839 (looking-at octave-continuation-regexp))) |
856 (zerop (forward-line 1))))) | 840 (zerop (forward-line 1))))) |
857 (end-of-line))) | 841 (end-of-line))) |
858 | 842 |
859 (defun octave-scan-blocks (from count depth) | 843 (defun octave-scan-blocks (count depth) |
860 "Scan from character number FROM by COUNT Octave begin-end blocks. | 844 "Scan from point by COUNT Octave begin-end blocks. |
861 Returns the character number of the position thus found. | 845 Returns the character number of the position thus found. |
862 | 846 |
863 If DEPTH is nonzero, block depth begins counting from that value. | 847 If DEPTH is nonzero, block depth begins counting from that value. |
864 Only places where the depth in blocks becomes zero are candidates for | 848 Only places where the depth in blocks becomes zero are candidates for |
865 stopping; COUNT such places are counted. | 849 stopping; COUNT such places are counted. |
893 "Move forward across one balanced Octave begin-end block. | 877 "Move forward across one balanced Octave begin-end block. |
894 With argument, do it that many times. | 878 With argument, do it that many times. |
895 Negative arg -N means move backward across N blocks." | 879 Negative arg -N means move backward across N blocks." |
896 (interactive "p") | 880 (interactive "p") |
897 (or arg (setq arg 1)) | 881 (or arg (setq arg 1)) |
898 (goto-char (or (octave-scan-blocks (point) arg 0) (buffer-end arg)))) | 882 (goto-char (or (octave-scan-blocks arg 0) (buffer-end arg)))) |
899 | 883 |
900 (defun octave-backward-block (&optional arg) | 884 (defun octave-backward-block (&optional arg) |
901 "Move backward across one balanced Octave begin-end block. | 885 "Move backward across one balanced Octave begin-end block. |
902 With argument, do it that many times. | 886 With argument, do it that many times. |
903 Negative arg -N means move forward across N blocks." | 887 Negative arg -N means move forward across N blocks." |
911 A negative argument means move backward but still go down a level. | 895 A negative argument means move backward but still go down a level. |
912 In Lisp programs, an argument is required." | 896 In Lisp programs, an argument is required." |
913 (interactive "p") | 897 (interactive "p") |
914 (let ((inc (if (> arg 0) 1 -1))) | 898 (let ((inc (if (> arg 0) 1 -1))) |
915 (while (/= arg 0) | 899 (while (/= arg 0) |
916 (goto-char (or (octave-scan-blocks (point) inc -1) | 900 (goto-char (or (octave-scan-blocks inc -1) |
917 (buffer-end arg))) | 901 (buffer-end arg))) |
918 (setq arg (- arg inc))))) | 902 (setq arg (- arg inc))))) |
919 | 903 |
920 (defun octave-backward-up-block (arg) | 904 (defun octave-backward-up-block (arg) |
921 "Move backward out of one begin-end block level of Octave code. | 905 "Move backward out of one begin-end block level of Octave code. |
931 A negative argument means move backward but still to a less deep spot. | 915 A negative argument means move backward but still to a less deep spot. |
932 In Lisp programs, an argument is required." | 916 In Lisp programs, an argument is required." |
933 (interactive "p") | 917 (interactive "p") |
934 (let ((inc (if (> arg 0) 1 -1))) | 918 (let ((inc (if (> arg 0) 1 -1))) |
935 (while (/= arg 0) | 919 (while (/= arg 0) |
936 (goto-char (or (octave-scan-blocks (point) inc 1) | 920 (goto-char (or (octave-scan-blocks inc 1) |
937 (buffer-end arg))) | 921 (buffer-end arg))) |
938 (setq arg (- arg inc))))) | 922 (setq arg (- arg inc))))) |
939 | 923 |
940 (defun octave-mark-block () | 924 (defun octave-mark-block () |
941 "Put point at the beginning of this Octave block, mark at the end. | 925 "Put point at the beginning of this Octave block, mark at the end. |
1147 (setq give-up t)))) | 1131 (setq give-up t)))) |
1148 (not give-up)))) | 1132 (not give-up)))) |
1149 | 1133 |
1150 (defun octave-fill-paragraph (&optional arg) | 1134 (defun octave-fill-paragraph (&optional arg) |
1151 "Fill paragraph of Octave code, handling Octave comments." | 1135 "Fill paragraph of Octave code, handling Octave comments." |
1136 ;; FIXME: now that the default fill-paragraph takes care of similar issues, | |
1137 ;; this seems obsolete. --Stef | |
1152 (interactive "P") | 1138 (interactive "P") |
1153 (save-excursion | 1139 (save-excursion |
1154 (let ((end (progn (forward-paragraph) (point))) | 1140 (let ((end (progn (forward-paragraph) (point))) |
1155 (beg (progn | 1141 (beg (progn |
1156 (forward-paragraph -1) | 1142 (forward-paragraph -1) |
1387 (indent-according-to-mode)))) | 1373 (indent-according-to-mode)))) |
1388 | 1374 |
1389 | 1375 |
1390 ;;; Menu | 1376 ;;; Menu |
1391 (defun octave-add-octave-menu () | 1377 (defun octave-add-octave-menu () |
1392 "Adds the `Octave' menu to the menu bar in Octave mode." | 1378 "Add the `Octave' menu to the menu bar in Octave mode." |
1393 (require 'easymenu) | 1379 (require 'easymenu) |
1394 (easy-menu-define octave-mode-menu-map octave-mode-map | 1380 (easy-menu-define octave-mode-menu-map octave-mode-map |
1395 "Menu keymap for Octave mode." octave-mode-menu) | 1381 "Menu keymap for Octave mode." octave-mode-menu) |
1396 (easy-menu-add octave-mode-menu-map octave-mode-map)) | 1382 (easy-menu-add octave-mode-menu-map octave-mode-map)) |
1397 | 1383 |
1517 'octave-block-offset | 1503 'octave-block-offset |
1518 'octave-comment-char | 1504 'octave-comment-char |
1519 'octave-continuation-offset | 1505 'octave-continuation-offset |
1520 'octave-continuation-string | 1506 'octave-continuation-string |
1521 'octave-help-files | 1507 'octave-help-files |
1522 'octave-mode-startup-message | |
1523 'octave-send-echo-input | 1508 'octave-send-echo-input |
1524 'octave-send-line-auto-forward | 1509 'octave-send-line-auto-forward |
1525 'octave-send-show-buffer)))) | 1510 'octave-send-show-buffer)))) |
1526 | 1511 |
1527 ;;; provide ourself | 1512 ;;; provide ourself |
1528 | 1513 |
1529 (provide 'octave-mod) | 1514 (provide 'octave-mod) |
1530 | 1515 |
1531 ;;; arch-tag: 05f1ce09-be87-4c00-803e-4919ffa26c23 | 1516 ;; arch-tag: 05f1ce09-be87-4c00-803e-4919ffa26c23 |
1532 ;;; octave-mod.el ends here | 1517 ;;; octave-mod.el ends here |