diff options
Diffstat (limited to 'sx.el')
-rw-r--r-- | sx.el | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -188,6 +188,27 @@ Anything before the (sub)domain is removed." (rx string-start (or (and (0+ word) (optional ":") "//"))) "" url))) +(defun sx--unindent-text (text) + "Remove indentation from TEXT." + (with-temp-buffer + (insert text) + (goto-char (point-min)) + (let (result) + (while (null (eobp)) + (skip-chars-forward "[:blank:]") + (unless (looking-at "$") + (push (current-column) result)) + (forward-line 1)) + (when result + (let ((rx (format "^ \\{0,%s\\}" + (apply #'min result)))) + (goto-char (point-min)) + (while (and (null (eobp)) + (search-forward-regexp rx nil 'noerror)) + (replace-match "") + (forward-line 1))))) + (buffer-string))) + ;;; Printing request data (defvar sx--overlays nil |