Function: kotl-mode:add-indent-to-region

kotl-mode:add-indent-to-region is a byte-compiled function defined in kotl-mode.el.

Signature

(kotl-mode:add-indent-to-region &optional INDENT START END)

Documentation

Add current cell's indent to current region.

Optionally, INDENT and region START and END may be given.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/kotl-mode.el
;; (defun kotl-mode:self-insert-command (n &optional c)
;;   "Insert the character you type.
;; Whichever character C you type to run this command is inserted.
;; The numeric prefix argument N says how many times to repeat the insertion.
;; Before insertion, `expand-abbrev’ is executed if the inserted character does
;; not have word syntax and the previous character in the buffer does.
;; After insertion, `internal-auto-fill’ is called if
;; `auto-fill-function’ is non-nil and if the `auto-fill-chars’ table has
;; a non-nil value for the inserted character.  At the end, it runs
;; `post-self-insert-hook’."
;;   (interactive (list (prefix-numeric-value current-prefix-arg) last-command-event))
;;   (kcell-view:operate
;;    (lambda () (self-insert-command n c))))

;;; ************************************************************************
;;; Private functions
;;; ************************************************************************

(defun kotl-mode:add-indent-to-region (&optional indent start end)
  "Add current cell's indent to current region.
Optionally, INDENT and region START and END may be given."
  (or (integerp indent) (setq indent (kcell-view:indent)))
  (save-excursion
    (save-restriction
      (narrow-to-region (or start (point)) (or end (mark t)))
      (goto-char (point-min))
      (let ((indent-str (concat "\n" (make-string indent ?\ ))))
	(while (search-forward "\n" nil t)
	  (replace-match indent-str t t))))))