Function: cperl-indent-exp
cperl-indent-exp is an interactive and byte-compiled function defined
in cperl-mode.el.gz.
Signature
(cperl-indent-exp)
Documentation
Simple variant of indentation of continued-sexp.
Will not indent comment if it starts at comment-indent or looks like
continuation of the comment on the previous line.
If cperl-indent-region-fix-constructs, will improve spacing on
conditional/loop constructs.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cperl-mode.el.gz
(defun cperl-indent-exp ()
"Simple variant of indentation of continued-sexp.
Will not indent comment if it starts at `comment-indent' or looks like
continuation of the comment on the previous line.
If `cperl-indent-region-fix-constructs', will improve spacing on
conditional/loop constructs."
(interactive)
(save-excursion
(let ((tmp-end (line-end-position)) top done)
(save-excursion
(beginning-of-line)
(while (null done)
(setq top (point))
;; Plan A: if line has an unfinished paren-group, go to end-of-group
(while (= -1 (nth 0 (parse-partial-sexp (point) tmp-end -1)))
(setq top (point))) ; Get the outermost parens in line
(goto-char top)
(while (< (point) tmp-end)
(parse-partial-sexp (point) tmp-end nil t) ; To start-sexp or eol
(or (eolp) (forward-sexp 1)))
(if (> (point) tmp-end) ; Check for an unfinished block
nil
(if (eq ?\) (preceding-char))
;; closing parens can be preceded by up to three sexps
(progn ;; Plan B: find by REGEXP block followup this line
(setq top (point))
(condition-case nil
(progn
(forward-sexp -2)
(if (eq (following-char) ?$ ) ; for my $var (list)
(progn
(forward-sexp -1)
(if (looking-at "\\(state\\|my\\|local\\|our\\|field\\)\\>")
(forward-sexp -1))))
(if (looking-at
(concat "\\(elsif\\|if\\|unless\\|while\\|until"
"\\|try\\|catch\\|finally\\|defer"
"\\|for\\(each\\)?\\>\\(\\("
cperl-maybe-white-and-comment-rex
"\\(state\\|my\\|local\\|our\\|field\\)\\)?"
cperl-maybe-white-and-comment-rex
(rx (eval cperl--basic-variable-rx))
"\\)?\\)\\>"))
(progn
(goto-char top)
(forward-sexp 1)
(setq top (point)))
;; no block to be processed: expression ends here
(setq done t)))
(error (setq done t)))
(goto-char top))
(if (looking-at ; Try Plan C: continuation block
(concat cperl-maybe-white-and-comment-rex
"\\<\\(else\\|elsif\\|continue\\)\\>"))
(progn
(goto-char (match-end 0))
(setq tmp-end (line-end-position)))
(setq done t))))
(setq tmp-end (line-end-position)))
(goto-char tmp-end)
(setq tmp-end (point-marker)))
(if cperl-indent-region-fix-constructs
(cperl-fix-line-spacing tmp-end))
(cperl-indent-region (point) tmp-end))))