diff options
| author | Stefan Monnier | 2010-08-17 17:49:30 +0200 |
|---|---|---|
| committer | Stefan Monnier | 2010-08-17 17:49:30 +0200 |
| commit | ff80a4464afb87bbd27d03d0e934793ba48070d6 (patch) | |
| tree | f594ae526c2ac052be4852a31f86aeb1c930c23d | |
| parent | 489cd5bd5a0128d6c3bee49fa2c451f2927ddea9 (diff) | |
| download | emacs-ff80a4464afb87bbd27d03d0e934793ba48070d6.tar.gz emacs-ff80a4464afb87bbd27d03d0e934793ba48070d6.zip | |
Font-lock '...' strings, plus various simplifications and fixes.
* lisp/progmodes/octave-mod.el (octave-font-lock-keywords): Use regexp-opt.
(octave-font-lock-close-quotes): New function.
(octave-font-lock-syntactic-keywords): New var.
(octave-mode): Use it. Set beginning-of-defun-function.
(octave-mode-map): Don't override the <foo>-defun commands.
(octave-mode-menu): Pass it directly to easy-menu-define;
remove (now generic) <foo>-defun commands; use info-lookup-symbol.
(octave-block-match-alist): Fix up last change so that
octave-close-block uses the more specific keyword.
(info-lookup-mode): Silence byte-compiler.
(octave-beginning-of-defun): Not interactive any more.
Optimize slightly.
(octave-end-of-defun, octave-mark-defun, octave-in-defun-p): Remove.
(octave-indent-defun, octave-send-defun): Use mark-defun instead.
(octave-completion-at-point-function): Make sure point is within
beg..end.
(octave-reindent-then-newline-and-indent):
Use reindent-then-newline-and-indent.
(octave-add-octave-menu): Remove.
| -rw-r--r-- | lisp/ChangeLog | 35 | ||||
| -rw-r--r-- | lisp/progmodes/octave-mod.el | 153 |
2 files changed, 88 insertions, 100 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0087163f097..39391e73609 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,26 @@ | |||
| 1 | 2010-08-17 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | Font-lock '...' strings, plus various simplifications and fixes. | ||
| 4 | * progmodes/octave-mod.el (octave-font-lock-keywords): Use regexp-opt. | ||
| 5 | (octave-font-lock-close-quotes): New function. | ||
| 6 | (octave-font-lock-syntactic-keywords): New var. | ||
| 7 | (octave-mode): Use it. Set beginning-of-defun-function. | ||
| 8 | (octave-mode-map): Don't override the <foo>-defun commands. | ||
| 9 | (octave-mode-menu): Pass it directly to easy-menu-define; | ||
| 10 | remove (now generic) <foo>-defun commands; use info-lookup-symbol. | ||
| 11 | (octave-block-match-alist): Fix up last change so that | ||
| 12 | octave-close-block uses the more specific keyword. | ||
| 13 | (info-lookup-mode): Silence byte-compiler. | ||
| 14 | (octave-beginning-of-defun): Not interactive any more. | ||
| 15 | Optimize slightly. | ||
| 16 | (octave-end-of-defun, octave-mark-defun, octave-in-defun-p): Remove. | ||
| 17 | (octave-indent-defun, octave-send-defun): Use mark-defun instead. | ||
| 18 | (octave-completion-at-point-function): Make sure point is within | ||
| 19 | beg..end. | ||
| 20 | (octave-reindent-then-newline-and-indent): | ||
| 21 | Use reindent-then-newline-and-indent. | ||
| 22 | (octave-add-octave-menu): Remove. | ||
| 23 | |||
| 1 | 2010-08-17 Jan Djärv <jan.h.d@swipnet.se> | 24 | 2010-08-17 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 25 | ||
| 3 | * mail/emacsbug.el (report-emacs-bug-insert-to-mailer) | 26 | * mail/emacsbug.el (report-emacs-bug-insert-to-mailer) |
| @@ -34,8 +57,8 @@ | |||
| 34 | 2010-08-15 Chong Yidong <cyd@stupidchicken.com> | 57 | 2010-08-15 Chong Yidong <cyd@stupidchicken.com> |
| 35 | 58 | ||
| 36 | * mouse.el (mouse--drag-set-mark-and-point): New function. | 59 | * mouse.el (mouse--drag-set-mark-and-point): New function. |
| 37 | (mouse-drag-track): Use LOCATION arg to push-mark. Use | 60 | (mouse-drag-track): Use LOCATION arg to push-mark. |
| 38 | mouse--drag-set-mark-and-point to take click-count into | 61 | Use mouse--drag-set-mark-and-point to take click-count into |
| 39 | consideration when updating point and mark (Bug#6840). | 62 | consideration when updating point and mark (Bug#6840). |
| 40 | 63 | ||
| 41 | 2010-08-15 Chong Yidong <cyd@stupidchicken.com> | 64 | 2010-08-15 Chong Yidong <cyd@stupidchicken.com> |
| @@ -45,8 +68,8 @@ | |||
| 45 | 68 | ||
| 46 | 2010-08-14 Štěpán Němec <stepnem@gmail.com> (tiny change) | 69 | 2010-08-14 Štěpán Němec <stepnem@gmail.com> (tiny change) |
| 47 | 70 | ||
| 48 | * font-lock.el (lisp-font-lock-keywords-2): Add | 71 | * font-lock.el (lisp-font-lock-keywords-2): |
| 49 | combine-after-change-calls, condition-case-no-debug, | 72 | Add combine-after-change-calls, condition-case-no-debug, |
| 50 | with-demoted-errors, and with-silent-modifications (Bug#6025). | 73 | with-demoted-errors, and with-silent-modifications (Bug#6025). |
| 51 | 74 | ||
| 52 | 2010-08-14 Kevin Ryde <user42@zip.com.au> | 75 | 2010-08-14 Kevin Ryde <user42@zip.com.au> |
| @@ -71,8 +94,8 @@ | |||
| 71 | (menu-bar-showhide-tool-bar-menu-customize-enable-left) | 94 | (menu-bar-showhide-tool-bar-menu-customize-enable-left) |
| 72 | (menu-bar-showhide-tool-bar-menu-customize-enable-right) | 95 | (menu-bar-showhide-tool-bar-menu-customize-enable-right) |
| 73 | (menu-bar-showhide-tool-bar-menu-customize-enable-top) | 96 | (menu-bar-showhide-tool-bar-menu-customize-enable-top) |
| 74 | (menu-bar-showhide-tool-bar-menu-customize-enable-bottom): Call | 97 | (menu-bar-showhide-tool-bar-menu-customize-enable-bottom): |
| 75 | menu-bar-set-tool-bar-position. | 98 | Call menu-bar-set-tool-bar-position. |
| 76 | 99 | ||
| 77 | 2010-08-12 Stefan Monnier <monnier@iro.umontreal.ca> | 100 | 2010-08-12 Stefan Monnier <monnier@iro.umontreal.ca> |
| 78 | 101 | ||
diff --git a/lisp/progmodes/octave-mod.el b/lisp/progmodes/octave-mod.el index 5287eff1347..382b817e80f 100644 --- a/lisp/progmodes/octave-mod.el +++ b/lisp/progmodes/octave-mod.el | |||
| @@ -171,9 +171,7 @@ parenthetical grouping.") | |||
| 171 | 'font-lock-builtin-face | 171 | 'font-lock-builtin-face |
| 172 | 'font-lock-preprocessor-face)) | 172 | 'font-lock-preprocessor-face)) |
| 173 | ;; Fontify all builtin variables. | 173 | ;; Fontify all builtin variables. |
| 174 | (cons (concat "\\<\\(" | 174 | (cons (concat "\\<" (regexp-opt octave-variables) "\\>") |
| 175 | (mapconcat 'identity octave-variables "\\|") | ||
| 176 | "\\)\\>") | ||
| 177 | 'font-lock-variable-name-face) | 175 | 'font-lock-variable-name-face) |
| 178 | ;; Fontify all function declarations. | 176 | ;; Fontify all function declarations. |
| 179 | (list octave-function-header-regexp | 177 | (list octave-function-header-regexp |
| @@ -181,6 +179,30 @@ parenthetical grouping.") | |||
| 181 | '(3 font-lock-function-name-face nil t))) | 179 | '(3 font-lock-function-name-face nil t))) |
| 182 | "Additional Octave expressions to highlight.") | 180 | "Additional Octave expressions to highlight.") |
| 183 | 181 | ||
| 182 | (defvar octave-font-lock-syntactic-keywords | ||
| 183 | ;; Try to distinguish the string-quotes from the transpose-quotes. | ||
| 184 | '(("[[({,; ]\\('\\)" (1 "\"'")) | ||
| 185 | (octave-font-lock-close-quotes))) | ||
| 186 | |||
| 187 | (defun octave-font-lock-close-quotes (limit) | ||
| 188 | "Fix the syntax-table of the closing quotes of single-quote strings." | ||
| 189 | ;; Freely inspired from perl-font-lock-special-syntactic-constructs. | ||
| 190 | (let ((state (syntax-ppss))) | ||
| 191 | (while (< (point) limit) | ||
| 192 | (cond | ||
| 193 | ((eq (nth 3 state) ?\') | ||
| 194 | ;; A '..' string. | ||
| 195 | (save-excursion | ||
| 196 | (when (and (or (looking-at "\\('\\)") | ||
| 197 | (re-search-forward "[^\\]\\(?:\\\\\\\\\\)*\\('\\)" | ||
| 198 | nil t)) | ||
| 199 | (not (eobp))) | ||
| 200 | (put-text-property (match-beginning 1) (match-end 1) | ||
| 201 | 'syntax-table (string-to-syntax "\"'")))))) | ||
| 202 | |||
| 203 | (setq state (parse-partial-sexp (point) limit nil nil state | ||
| 204 | 'syntax-table))))) | ||
| 205 | |||
| 184 | (defcustom inferior-octave-buffer "*Inferior Octave*" | 206 | (defcustom inferior-octave-buffer "*Inferior Octave*" |
| 185 | "Name of buffer for running an inferior Octave process." | 207 | "Name of buffer for running an inferior Octave process." |
| 186 | :type 'string | 208 | :type 'string |
| @@ -195,9 +217,6 @@ parenthetical grouping.") | |||
| 195 | (define-key map " " 'octave-electric-space) | 217 | (define-key map " " 'octave-electric-space) |
| 196 | (define-key map "\n" 'octave-reindent-then-newline-and-indent) | 218 | (define-key map "\n" 'octave-reindent-then-newline-and-indent) |
| 197 | (define-key map "\e\n" 'octave-indent-new-comment-line) | 219 | (define-key map "\e\n" 'octave-indent-new-comment-line) |
| 198 | (define-key map "\M-\C-a" 'octave-beginning-of-defun) | ||
| 199 | (define-key map "\M-\C-e" 'octave-end-of-defun) | ||
| 200 | (define-key map "\M-\C-h" 'octave-mark-defun) | ||
| 201 | (define-key map "\M-\C-q" 'octave-indent-defun) | 220 | (define-key map "\M-\C-q" 'octave-indent-defun) |
| 202 | (define-key map "\C-c\C-b" 'octave-submit-bug-report) | 221 | (define-key map "\C-c\C-b" 'octave-submit-bug-report) |
| 203 | (define-key map "\C-c\C-p" 'octave-previous-code-line) | 222 | (define-key map "\C-c\C-p" 'octave-previous-code-line) |
| @@ -231,7 +250,9 @@ parenthetical grouping.") | |||
| 231 | "Keymap used in Octave mode.") | 250 | "Keymap used in Octave mode.") |
| 232 | 251 | ||
| 233 | 252 | ||
| 234 | (defvar octave-mode-menu | 253 | |
| 254 | (easy-menu-define octave-mode-menu octave-mode-map | ||
| 255 | "Menu for Octave mode." | ||
| 235 | '("Octave" | 256 | '("Octave" |
| 236 | ("Lines" | 257 | ("Lines" |
| 237 | ["Previous Code Line" octave-previous-code-line t] | 258 | ["Previous Code Line" octave-previous-code-line t] |
| @@ -247,9 +268,6 @@ parenthetical grouping.") | |||
| 247 | ["Mark Block" octave-mark-block t] | 268 | ["Mark Block" octave-mark-block t] |
| 248 | ["Close Block" octave-close-block t]) | 269 | ["Close Block" octave-close-block t]) |
| 249 | ("Functions" | 270 | ("Functions" |
| 250 | ["Begin of Function" octave-beginning-of-defun t] | ||
| 251 | ["End of Function" octave-end-of-defun t] | ||
| 252 | ["Mark Function" octave-mark-defun t] | ||
| 253 | ["Indent Function" octave-indent-defun t] | 271 | ["Indent Function" octave-indent-defun t] |
| 254 | ["Insert Function" octave-insert-defun t]) | 272 | ["Insert Function" octave-insert-defun t]) |
| 255 | "-" | 273 | "-" |
| @@ -265,14 +283,14 @@ parenthetical grouping.") | |||
| 265 | ["Indent Line" indent-according-to-mode t] | 283 | ["Indent Line" indent-according-to-mode t] |
| 266 | ["Complete Symbol" completion-at-point t] | 284 | ["Complete Symbol" completion-at-point t] |
| 267 | "-" | 285 | "-" |
| 286 | ;; FIXME: Make them toggle-buttons. | ||
| 268 | ["Toggle Abbrev Mode" abbrev-mode t] | 287 | ["Toggle Abbrev Mode" abbrev-mode t] |
| 269 | ["Toggle Auto-Fill Mode" auto-fill-mode t] | 288 | ["Toggle Auto-Fill Mode" auto-fill-mode t] |
| 270 | "-" | 289 | "-" |
| 271 | ["Submit Bug Report" octave-submit-bug-report t] | 290 | ["Submit Bug Report" octave-submit-bug-report t] |
| 272 | "-" | 291 | "-" |
| 273 | ["Describe Octave Mode" describe-mode t] | 292 | ["Describe Octave Mode" describe-mode t] |
| 274 | ["Lookup Octave Index" octave-help t]) | 293 | ["Lookup Octave Index" info-lookup-symbol t])) |
| 275 | "Menu for Octave mode.") | ||
| 276 | 294 | ||
| 277 | (defvar octave-mode-syntax-table | 295 | (defvar octave-mode-syntax-table |
| 278 | (let ((table (make-syntax-table))) | 296 | (let ((table (make-syntax-table))) |
| @@ -324,6 +342,7 @@ Non-nil means show matching begin of block when inserting a space, | |||
| 324 | newline or semicolon after an else or end keyword." | 342 | newline or semicolon after an else or end keyword." |
| 325 | :type 'boolean | 343 | :type 'boolean |
| 326 | :group 'octave) | 344 | :group 'octave) |
| 345 | |||
| 327 | (defcustom octave-block-offset 2 | 346 | (defcustom octave-block-offset 2 |
| 328 | "Extra indentation applied to statements in Octave block structures." | 347 | "Extra indentation applied to statements in Octave block structures." |
| 329 | :type 'integer | 348 | :type 'integer |
| @@ -347,13 +366,13 @@ newline or semicolon after an else or end keyword." | |||
| 347 | (concat octave-block-else-regexp "\\|" octave-block-end-regexp)) | 366 | (concat octave-block-else-regexp "\\|" octave-block-end-regexp)) |
| 348 | (defvar octave-block-match-alist | 367 | (defvar octave-block-match-alist |
| 349 | '(("do" . ("until")) | 368 | '(("do" . ("until")) |
| 350 | ("for" . ("endfor" "end")) | 369 | ("for" . ("end" "endfor")) |
| 351 | ("function" . ("endfunction")) | 370 | ("function" . ("end" "endfunction")) |
| 352 | ("if" . ("else" "elseif" "endif" "end")) | 371 | ("if" . ("else" "elseif" "end" "endif")) |
| 353 | ("switch" . ("case" "otherwise" "endswitch" "end")) | 372 | ("switch" . ("case" "otherwise" "end" "endswitch")) |
| 354 | ("try" . ("catch" "end_try_catch")) | 373 | ("try" . ("catch" "end" "end_try_catch")) |
| 355 | ("unwind_protect" . ("unwind_protect_cleanup" "end_unwind_protect")) | 374 | ("unwind_protect" . ("unwind_protect_cleanup" "end" "end_unwind_protect")) |
| 356 | ("while" . ("endwhile" "end"))) | 375 | ("while" . ("end" "endwhile"))) |
| 357 | "Alist with Octave's matching block keywords. | 376 | "Alist with Octave's matching block keywords. |
| 358 | Has Octave's begin keywords as keys and a list of the matching else or | 377 | Has Octave's begin keywords as keys and a list of the matching else or |
| 359 | end keywords as associated values.") | 378 | end keywords as associated values.") |
| @@ -514,7 +533,9 @@ including a reproducible test case and send the message." | |||
| 514 | (set (make-local-variable 'normal-auto-fill-function) 'octave-auto-fill) | 533 | (set (make-local-variable 'normal-auto-fill-function) 'octave-auto-fill) |
| 515 | 534 | ||
| 516 | (set (make-local-variable 'font-lock-defaults) | 535 | (set (make-local-variable 'font-lock-defaults) |
| 517 | '(octave-font-lock-keywords nil nil)) | 536 | '(octave-font-lock-keywords nil nil nil nil |
| 537 | (font-lock-syntactic-keywords . octave-font-lock-syntactic-keywords) | ||
| 538 | (parse-sexp-lookup-properties . t))) | ||
| 518 | 539 | ||
| 519 | (set (make-local-variable 'imenu-generic-expression) | 540 | (set (make-local-variable 'imenu-generic-expression) |
| 520 | octave-mode-imenu-generic-expression) | 541 | octave-mode-imenu-generic-expression) |
| @@ -522,11 +543,15 @@ including a reproducible test case and send the message." | |||
| 522 | 543 | ||
| 523 | (add-hook 'completion-at-point-functions | 544 | (add-hook 'completion-at-point-functions |
| 524 | 'octave-completion-at-point-function nil t) | 545 | 'octave-completion-at-point-function nil t) |
| 546 | (set (make-local-variable 'beginning-of-defun-function) | ||
| 547 | 'octave-beginning-of-defun) | ||
| 525 | 548 | ||
| 526 | (octave-add-octave-menu) | 549 | (easy-menu-add octave-mode-menu) |
| 527 | (octave-initialize-completions) | 550 | (octave-initialize-completions) |
| 528 | (run-mode-hooks 'octave-mode-hook)) | 551 | (run-mode-hooks 'octave-mode-hook)) |
| 529 | 552 | ||
| 553 | (defvar info-lookup-mode) | ||
| 554 | |||
| 530 | (defun octave-help () | 555 | (defun octave-help () |
| 531 | "Get help on Octave symbols from the Octave info files. | 556 | "Get help on Octave symbols from the Octave info files. |
| 532 | Look up symbol in the function, operator and variable indices of the info files." | 557 | Look up symbol in the function, operator and variable indices of the info files." |
| @@ -583,22 +608,6 @@ to end after the end keyword." | |||
| 583 | (let ((case-fold-search nil)) | 608 | (let ((case-fold-search nil)) |
| 584 | (re-search-backward regexp nil 'move count))) | 609 | (re-search-backward regexp nil 'move count))) |
| 585 | 610 | ||
| 586 | (defun octave-in-defun-p () | ||
| 587 | "Return t if point is inside an Octave function declaration. | ||
| 588 | The function is taken to start at the `f' of `function' and to end after | ||
| 589 | the end keyword." | ||
| 590 | (let ((pos (point))) | ||
| 591 | (save-excursion | ||
| 592 | (or (and (octave-looking-at-kw "\\<function\\>") | ||
| 593 | (octave-not-in-string-or-comment-p)) | ||
| 594 | (and (octave-beginning-of-defun) | ||
| 595 | (condition-case nil | ||
| 596 | (progn | ||
| 597 | (octave-forward-block) | ||
| 598 | t) | ||
| 599 | (error nil)) | ||
| 600 | (< pos (point))))))) | ||
| 601 | |||
| 602 | (defun octave-maybe-insert-continuation-string () | 611 | (defun octave-maybe-insert-continuation-string () |
| 603 | (if (or (octave-in-comment-p) | 612 | (if (or (octave-in-comment-p) |
| 604 | (save-excursion | 613 | (save-excursion |
| @@ -733,7 +742,7 @@ The new line is properly indented." | |||
| 733 | "Properly indent the Octave function which contains point." | 742 | "Properly indent the Octave function which contains point." |
| 734 | (interactive) | 743 | (interactive) |
| 735 | (save-excursion | 744 | (save-excursion |
| 736 | (octave-mark-defun) | 745 | (mark-defun) |
| 737 | (message "Indenting function...") | 746 | (message "Indenting function...") |
| 738 | (indent-region (point) (mark) nil)) | 747 | (indent-region (point) (mark) nil)) |
| 739 | (message "Indenting function...done.")) | 748 | (message "Indenting function...done.")) |
| @@ -990,16 +999,16 @@ Signal an error if the keywords are incompatible." | |||
| 990 | With positive ARG, do it that many times. Negative argument -N means | 999 | With positive ARG, do it that many times. Negative argument -N means |
| 991 | move forward to Nth following beginning of a function. | 1000 | move forward to Nth following beginning of a function. |
| 992 | Returns t unless search stops at the beginning or end of the buffer." | 1001 | Returns t unless search stops at the beginning or end of the buffer." |
| 993 | (interactive "p") | ||
| 994 | (let* ((arg (or arg 1)) | 1002 | (let* ((arg (or arg 1)) |
| 995 | (inc (if (> arg 0) 1 -1)) | 1003 | (inc (if (> arg 0) 1 -1)) |
| 996 | (found)) | 1004 | (found nil) |
| 1005 | (case-fold-search nil)) | ||
| 997 | (and (not (eobp)) | 1006 | (and (not (eobp)) |
| 998 | (not (and (> arg 0) (octave-looking-at-kw "\\<function\\>"))) | 1007 | (not (and (> arg 0) (looking-at "\\<function\\>"))) |
| 999 | (skip-syntax-forward "w")) | 1008 | (skip-syntax-forward "w")) |
| 1000 | (while (and (/= arg 0) | 1009 | (while (and (/= arg 0) |
| 1001 | (setq found | 1010 | (setq found |
| 1002 | (octave-re-search-backward-kw "\\<function\\>" inc))) | 1011 | (re-search-backward "\\<function\\>" inc))) |
| 1003 | (if (octave-not-in-string-or-comment-p) | 1012 | (if (octave-not-in-string-or-comment-p) |
| 1004 | (setq arg (- arg inc)))) | 1013 | (setq arg (- arg inc)))) |
| 1005 | (if found | 1014 | (if found |
| @@ -1007,40 +1016,6 @@ Returns t unless search stops at the beginning or end of the buffer." | |||
| 1007 | (and (< inc 0) (goto-char (match-beginning 0))) | 1016 | (and (< inc 0) (goto-char (match-beginning 0))) |
| 1008 | t)))) | 1017 | t)))) |
| 1009 | 1018 | ||
| 1010 | (defun octave-end-of-defun (&optional arg) | ||
| 1011 | "Move forward to the end of an Octave function. | ||
| 1012 | With positive ARG, do it that many times. Negative argument -N means | ||
| 1013 | move back to Nth preceding end of a function. | ||
| 1014 | |||
| 1015 | An end of a function occurs right after the end keyword matching the | ||
| 1016 | `function' keyword that starts the function." | ||
| 1017 | (interactive "p") | ||
| 1018 | (or arg (setq arg 1)) | ||
| 1019 | (and (< arg 0) (skip-syntax-backward "w")) | ||
| 1020 | (and (> arg 0) (skip-syntax-forward "w")) | ||
| 1021 | (if (octave-in-defun-p) | ||
| 1022 | (setq arg (- arg 1))) | ||
| 1023 | (if (= arg 0) (setq arg -1)) | ||
| 1024 | (if (octave-beginning-of-defun (- arg)) | ||
| 1025 | (octave-forward-block))) | ||
| 1026 | |||
| 1027 | (defun octave-mark-defun () | ||
| 1028 | "Put point at the beginning of this Octave function, mark at its end. | ||
| 1029 | The function marked is the one containing point or following point." | ||
| 1030 | (interactive) | ||
| 1031 | (let ((pos (point))) | ||
| 1032 | (if (or (octave-in-defun-p) | ||
| 1033 | (and (octave-beginning-of-defun -1) | ||
| 1034 | (octave-in-defun-p))) | ||
| 1035 | (progn | ||
| 1036 | (skip-syntax-forward "w") | ||
| 1037 | (octave-beginning-of-defun) | ||
| 1038 | (push-mark (point)) | ||
| 1039 | (octave-end-of-defun) | ||
| 1040 | (exchange-point-and-mark)) | ||
| 1041 | (goto-char pos) | ||
| 1042 | (message "No function to mark found")))) | ||
| 1043 | |||
| 1044 | 1019 | ||
| 1045 | ;;; Filling | 1020 | ;;; Filling |
| 1046 | (defun octave-auto-fill () | 1021 | (defun octave-auto-fill () |
| @@ -1195,9 +1170,11 @@ otherwise." | |||
| 1195 | (defun octave-completion-at-point-function () | 1170 | (defun octave-completion-at-point-function () |
| 1196 | "Find the text to complete and the corresponding table." | 1171 | "Find the text to complete and the corresponding table." |
| 1197 | (let* ((beg (save-excursion (backward-sexp 1) (point))) | 1172 | (let* ((beg (save-excursion (backward-sexp 1) (point))) |
| 1198 | (end (if (< beg (point)) | 1173 | (end (point))) |
| 1199 | (save-excursion (goto-char beg) (forward-sexp 1) (point)) | 1174 | (if (< beg (point)) |
| 1200 | (point)))) | 1175 | ;; Extend region past point, if applicable. |
| 1176 | (save-excursion (goto-char beg) (forward-sexp 1) | ||
| 1177 | (setq end (max end (point))))) | ||
| 1201 | (list beg end octave-completion-alist))) | 1178 | (list beg end octave-completion-alist))) |
| 1202 | 1179 | ||
| 1203 | (defun octave-complete-symbol () | 1180 | (defun octave-complete-symbol () |
| @@ -1211,15 +1188,12 @@ variables." | |||
| 1211 | (defun octave-reindent-then-newline-and-indent () | 1188 | (defun octave-reindent-then-newline-and-indent () |
| 1212 | "Reindent current Octave line, insert newline, and indent the new line. | 1189 | "Reindent current Octave line, insert newline, and indent the new line. |
| 1213 | If Abbrev mode is on, expand abbrevs first." | 1190 | If Abbrev mode is on, expand abbrevs first." |
| 1191 | ;; FIXME: None of this is Octave-specific. | ||
| 1214 | (interactive) | 1192 | (interactive) |
| 1215 | (if abbrev-mode (expand-abbrev)) | 1193 | (if abbrev-mode (expand-abbrev)) |
| 1216 | (if octave-blink-matching-block | 1194 | (if octave-blink-matching-block |
| 1217 | (octave-blink-matching-block-open)) | 1195 | (octave-blink-matching-block-open)) |
| 1218 | (save-excursion | 1196 | (reindent-then-newline-and-indent)) |
| 1219 | (delete-region (point) (progn (skip-chars-backward " \t") (point))) | ||
| 1220 | (indent-according-to-mode)) | ||
| 1221 | (insert "\n") | ||
| 1222 | (indent-according-to-mode)) | ||
| 1223 | 1197 | ||
| 1224 | (defun octave-electric-semi () | 1198 | (defun octave-electric-semi () |
| 1225 | "Insert a semicolon in Octave mode. | 1199 | "Insert a semicolon in Octave mode. |
| @@ -1301,15 +1275,6 @@ entered without parens)." | |||
| 1301 | \n _ \n | 1275 | \n _ \n |
| 1302 | "endfunction" > \n) | 1276 | "endfunction" > \n) |
| 1303 | 1277 | ||
| 1304 | ;;; Menu | ||
| 1305 | (defun octave-add-octave-menu () | ||
| 1306 | "Add the `Octave' menu to the menu bar in Octave mode." | ||
| 1307 | (require 'easymenu) | ||
| 1308 | (easy-menu-define octave-mode-menu-map octave-mode-map | ||
| 1309 | "Menu keymap for Octave mode." octave-mode-menu) | ||
| 1310 | (easy-menu-add octave-mode-menu-map octave-mode-map)) | ||
| 1311 | |||
| 1312 | |||
| 1313 | ;;; Communication with the inferior Octave process | 1278 | ;;; Communication with the inferior Octave process |
| 1314 | (defun octave-kill-process () | 1279 | (defun octave-kill-process () |
| 1315 | "Kill inferior Octave process and its buffer." | 1280 | "Kill inferior Octave process and its buffer." |
| @@ -1375,7 +1340,7 @@ entered without parens)." | |||
| 1375 | "Send current Octave function to the inferior Octave process." | 1340 | "Send current Octave function to the inferior Octave process." |
| 1376 | (interactive) | 1341 | (interactive) |
| 1377 | (save-excursion | 1342 | (save-excursion |
| 1378 | (octave-mark-defun) | 1343 | (mark-defun) |
| 1379 | (octave-send-region (point) (mark)))) | 1344 | (octave-send-region (point) (mark)))) |
| 1380 | 1345 | ||
| 1381 | (defun octave-send-line (&optional arg) | 1346 | (defun octave-send-line (&optional arg) |