Function: cperl-indent-region
cperl-indent-region is an interactive and byte-compiled function
defined in cperl-mode.el.gz.
Signature
(cperl-indent-region START END)
Documentation
Simple variant of indentation of region in CPerl mode.
Should be slow. Will not indent comment if it starts at comment-indent
or looks like continuation of the comment on the previous line.
Indents all the lines whose first character is between START and END
inclusive.
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-region (start end)
"Simple variant of indentation of region in CPerl mode.
Should be slow. Will not indent comment if it starts at `comment-indent'
or looks like continuation of the comment on the previous line.
Indents all the lines whose first character is between START and END
inclusive.
If `cperl-indent-region-fix-constructs', will improve spacing on
conditional/loop constructs."
(interactive "r")
(cperl-update-syntaxification end)
(save-excursion
(let (cperl-update-start cperl-update-end (h-a-c after-change-functions))
(let ((indent-info (list nil nil nil) ; Cannot use '(), since will modify
)
after-change-functions ; Speed it up!
comm old-comm-indent new-comm-indent i empty)
(if h-a-c (add-hook 'after-change-functions #'cperl-delay-update-hook))
(goto-char start)
(setq old-comm-indent (and (cperl-to-comment-or-eol)
(current-column))
new-comm-indent old-comm-indent)
(goto-char start)
(setq end (set-marker (make-marker) end)) ; indentation changes pos
(or (bolp) (beginning-of-line 2))
(while (and (<= (point) end) (not (eobp))) ; bol to check start
(if (or
(setq empty (looking-at "[ \t]*\n"))
(and (setq comm (looking-at "[ \t]*#"))
(or (eq (current-indentation) (or old-comm-indent
comment-column))
(setq old-comm-indent nil))))
(if (and old-comm-indent
(not empty)
(= (current-indentation) old-comm-indent)
(not (eq (get-text-property (point) 'syntax-type) 'pod))
(not (eq (get-text-property (point) 'syntax-table)
cperl-st-cfence)))
(let ((comment-column new-comm-indent))
(indent-for-comment)))
(progn
;; FIXME: It would be nice to keep indent-info, but this
;; doesn not work if the region contains continuation
;; lines (see `cperl-calculate-indent') -- haj 2023-06-30
(setq indent-info (list nil nil nil))
(setq i (cperl-indent-line indent-info))
(or comm
(not i)
(progn
(if cperl-indent-region-fix-constructs
(goto-char (cperl-fix-line-spacing end indent-info)))
(if (setq old-comm-indent
(and (cperl-to-comment-or-eol)
(not (memq (get-text-property (point)
'syntax-type)
'(pod here-doc)))
(not (eq (get-text-property (point)
'syntax-table)
cperl-st-cfence))
(current-column)))
(progn (indent-for-comment)
(skip-chars-backward " \t")
(skip-chars-backward "#")
(setq new-comm-indent (current-column))))))))
(beginning-of-line 2)))
;; Now run the update hooks
(and after-change-functions
cperl-update-end
(save-excursion
(goto-char cperl-update-end)
(insert " ")
(delete-char -1)
(goto-char cperl-update-start)
(insert " ")
(delete-char -1))))))