]> git.eshelyaron.com Git - emacs.git/commitdiff
Tweak octave continuation indentation
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 30 May 2021 04:25:47 +0000 (06:25 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 30 May 2021 04:25:47 +0000 (06:25 +0200)
* lisp/progmodes/octave.el (octave-smie-rules): Further tweak
continuation indentation (bug#17955).

lisp/progmodes/octave.el
test/lisp/progmodes/octave-tests.el [new file with mode: 0644]

index 5d877fc6ba32296fc5dd34f209d1b361eeeeeee3..aff3066c69866dad2d80dd1bf06b5eb10991685b 100644 (file)
@@ -461,7 +461,7 @@ Non-nil means always go to the next Octave code line after sending."
        ;; For (invalid) code between switch and case.
        ;; (if (smie-rule-parent-p "switch") 4)
        nil))
-    ('(:after . "=") octave-block-offset)))
+    ('(:after . "=") (smie-rule-parent octave-block-offset))))
 
 (defun octave-indent-comment ()
   "A function for `smie-indent-functions' (which see)."
diff --git a/test/lisp/progmodes/octave-tests.el b/test/lisp/progmodes/octave-tests.el
new file mode 100644 (file)
index 0000000..e28fe73
--- /dev/null
@@ -0,0 +1,49 @@
+;;; octave-tests.el --- Test suite for octave.el  -*- lexical-binding:t -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'ert)
+(require 'octave)
+
+(defun octave-test--indent (string)
+  (with-temp-buffer
+    (octave-mode)
+    (insert string)
+    (indent-region (point-min) (point-max))
+    (buffer-string)))
+
+(ert-deftest octave-tests--continuation-indentation ()
+  (should
+   (equal (octave-test--indent "a = b + a * \\
+c;
+")
+          "a = b + a * \\
+       c;
+"))
+  (should (equal (octave-test--indent "a = \\
+b;
+")
+                 "a = \\
+  b;
+")))
+
+;;; octave-tests.el ends here