Function: perl-indent-line

perl-indent-line is a byte-compiled function defined in perl-mode.el.gz.

Signature

(perl-indent-line &optional NOCHANGE)

Documentation

Indent current line as Perl code.

Return the amount the indentation changed by, or (parse-state) if line starts in a quoted string.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/perl-mode.el.gz
(defun perl-indent-line (&optional nochange)
  "Indent current line as Perl code.
Return the amount the indentation
changed by, or (parse-state) if line starts in a quoted string."
  (let ((case-fold-search nil)
	(pos (- (point-max) (point)))
	beg indent shift-amt)
    (beginning-of-line)
    (setq beg (point))
    (setq shift-amt
	  (cond ((eq 1 (nth 7 (syntax-ppss))) 0) ;For doc sections!
		((listp (setq indent (perl-calculate-indent))) indent)
                ((eq 'noindent indent) indent)
		((looking-at (or nochange perl-nochange)) 0)
		(t
		 (skip-chars-forward " \t\f")
		 (setq indent (perl-indent-new-calculate nil indent))
		 (- indent (current-column)))))
    (skip-chars-forward " \t\f")
    (if (and (numberp shift-amt) (/= 0 shift-amt))
	(progn (delete-region beg (point))
	       (indent-to indent)))
    ;; If initial point was within line's indentation,
    ;; position after the indentation.  Else stay at same point in text.
    (if (> (- (point-max) pos) (point))
	(goto-char (- (point-max) pos)))
    shift-amt))