diff options
| author | Stefan Monnier | 2005-03-20 18:04:41 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-03-20 18:04:41 +0000 |
| commit | 92aba9ab38940b642bebd763dac852104c5c0127 (patch) | |
| tree | 266be6904f2b985e5def8e95a220799dea506c19 | |
| parent | ca79c816e86ab35ab2edbccce633ffc95437c221 (diff) | |
| download | emacs-92aba9ab38940b642bebd763dac852104c5c0127.tar.gz emacs-92aba9ab38940b642bebd763dac852104c5c0127.zip | |
(perl-indent-new-calculate): New function.
(perl-indent-line): Use it.
| -rw-r--r-- | lisp/progmodes/perl-mode.el | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index 3832a65c75c..c65ae0d284e 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el | |||
| @@ -653,20 +653,7 @@ changed by, or (parse-state) if line starts in a quoted string." | |||
| 653 | ((looking-at (or nochange perl-nochange)) 0) | 653 | ((looking-at (or nochange perl-nochange)) 0) |
| 654 | (t | 654 | (t |
| 655 | (skip-chars-forward " \t\f") | 655 | (skip-chars-forward " \t\f") |
| 656 | (cond ((looking-at "\\(\\w\\|\\s_\\)+:[^:]") | 656 | (setq indent (perl-indent-new-calculate nil indent bof)) |
| 657 | (setq indent (max 1 (+ indent perl-label-offset)))) | ||
| 658 | ((= (char-syntax (following-char)) ?\)) | ||
| 659 | (setq indent | ||
| 660 | (save-excursion | ||
| 661 | (forward-char 1) | ||
| 662 | (forward-sexp -1) | ||
| 663 | (forward-char 1) | ||
| 664 | (if (perl-hanging-paren-p) | ||
| 665 | (- indent perl-indent-level) | ||
| 666 | (forward-char -1) | ||
| 667 | (current-column))))) | ||
| 668 | ((= (following-char) ?{) | ||
| 669 | (setq indent (+ indent perl-brace-offset)))) | ||
| 670 | (- indent (current-column))))) | 657 | (- indent (current-column))))) |
| 671 | (skip-chars-forward " \t\f") | 658 | (skip-chars-forward " \t\f") |
| 672 | (if (and (numberp shift-amt) (/= 0 shift-amt)) | 659 | (if (and (numberp shift-amt) (/= 0 shift-amt)) |
| @@ -702,13 +689,30 @@ changed by, or (parse-state) if line starts in a quoted string." | |||
| 702 | (save-excursion | 689 | (save-excursion |
| 703 | (skip-syntax-backward " (") (not (bolp))))) | 690 | (skip-syntax-backward " (") (not (bolp))))) |
| 704 | 691 | ||
| 692 | (defun perl-indent-new-calculate (&optional virtual default parse-start) | ||
| 693 | (or | ||
| 694 | (and virtual (save-excursion (skip-chars-backward " \t") (bolp)) | ||
| 695 | (current-column)) | ||
| 696 | (and (looking-at "\\(\\w\\|\\s_\\)+:[^:]") | ||
| 697 | (max 1 (+ (or default (perl-calculate-indent parse-start)) | ||
| 698 | perl-label-offset))) | ||
| 699 | (and (= (char-syntax (following-char)) ?\)) | ||
| 700 | (save-excursion | ||
| 701 | (forward-char 1) | ||
| 702 | (forward-sexp -1) | ||
| 703 | (perl-indent-new-calculate 'virtual nil parse-start))) | ||
| 704 | (and (and (= (following-char) ?{) | ||
| 705 | (save-excursion (forward-char) (perl-hanging-paren-p))) | ||
| 706 | (+ (or default (perl-calculate-indent parse-start)) | ||
| 707 | perl-brace-offset)) | ||
| 708 | (or default (perl-calculate-indent parse-start)))) | ||
| 709 | |||
| 705 | (defun perl-calculate-indent (&optional parse-start) | 710 | (defun perl-calculate-indent (&optional parse-start) |
| 706 | "Return appropriate indentation for current line as Perl code. | 711 | "Return appropriate indentation for current line as Perl code. |
| 707 | In usual case returns an integer: the column to indent to. | 712 | In usual case returns an integer: the column to indent to. |
| 708 | Returns (parse-state) if line starts inside a string. | 713 | Returns (parse-state) if line starts inside a string. |
| 709 | Optional argument PARSE-START should be the position of `beginning-of-defun'." | 714 | Optional argument PARSE-START should be the position of `beginning-of-defun'." |
| 710 | (save-excursion | 715 | (save-excursion |
| 711 | (beginning-of-line) | ||
| 712 | (let ((indent-point (point)) | 716 | (let ((indent-point (point)) |
| 713 | (case-fold-search nil) | 717 | (case-fold-search nil) |
| 714 | (colon-line-end 0) | 718 | (colon-line-end 0) |