Function: makefile-backslash-region
makefile-backslash-region is an interactive and byte-compiled function
defined in make-mode.el.gz.
Signature
(makefile-backslash-region FROM TO DELETE-FLAG)
Documentation
Insert, align, or delete end-of-line backslashes on the lines in the region.
With no argument, insert backslashes and align existing backslashes. With an argument, delete the backslashes.
This function does not modify the last line of the region if the region ends right at the start of the following line; it does not modify blank lines at the start of the region. So you can put the region around an entire macro definition and conveniently use this command.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/make-mode.el.gz
;; Backslashification. Stolen from cc-mode.el.
(defun makefile-backslash-region (from to delete-flag)
"Insert, align, or delete end-of-line backslashes on the lines in the region.
With no argument, insert backslashes and align existing backslashes.
With an argument, delete the backslashes.
This function does not modify the last line of the region if the region ends
right at the start of the following line; it does not modify blank lines
at the start of the region. So you can put the region around an entire macro
definition and conveniently use this command."
(interactive "r\nP")
(save-excursion
(goto-char from)
(let ((column makefile-backslash-column)
(endmark (copy-marker to)))
;; Compute the smallest column number past the ends of all the lines.
(when (and makefile-backslash-align (not delete-flag))
(while (< (point) to)
(end-of-line)
(when (= (preceding-char) ?\\)
(forward-char -1)
(skip-chars-backward " \t"))
(setq column (max column (1+ (current-column))))
(forward-line 1))
;; Adjust upward to a tab column, if that doesn't push
;; past the margin.
(if (> (% column tab-width) 0)
(let ((adjusted (* (/ (+ column tab-width -1) tab-width)
tab-width)))
(if (< adjusted (window-width))
(setq column adjusted)))))
;; Don't modify blank lines at start of region.
(goto-char from)
(while (and (< (point) endmark) (eolp))
(forward-line 1))
;; Add or remove backslashes on all the lines.
(while (and (< (point) endmark)
;; Don't backslashify the last line
;; if the region ends right at the start of the next line.
(save-excursion
(forward-line 1)
(< (point) endmark)))
(if (not delete-flag)
(makefile-append-backslash column)
(makefile-delete-backslash))
(forward-line 1))
(move-marker endmark nil))))