Function: org-do-remove-indentation

org-do-remove-indentation is a byte-compiled function defined in org-macs.el.gz.

Signature

(org-do-remove-indentation &optional N SKIP-FL)

Documentation

Remove the maximum common indentation from the buffer.

Do not consider invisible text when calculating indentation.

When optional argument N is a positive integer, remove exactly that much characters from indentation, if possible. When optional argument SKIP-FL is non-nil, skip the first line. Return nil if it fails.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-macs.el.gz
(defun org-do-remove-indentation (&optional n skip-fl)
  "Remove the maximum common indentation from the buffer.
Do not consider invisible text when calculating indentation.

When optional argument N is a positive integer, remove exactly
that much characters from indentation, if possible.  When
optional argument SKIP-FL is non-nil, skip the first
line.  Return nil if it fails."
  (catch :exit
    (goto-char (point-min))
    ;; Find maximum common indentation, if not specified.
    (let ((n (or n
		 (let ((min-ind (point-max)))
		   (save-excursion
                     (when skip-fl (forward-line))
		     (while (re-search-forward "^[ \t]*\\S-" nil t)
		       (let ((ind (org-current-text-indentation)))
			 (if (zerop ind) (throw :exit nil)
			   (setq min-ind (min min-ind ind))))))
		   min-ind))))
      (if (zerop n) (throw :exit nil)
	;; Remove exactly N indentation, but give up if not possible.
        (when skip-fl (forward-line))
	(while (not (eobp))
	  (let* ((buffer-invisibility-spec nil) ; do not treat invisible text specially
                 (ind (progn (skip-chars-forward " \t") (current-column))))
	    (cond ((< ind n)
                   (if (eolp) (delete-region (line-beginning-position) (point))
                     (throw :exit nil)))
		  (t (delete-region (line-beginning-position)
                                    (progn (move-to-column n t)
                                           (point)))))
	    (forward-line)))
	;; Signal success.
	t))))