Function: cperl-indent-line
cperl-indent-line is a byte-compiled function defined in
cperl-mode.el.gz.
Signature
(cperl-indent-line &optional PARSE-DATA)
Documentation
Indent current line as Perl code.
Return the amount the indentation changed by. PARSE-DATA is used to save status between calls in a loop.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cperl-mode.el.gz
(defun cperl-indent-line (&optional parse-data)
"Indent current line as Perl code.
Return the amount the indentation changed by.
PARSE-DATA is used to save status between calls in a loop."
(let ((case-fold-search nil)
(pos (- (point-max) (point)))
indent i shift-amt)
(setq indent (cperl-calculate-indent parse-data)
i indent)
(beginning-of-line)
(cond ((or (eq indent nil) (eq indent t))
(setq indent (current-indentation) i nil))
;;((eq indent t) ; Never?
;; (setq indent (cperl-calculate-indent-within-comment)))
;;((looking-at "[ \t]*#")
;; (setq indent 0))
(t
(skip-chars-forward " \t")
(if (listp indent) (setq indent (car indent)))
(cond ((and (looking-at (rx (sequence (eval cperl--label-rx)
(not (in ":")))))
(null (get-text-property (point) 'syntax-type))
(not (looking-at (rx (eval cperl--false-label-rx)))))
(and (> indent 0)
(setq indent (max cperl-min-label-indent
(+ indent cperl-label-offset)))))
((= (following-char) ?})
(setq indent (- indent cperl-indent-level)))
((memq (following-char) '(?\) ?\])) ; To line up with opening paren.
(setq indent (+ indent cperl-close-paren-offset)))
((= (following-char) ?{)
(setq indent (+ indent cperl-brace-offset))))))
(skip-chars-forward " \t")
(setq shift-amt (and i (- indent (current-column))))
(if (or (not shift-amt)
(zerop shift-amt))
(if (> (- (point-max) pos) (point))
(goto-char (- (point-max) pos)))
;;(delete-region beg (point))
;;(indent-to indent)
(cperl-make-indent 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))