Function: conf-align-assignments
conf-align-assignments is an interactive and byte-compiled function
defined in conf-mode.el.gz.
Signature
(conf-align-assignments &optional ARG)
Documentation
Align the assignments in the buffer or active region.
In Transient Mark mode, if the mark is active, operate on the contents of the region. Otherwise, operate on the whole buffer.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/conf-mode.el.gz
;; If anybody can figure out how to get the same effect by configuring
;; `align', I'd be glad to hear.
(defun conf-align-assignments (&optional arg)
"Align the assignments in the buffer or active region.
In Transient Mark mode, if the mark is active, operate on the
contents of the region. Otherwise, operate on the whole buffer."
(interactive "P")
(setq arg (if arg
(prefix-numeric-value arg)
conf-assignment-column))
(save-excursion
(save-restriction
(when (use-region-p)
(narrow-to-region (region-beginning) (region-end)))
(goto-char (point-min))
(while (not (eobp))
(let ((cs (comment-beginning))) ; go before comment if within
(if cs (goto-char cs)))
(while (forward-comment 9)) ; max-int?
(when (and (not (eobp))
(looking-at conf-assignment-regexp))
(goto-char (match-beginning 1))
(delete-region (point) (match-end 1))
(if conf-assignment-sign
(if (>= arg 0)
(progn
(indent-to-column arg)
(or (not conf-assignment-space)
(memq (char-before (point)) '(?\s ?\t)) (insert ?\s))
(insert conf-assignment-sign
(if (and conf-assignment-space (not (eolp))) ?\s "")))
(insert (if conf-assignment-space ?\s "") conf-assignment-sign)
(unless (eolp)
(indent-to-column (- arg))
(or (not conf-assignment-space)
(memq (char-before (point)) '(?\s ?\t)) (insert ?\s))))
(unless (eolp)
(if (>= (current-column) (abs arg))
(insert ?\s)
(indent-to-column (abs arg))))))
(forward-line)))))