Function: org-unindent-buffer

org-unindent-buffer is an interactive and byte-compiled function defined in org.el.gz.

Signature

(org-unindent-buffer)

Documentation

Un-indent the visible part of the buffer.

Relative indentation (between items, inside blocks, etc.) isn't modified.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-unindent-buffer ()
  "Un-indent the visible part of the buffer.
Relative indentation (between items, inside blocks, etc.) isn't
modified."
  (interactive)
  (unless (eq major-mode 'org-mode)
    (user-error "Cannot un-indent a buffer not in Org mode"))
  (letrec ((parse-tree (org-element-parse-buffer 'greater-element nil 'defer))
	   (unindent-tree
	    (lambda (contents)
	      (dolist (element (reverse contents))
		(if (org-element-type-p element '(headline section))
		    (funcall unindent-tree (org-element-contents element))
		  (save-excursion
		    (save-restriction
		      (narrow-to-region
		       (org-element-begin element)
		       (org-element-end element))
		      (org-do-remove-indentation))))))))
    (funcall unindent-tree (org-element-contents parse-tree))))