Commit 87347a5b authored by Stefan Monnier's avatar Stefan Monnier

* lisp/progmodes/perl-mode.el (perl-calculate-indent): Indent qw(...)

Fix initialization of `state`.
Special-case `qw(...)` because we do want to indent its contents.
parent 904146cf
Pipeline #4059 failed with stage
in 59 minutes and 58 seconds
......@@ -935,15 +935,24 @@ changed by, or (parse-state) if line starts in a quoted string."
In usual case returns an integer: the column to indent to.
Returns (parse-state) if line starts inside a string."
(save-excursion
(let ((indent-point (point))
(case-fold-search nil)
(colon-line-end 0)
prev-char
state containing-sexp)
(setq containing-sexp (nth 1 (syntax-ppss indent-point)))
(let* ((indent-point (point))
(case-fold-search nil)
(colon-line-end 0)
prev-char
(state (syntax-ppss))
(containing-sexp (nth 1 state))
;; Don't auto-indent in a quoted string or a here-document.
(unindentable (or (nth 3 state) (eq 2 (nth 7 state)))))
(when (and (eq t (nth 3 state))
(save-excursion
(goto-char (nth 8 state))
(looking-back "qw[ \t]*" (- (point) 4))))
;; qw(...) is a list of words so the spacing is not meaningful,
;; and makes indentation possible (and desirable).
(setq unindentable nil)
(setq containing-sexp (nth 8 state)))
(cond
;; Don't auto-indent in a quoted string or a here-document.
((or (nth 3 state) (eq 2 (nth 7 state))) 'noindent)
(unindentable 'noindent)
((null containing-sexp) ; Line is at top level.
(skip-chars-forward " \t\f")
(if (memq (following-char)
......@@ -965,7 +974,11 @@ Returns (parse-state) if line starts inside a string."
;; arg2
;; );
(progn
(skip-syntax-backward "(")
;; Go just before the open paren (don't rely on the
;; skip-syntax-backward to jump over it, because it could
;; have string-fence syntax instead!).
(goto-char containing-sexp)
(skip-syntax-backward "(") ;FIXME: Not sure if still want this.
(condition-case nil
(while (save-excursion
(skip-syntax-backward " ") (not (bolp)))
......
......@@ -5,6 +5,12 @@ ($)
return 0;
}
# qw(...) is a quoted list of words, so we can and should indent its content!
my @tutu = qw[
tata
titi
];
my $hash = {
foo => 'bar',
format => 'some',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment