emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 84f7413: cperl-mode: Fix indentation for Emacs 26


From: Lars Ingebrigtsen
Subject: master 84f7413: cperl-mode: Fix indentation for Emacs 26
Date: Tue, 3 Nov 2020 09:29:42 -0500 (EST)

branch: master
commit 84f74136d374421d3eb6a71a2e248e2b369cddbe
Author: Harald Jörg <haj@posteo.de>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    cperl-mode: Fix indentation for Emacs 26
    
    * lisp/progmodes/cperl-mode.el (cperl-mode): Add a fix
    which is only required for Emacs versions older than 27.
    
    * test/lisp/progmodes/cperl-mode-tests.el (cperl-bug30393):
    Add a test to verify correct indentation (bug#30393).
---
 lisp/progmodes/cperl-mode.el                       |  3 +++
 .../cperl-mode-resources/cperl-bug-30393.pl        | 19 ++++++++++++++
 test/lisp/progmodes/cperl-mode-tests.el            | 29 ++++++++++++++++++++++
 3 files changed, 51 insertions(+)

diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index ebbea6b..6178cdf 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -1606,6 +1606,9 @@ or as help on variables `cperl-tips', `cperl-problems',
   (if (cperl-val 'cperl-electric-keywords)
       (abbrev-mode 1))
   (set-syntax-table cperl-mode-syntax-table)
+  ;; Workaround for Bug#30393, needed for Emacs 26.
+  (when (< emacs-major-version 27)
+    (setq-local open-paren-in-column-0-is-defun-start nil))
   ;; Until Emacs is multi-threaded, we do not actually need it local:
   (make-local-variable 'cperl-font-lock-multiline-start)
   (make-local-variable 'cperl-font-locking)
diff --git a/test/lisp/progmodes/cperl-mode-resources/cperl-bug-30393.pl 
b/test/lisp/progmodes/cperl-mode-resources/cperl-bug-30393.pl
new file mode 100644
index 0000000..01db7b5
--- /dev/null
+++ b/test/lisp/progmodes/cperl-mode-resources/cperl-bug-30393.pl
@@ -0,0 +1,19 @@
+# -------- bug#30393: input --------
+#
+          my $sql = "insert into jobs (id, priority) values (1, 2);";
+               my $sth = $dbh->prepare($sql) or die "bother";
+
+          my $sql = "insert into jobs
+(id, priority)
+values (1, 2);";
+               my $sth = $dbh->prepare($sql) or die "bother";
+# -------- bug#30393: expected output --------
+#
+my $sql = "insert into jobs (id, priority) values (1, 2);";
+my $sth = $dbh->prepare($sql) or die "bother";
+
+my $sql = "insert into jobs
+(id, priority)
+values (1, 2);";
+my $sth = $dbh->prepare($sql) or die "bother";
+# -------- bug#30393: end --------
diff --git a/test/lisp/progmodes/cperl-mode-tests.el 
b/test/lisp/progmodes/cperl-mode-tests.el
index dcde3b6..2977f10 100644
--- a/test/lisp/progmodes/cperl-mode-tests.el
+++ b/test/lisp/progmodes/cperl-mode-tests.el
@@ -220,6 +220,35 @@ point in the distant past, and is still broken in 
perl-mode. "
         (should (equal (nth 3 (syntax-ppss)) nil))
         (should (equal (nth 4 (syntax-ppss)) t))))))
 
+(ert-deftest cperl-bug30393 ()
+  "Verify that indentation is not disturbed by an open paren in col 0.
+Perl is not Lisp: An open paren in column 0 does not start a function."
+  (let ((file (ert-resource-file "cperl-bug-30393.pl")))
+    (with-temp-buffer
+      (insert-file-contents file)
+      (goto-char (point-min))
+      (while (re-search-forward
+              (concat "^# ?-+ \\_<\\(?1:.+?\\)\\_>: input ?-+\n"
+                      "\\(?2:\\(?:.*\n\\)+?\\)"
+                      "# ?-+ \\1: expected output ?-+\n"
+                      "\\(?3:\\(?:.*\n\\)+?\\)"
+                      "# ?-+ \\1: end ?-+")
+              nil t)
+        (let ((name (match-string 1))
+              (code (match-string 2))
+              (expected (match-string 3))
+              got)
+          (with-temp-buffer
+            (insert code)
+           (funcall cperl-test-mode)
+            (goto-char (point-min))
+            (while (null (eobp))
+              (cperl-indent-command)
+              (next-line))
+            (setq expected (concat "test case " name ":\n" expected))
+            (setq got (concat "test case " name ":\n" (buffer-string)))
+            (should (equal got expected))))))))
+
 (ert-deftest cperl-bug37127 ()
   "Verify that closing a paren in a regex goes without a message.
 Also check that the message is issued if the regex terminator is



reply via email to

[Prev in Thread] Current Thread [Next in Thread]