diff options
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/progmodes/octave.el | 25 |
2 files changed, 27 insertions, 2 deletions
| @@ -287,6 +287,10 @@ in (info "(emacs) Directory Variables") | |||
| 287 | 287 | ||
| 288 | * Changes in Specialized Modes and Packages in Emacs 27.1 | 288 | * Changes in Specialized Modes and Packages in Emacs 27.1 |
| 289 | 289 | ||
| 290 | ** Octave mode | ||
| 291 | The mode is automatically enabled in files that start with the | ||
| 292 | 'function' keyword. | ||
| 293 | |||
| 290 | ** project.el | 294 | ** project.el |
| 291 | *** New commands project-search and project-query-replace | 295 | *** New commands project-search and project-query-replace |
| 292 | 296 | ||
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 984bb73c73e..13510eef805 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el | |||
| @@ -170,8 +170,8 @@ parenthetical grouping.") | |||
| 170 | (modify-syntax-entry ?. "." table) | 170 | (modify-syntax-entry ?. "." table) |
| 171 | (modify-syntax-entry ?\" "\"" table) | 171 | (modify-syntax-entry ?\" "\"" table) |
| 172 | (modify-syntax-entry ?_ "_" table) | 172 | (modify-syntax-entry ?_ "_" table) |
| 173 | ;; The "b" flag only applies to the second letter of the comstart | 173 | ;; The "b" flag only applies to the second letter of the comstart and |
| 174 | ;; and the first letter of the comend, i.e. the "4b" below is ineffective. | 174 | ;; the first letter of the comend, i.e. a "4b" below would be ineffective. |
| 175 | ;; If we try to put `b' on the single-line comments, we get a similar | 175 | ;; If we try to put `b' on the single-line comments, we get a similar |
| 176 | ;; problem where the % and # chars appear as first chars of the 2-char | 176 | ;; problem where the % and # chars appear as first chars of the 2-char |
| 177 | ;; comend, so the multi-line ender is also turned into style-b. | 177 | ;; comend, so the multi-line ender is also turned into style-b. |
| @@ -533,6 +533,27 @@ Non-nil means always go to the next Octave code line after sending." | |||
| 533 | 533 | ||
| 534 | (defvar electric-layout-rules) | 534 | (defvar electric-layout-rules) |
| 535 | 535 | ||
| 536 | ;; FIXME: cc-mode.el also adds an entry for .m files, mapping them to | ||
| 537 | ;; objc-mode. We here rely on the fact that loaddefs.el is filled in | ||
| 538 | ;; alphabetical order, so cc-mode.el comes before octave-mode.el, which lets | ||
| 539 | ;; our entry come first! | ||
| 540 | ;;;###autoload (add-to-list 'auto-mode-alist '("\\.m\\'" . octave-maybe-mode)) | ||
| 541 | |||
| 542 | ;;;###autoload | ||
| 543 | (defun octave-maybe-mode () | ||
| 544 | "Select `octave-mode' if the current buffer seems to hold Octave code." | ||
| 545 | (if (save-excursion | ||
| 546 | (with-syntax-table octave-mode-syntax-table | ||
| 547 | (goto-char (point-min)) | ||
| 548 | (forward-comment (point-max)) | ||
| 549 | ;; FIXME: What about Octave files which don't start with "function"? | ||
| 550 | (looking-at "function"))) | ||
| 551 | (octave-mode) | ||
| 552 | (let ((x (rassq 'octave-maybe-mode auto-mode-alist))) | ||
| 553 | (when x | ||
| 554 | (let ((auto-mode-alist (remove x auto-mode-alist))) | ||
| 555 | (set-auto-mode)))))) | ||
| 556 | |||
| 536 | ;;;###autoload | 557 | ;;;###autoload |
| 537 | (define-derived-mode octave-mode prog-mode "Octave" | 558 | (define-derived-mode octave-mode prog-mode "Octave" |
| 538 | "Major mode for editing Octave code. | 559 | "Major mode for editing Octave code. |