Function: cperl-lineup
cperl-lineup is an interactive and byte-compiled function defined in
cperl-mode.el.gz.
Signature
(cperl-lineup BEG END &optional STEP MINSHIFT)
Documentation
Lineup construction in a region.
Beginning of region should be at the start of a construction. All first occurrences of this construction in the lines that are partially contained in the region are lined up at the same column.
MINSHIFT is the minimal amount of space to insert before the construction.
STEP is the tabwidth to position constructions.
If STEP is nil, cperl-lineup-step will be used
(or cperl-indent-level, if cperl-lineup-step is nil).
Will not move the position at the start to the left.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cperl-mode.el.gz
(defun cperl-lineup (beg end &optional step minshift)
"Lineup construction in a region.
Beginning of region should be at the start of a construction.
All first occurrences of this construction in the lines that are
partially contained in the region are lined up at the same column.
MINSHIFT is the minimal amount of space to insert before the construction.
STEP is the tabwidth to position constructions.
If STEP is nil, `cperl-lineup-step' will be used
\(or `cperl-indent-level', if `cperl-lineup-step' is nil).
Will not move the position at the start to the left."
(interactive "r")
(let (search col tcol seen)
(save-excursion
(goto-char end)
(end-of-line)
(setq end (point-marker))
(goto-char beg)
(skip-chars-forward " \t\f")
(setq beg (point-marker))
(indent-region beg end nil)
(goto-char beg)
(setq col (current-column))
;; Assuming that lineup is done on Perl syntax, this regexp
;; doesn't need to be unicode aware -- haj, 2021-09-10
(if (looking-at "[a-zA-Z0-9_]")
(if (looking-at "\\<[a-zA-Z0-9_]+\\>")
(setq search
(concat "\\<"
(regexp-quote
(buffer-substring (match-beginning 0)
(match-end 0))) "\\>"))
(error "Cannot line up in a middle of the word"))
(if (looking-at "$")
(error "Cannot line up end of line"))
(setq search (regexp-quote (char-to-string (following-char)))))
(setq step (or step cperl-lineup-step cperl-indent-level))
(or minshift (setq minshift 1))
(while (progn
(beginning-of-line 2)
(and (< (point) end)
(re-search-forward search end t)
(goto-char (match-beginning 0))))
(setq tcol (current-column) seen t)
(if (> tcol col) (setq col tcol)))
(or seen
(error "The construction to line up occurred only once"))
(goto-char beg)
(setq col (+ col minshift))
(if (/= (% col step) 0) (setq step (* step (1+ (/ col step)))))
(while
(progn
(cperl-make-indent col)
(beginning-of-line 2)
(and (< (point) end)
(re-search-forward search end t)
(goto-char (match-beginning 0)))))))) ; No body