Function: table--remove-eol-spaces

table--remove-eol-spaces is a byte-compiled function defined in table.el.gz.

Signature

(table--remove-eol-spaces BEG END &optional BOL FORCE)

Documentation

Remove spaces at the end of each line in the BEG END region of current buffer.

When optional BOL is non-nil spaces at the beginning of line are removed. When optional FORCE is non-nil removal operation is enforced even when point is within the removal area.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/table.el.gz
(defun table--remove-eol-spaces (beg end &optional bol force)
  "Remove spaces at the end of each line in the BEG END region of current buffer.
When optional BOL is non-nil spaces at the beginning of line are
removed.  When optional FORCE is non-nil removal operation is enforced
even when point is within the removal area."
  (if (> beg end)
      (let ((tmp beg))
	(setq beg end)
	(setq end tmp)))
  (let ((saved-point (point-marker))
	(end-marker (copy-marker end)))
    (save-excursion
      (goto-char beg)
      (while (if bol (re-search-forward "^\\( +\\)" end-marker t)
	       (re-search-forward "\\( +\\)$" end-marker t))
	;; avoid removal that causes the saved point to lose its location.
	(if (and (null bol)
		 (<= (match-beginning 1) saved-point)
		 (<= saved-point (match-end 1))
		 (not force))
	    (delete-region saved-point (match-end 1))
	  (delete-region (match-beginning 1) (match-end 1)))))
    (set-marker saved-point nil)
    (set-marker end-marker nil)))