diff options
| -rw-r--r-- | lisp/progmodes/perl-mode.el | 31 | ||||
| -rwxr-xr-x | test/manual/indent/perl.perl | 6 |
2 files changed, 28 insertions, 9 deletions
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index ab3680bfb76..2dcd0406277 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el | |||
| @@ -935,15 +935,24 @@ changed by, or (parse-state) if line starts in a quoted string." | |||
| 935 | In usual case returns an integer: the column to indent to. | 935 | In usual case returns an integer: the column to indent to. |
| 936 | Returns (parse-state) if line starts inside a string." | 936 | Returns (parse-state) if line starts inside a string." |
| 937 | (save-excursion | 937 | (save-excursion |
| 938 | (let ((indent-point (point)) | 938 | (let* ((indent-point (point)) |
| 939 | (case-fold-search nil) | 939 | (case-fold-search nil) |
| 940 | (colon-line-end 0) | 940 | (colon-line-end 0) |
| 941 | prev-char | 941 | prev-char |
| 942 | state containing-sexp) | 942 | (state (syntax-ppss)) |
| 943 | (setq containing-sexp (nth 1 (syntax-ppss indent-point))) | 943 | (containing-sexp (nth 1 state)) |
| 944 | ;; Don't auto-indent in a quoted string or a here-document. | ||
| 945 | (unindentable (or (nth 3 state) (eq 2 (nth 7 state))))) | ||
| 946 | (when (and (eq t (nth 3 state)) | ||
| 947 | (save-excursion | ||
| 948 | (goto-char (nth 8 state)) | ||
| 949 | (looking-back "qw[ \t]*" (- (point) 4)))) | ||
| 950 | ;; qw(...) is a list of words so the spacing is not meaningful, | ||
| 951 | ;; and makes indentation possible (and desirable). | ||
| 952 | (setq unindentable nil) | ||
| 953 | (setq containing-sexp (nth 8 state))) | ||
| 944 | (cond | 954 | (cond |
| 945 | ;; Don't auto-indent in a quoted string or a here-document. | 955 | (unindentable 'noindent) |
| 946 | ((or (nth 3 state) (eq 2 (nth 7 state))) 'noindent) | ||
| 947 | ((null containing-sexp) ; Line is at top level. | 956 | ((null containing-sexp) ; Line is at top level. |
| 948 | (skip-chars-forward " \t\f") | 957 | (skip-chars-forward " \t\f") |
| 949 | (if (memq (following-char) | 958 | (if (memq (following-char) |
| @@ -965,7 +974,11 @@ Returns (parse-state) if line starts inside a string." | |||
| 965 | ;; arg2 | 974 | ;; arg2 |
| 966 | ;; ); | 975 | ;; ); |
| 967 | (progn | 976 | (progn |
| 968 | (skip-syntax-backward "(") | 977 | ;; Go just before the open paren (don't rely on the |
| 978 | ;; skip-syntax-backward to jump over it, because it could | ||
| 979 | ;; have string-fence syntax instead!). | ||
| 980 | (goto-char containing-sexp) | ||
| 981 | (skip-syntax-backward "(") ;FIXME: Not sure if still want this. | ||
| 969 | (condition-case nil | 982 | (condition-case nil |
| 970 | (while (save-excursion | 983 | (while (save-excursion |
| 971 | (skip-syntax-backward " ") (not (bolp))) | 984 | (skip-syntax-backward " ") (not (bolp))) |
diff --git a/test/manual/indent/perl.perl b/test/manual/indent/perl.perl index 06f32e7f090..853aec49245 100755 --- a/test/manual/indent/perl.perl +++ b/test/manual/indent/perl.perl | |||
| @@ -5,6 +5,12 @@ sub add_funds($) { | |||
| 5 | return 0; | 5 | return 0; |
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | # qw(...) is a quoted list of words, so we can and should indent its content! | ||
| 9 | my @tutu = qw[ | ||
| 10 | tata | ||
| 11 | titi | ||
| 12 | ]; | ||
| 13 | |||
| 8 | my $hash = { | 14 | my $hash = { |
| 9 | foo => 'bar', | 15 | foo => 'bar', |
| 10 | format => 'some', | 16 | format => 'some', |