Function: org-delete-indentation

org-delete-indentation is an interactive and byte-compiled function defined in org.el.gz.

Signature

(org-delete-indentation &optional ARG BEG END)

Documentation

Join current line to previous and fix whitespace at join.

If previous line is a headline add to headline title. Otherwise the function calls delete-indentation.

If there is a region (BEG END), then join the lines in that region.

With a non-nil prefix ARG, join the line with the following one, ignoring region.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-delete-indentation (&optional arg beg end)
  "Join current line to previous and fix whitespace at join.

If previous line is a headline add to headline title.  Otherwise
the function calls `delete-indentation'.

If there is a region (BEG END), then join the lines in that region.

With a non-nil prefix ARG, join the line with the following one,
ignoring region."
  (interactive
   (cons current-prefix-arg
         (when (and (not current-prefix-arg) (use-region-p))
           (list (region-beginning) (region-end)))))
  (unless (and beg end)
    ;; No region selected or BEG/END arguments not passed.
    (setq beg (line-beginning-position (if arg 1 0))
          end (line-end-position (if arg 2 1))))
  (if (save-excursion
        (goto-char beg)
        (forward-line 0)
        (and (< (line-end-position) end)
             (let ((case-fold-search nil))
	       (looking-at org-complex-heading-regexp))))
      ;; At headline.
      (let ((tags-column (when (match-beginning 5)
			   (save-excursion (goto-char (match-beginning 5))
					   (current-column))))
	    string)
        (goto-char beg)
        ;; Join all but headline.
        (save-excursion
          (save-match-data
            (if (version<= "27" emacs-version)
                (delete-indentation nil (line-beginning-position 2) end)
              ;; FIXME: Emacs 26.  `delete-indentation' does not yet
              ;; accept BEG/END arguments.
              (save-restriction
                (narrow-to-region beg end)
                (goto-char beg)
                (forward-line 2)
                (while (< (point) (point-max))
                  (delete-indentation)
                  (forward-line 1))))))
        (setq string (org-trim (delete-and-extract-region (line-end-position) (line-end-position 2))))
	(goto-char (or (match-end 4)
		       (match-beginning 5)
		       (match-end 0)))
	(skip-chars-backward " \t")
	(save-excursion (insert " " string))
	;; Adjust alignment of tags.
	(cond
	 ((not tags-column))		;no tags
	 (org-auto-align-tags (org-align-tags))
	 (t (org--align-tags-here tags-column)))) ;preserve tags column
    (if (version<= "27" emacs-version)
        (funcall-interactively #'delete-indentation arg beg end)
      ;; FIXME: Emacs 26.  `delete-indentation' does not yet
      ;; accept BEG/END arguments.
      (save-restriction
        (narrow-to-region beg end)
        (goto-char beg)
        (forward-line 1)
        (while (< (point) (point-max))
          (delete-indentation)
          (forward-line 1))))))