diff options
| author | Gerd Moellmann | 2001-10-05 09:36:31 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-10-05 09:36:31 +0000 |
| commit | df3fd736fdf9515a1c3338999a90399481eb5c5d (patch) | |
| tree | 9f52537f0a978ca741b8879e88cc43262b3e999c | |
| parent | d8754ce5289bd855f19c9bd522c8aac7b79fa4e0 (diff) | |
| download | emacs-df3fd736fdf9515a1c3338999a90399481eb5c5d.tar.gz emacs-df3fd736fdf9515a1c3338999a90399481eb5c5d.zip | |
(perl-indent-continued-arguments): New var.
(perl-calculate-indent): Use it.
(perl-backward-to-noncomment): Use forward-comment.
| -rw-r--r-- | lisp/progmodes/perl-mode.el | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index 33ff6364390..c6a90cc0dd0 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el | |||
| @@ -250,6 +250,11 @@ This is in addition to `perl-continued-statement-offset'." | |||
| 250 | "*Offset of Perl label lines relative to usual indentation." | 250 | "*Offset of Perl label lines relative to usual indentation." |
| 251 | :type 'integer | 251 | :type 'integer |
| 252 | :group 'perl) | 252 | :group 'perl) |
| 253 | (defcustom perl-indent-continued-arguments nil | ||
| 254 | "*If non-nil offset of argument lines relative to usual indentation. | ||
| 255 | If nil, continued arguments are aligned with the first argument." | ||
| 256 | :type '(choice integer (const nil)) | ||
| 257 | :group 'perl) | ||
| 253 | 258 | ||
| 254 | (defcustom perl-tab-always-indent t | 259 | (defcustom perl-tab-always-indent t |
| 255 | "*Non-nil means TAB in Perl mode always indents the current line. | 260 | "*Non-nil means TAB in Perl mode always indents the current line. |
| @@ -283,32 +288,34 @@ Paragraphs are separated by blank lines only. | |||
| 283 | Delete converts tabs to spaces as it moves back. | 288 | Delete converts tabs to spaces as it moves back. |
| 284 | \\{perl-mode-map} | 289 | \\{perl-mode-map} |
| 285 | Variables controlling indentation style: | 290 | Variables controlling indentation style: |
| 286 | perl-tab-always-indent | 291 | `perl-tab-always-indent' |
| 287 | Non-nil means TAB in Perl mode should always indent the current line, | 292 | Non-nil means TAB in Perl mode should always indent the current line, |
| 288 | regardless of where in the line point is when the TAB command is used. | 293 | regardless of where in the line point is when the TAB command is used. |
| 289 | perl-tab-to-comment | 294 | `perl-tab-to-comment' |
| 290 | Non-nil means that for lines which don't need indenting, TAB will | 295 | Non-nil means that for lines which don't need indenting, TAB will |
| 291 | either delete an empty comment, indent an existing comment, move | 296 | either delete an empty comment, indent an existing comment, move |
| 292 | to end-of-line, or if at end-of-line already, create a new comment. | 297 | to end-of-line, or if at end-of-line already, create a new comment. |
| 293 | perl-nochange | 298 | `perl-nochange' |
| 294 | Lines starting with this regular expression are not auto-indented. | 299 | Lines starting with this regular expression are not auto-indented. |
| 295 | perl-indent-level | 300 | `perl-indent-level' |
| 296 | Indentation of Perl statements within surrounding block. | 301 | Indentation of Perl statements within surrounding block. |
| 297 | The surrounding block's indentation is the indentation | 302 | The surrounding block's indentation is the indentation |
| 298 | of the line on which the open-brace appears. | 303 | of the line on which the open-brace appears. |
| 299 | perl-continued-statement-offset | 304 | `perl-continued-statement-offset' |
| 300 | Extra indentation given to a substatement, such as the | 305 | Extra indentation given to a substatement, such as the |
| 301 | then-clause of an if or body of a while. | 306 | then-clause of an if or body of a while. |
| 302 | perl-continued-brace-offset | 307 | `perl-continued-brace-offset' |
| 303 | Extra indentation given to a brace that starts a substatement. | 308 | Extra indentation given to a brace that starts a substatement. |
| 304 | This is in addition to `perl-continued-statement-offset'. | 309 | This is in addition to `perl-continued-statement-offset'. |
| 305 | perl-brace-offset | 310 | `perl-brace-offset' |
| 306 | Extra indentation for line if it starts with an open brace. | 311 | Extra indentation for line if it starts with an open brace. |
| 307 | perl-brace-imaginary-offset | 312 | `perl-brace-imaginary-offset' |
| 308 | An open brace following other text is treated as if it were | 313 | An open brace following other text is treated as if it were |
| 309 | this far to the right of the start of its line. | 314 | this far to the right of the start of its line. |
| 310 | perl-label-offset | 315 | `perl-label-offset' |
| 311 | Extra indentation for line that is a label. | 316 | Extra indentation for line that is a label. |
| 317 | `perl-indent-continued-arguments' | ||
| 318 | Offset of argument lines relative to usual indentation. | ||
| 312 | 319 | ||
| 313 | Various indentation styles: K&R BSD BLK GNU LW | 320 | Various indentation styles: K&R BSD BLK GNU LW |
| 314 | perl-indent-level 5 8 0 2 4 | 321 | perl-indent-level 5 8 0 2 4 |
| @@ -423,23 +430,22 @@ possible action from the following list: | |||
| 423 | (if (and (not perl-tab-always-indent) | 430 | (if (and (not perl-tab-always-indent) |
| 424 | (> (current-column) (current-indentation))) | 431 | (> (current-column) (current-indentation))) |
| 425 | (insert-tab) | 432 | (insert-tab) |
| 426 | (let (bof lsexp delta (oldpnt (point))) | 433 | (let* ((oldpnt (point)) |
| 427 | (beginning-of-line) | 434 | (lsexp (progn (beginning-of-line) (point))) |
| 428 | (setq lsexp (point)) | 435 | (bof (perl-beginning-of-function)) |
| 429 | (setq bof (perl-beginning-of-function)) | 436 | (delta (progn |
| 430 | (goto-char oldpnt) | 437 | (goto-char oldpnt) |
| 431 | (setq delta (perl-indent-line "\f\\|;?#" bof)) | 438 | (perl-indent-line "\f\\|;?#" bof)))) |
| 432 | (and perl-tab-to-comment | 439 | (and perl-tab-to-comment |
| 433 | (= oldpnt (point)) ; done if point moved | 440 | (= oldpnt (point)) ; done if point moved |
| 434 | (if (listp delta) ; if line starts in a quoted string | 441 | (if (listp delta) ; if line starts in a quoted string |
| 435 | (setq lsexp (or (nth 2 delta) bof)) | 442 | (setq lsexp (or (nth 2 delta) bof)) |
| 436 | (= delta 0)) ; done if indenting occurred | 443 | (= delta 0)) ; done if indenting occurred |
| 437 | (let (eol state) | 444 | (let ((eol (progn (end-of-line) (point))) |
| 438 | (end-of-line) | 445 | state) |
| 439 | (setq eol (point)) | ||
| 440 | (if (= (char-after bof) ?=) | 446 | (if (= (char-after bof) ?=) |
| 441 | (if (= oldpnt eol) | 447 | (if (= oldpnt eol) |
| 442 | (message "In a format statement")) | 448 | (message "In a format statement")) |
| 443 | (setq state (parse-partial-sexp lsexp eol)) | 449 | (setq state (parse-partial-sexp lsexp eol)) |
| 444 | (if (nth 3 state) | 450 | (if (nth 3 state) |
| 445 | (if (= oldpnt eol) ; already at eol in a string | 451 | (if (= oldpnt eol) ; already at eol in a string |
| @@ -538,7 +544,6 @@ Returns (parse-state) if line starts inside a string." | |||
| 538 | (> indent-point (save-excursion (forward-sexp 1) (point)))) | 544 | (> indent-point (save-excursion (forward-sexp 1) (point)))) |
| 539 | (perl-beginning-of-function)) | 545 | (perl-beginning-of-function)) |
| 540 | (while (< (point) indent-point) ;repeat until right sexp | 546 | (while (< (point) indent-point) ;repeat until right sexp |
| 541 | (setq parse-start (point)) | ||
| 542 | (setq state (parse-partial-sexp (point) indent-point 0)) | 547 | (setq state (parse-partial-sexp (point) indent-point 0)) |
| 543 | ; state = (depth_in_parens innermost_containing_list last_complete_sexp | 548 | ; state = (depth_in_parens innermost_containing_list last_complete_sexp |
| 544 | ; string_terminator_or_nil inside_commentp following_quotep | 549 | ; string_terminator_or_nil inside_commentp following_quotep |
| @@ -559,8 +564,10 @@ Returns (parse-state) if line starts inside a string." | |||
| 559 | ;; line is expression, not statement: | 564 | ;; line is expression, not statement: |
| 560 | ;; indent to just after the surrounding open. | 565 | ;; indent to just after the surrounding open. |
| 561 | (goto-char (1+ containing-sexp)) | 566 | (goto-char (1+ containing-sexp)) |
| 562 | (skip-chars-forward " \t") | 567 | (if perl-indent-continued-arguments |
| 563 | (current-column)) | 568 | (+ perl-indent-continued-arguments (current-indentation)) |
| 569 | (skip-chars-forward " \t") | ||
| 570 | (current-column))) | ||
| 564 | (t | 571 | (t |
| 565 | ;; Statement level. Is it a continuation or a new statement? | 572 | ;; Statement level. Is it a continuation or a new statement? |
| 566 | (if (perl-continuation-line-p containing-sexp) | 573 | (if (perl-continuation-line-p containing-sexp) |
| @@ -633,19 +640,8 @@ Returns (parse-state) if line starts inside a string." | |||
| 633 | 640 | ||
| 634 | (defun perl-backward-to-noncomment () | 641 | (defun perl-backward-to-noncomment () |
| 635 | "Move point backward to after the first non-white-space, skipping comments." | 642 | "Move point backward to after the first non-white-space, skipping comments." |
| 636 | (interactive) | 643 | (interactive) ;why?? -stef |
| 637 | (let (opoint stop) | 644 | (forward-comment (- (point-max)))) |
| 638 | (while (not stop) | ||
| 639 | (setq opoint (point)) | ||
| 640 | (beginning-of-line) | ||
| 641 | (if (and comment-start-skip | ||
| 642 | (re-search-forward comment-start-skip opoint 'move 1)) | ||
| 643 | (progn (goto-char (match-end 1)) | ||
| 644 | (skip-chars-forward ";"))) | ||
| 645 | (skip-chars-backward " \t\f") | ||
| 646 | (setq stop (or (bobp) | ||
| 647 | (not (bolp)) | ||
| 648 | (forward-char -1)))))) | ||
| 649 | 645 | ||
| 650 | (defun perl-backward-to-start-of-continued-exp (lim) | 646 | (defun perl-backward-to-start-of-continued-exp (lim) |
| 651 | (if (= (preceding-char) ?\)) | 647 | (if (= (preceding-char) ?\)) |