Function: kimport:unindent-region

kimport:unindent-region is a byte-compiled function defined in kimport.el.

Signature

(kimport:unindent-region START END)

Documentation

Calculate indent based upon the second line within the region START to END.

Remove the indent and return the remaining region as a string.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/kimport.el
(defun kimport:unindent-region (start end)
  "Calculate indent based upon the second line within the region START to END.
Remove the indent and return the remaining region as a string."
  (save-excursion
    (let (indent-regexp)
      (goto-char start)
      ;; Remove leading indent from lines in paragraph.  Base paragraph
      ;; indent on the 2nd paragraph line since the first line might be
      ;; further indented or outdented.
      (setq indent-regexp
	    (if (re-search-forward "[\n\r][ \t]+" end t)
		(concat "^" (make-string (current-column) ?\ ))))
      (if indent-regexp
	  (replace-regexp-in-string
			  indent-regexp "" (buffer-substring start end) nil t)
	(buffer-substring start end)))))