Function: kotl-mode:kill-region

kotl-mode:kill-region is an interactive and byte-compiled function defined in kotl-mode.el.

Signature

(kotl-mode:kill-region START END &optional COPY-FLAG)

Documentation

Kill region between START and END within a single kcell.

With optional COPY-FLAG equal to t, copy region to kill ring but does not kill it. With COPY-FLAG any other non-nil value, return region as a string without affecting kill ring.

If called interactively, transient-mark-mode(var)/transient-mark-mode(fun) is non-nil, and there is no active region, copy any delimited selectable thing at point; see hui:delimited-selectable-thing.

If the buffer is read-only and COPY-FLAG is nil, the region will not be deleted but it will be copied to the kill ring and then an error will be signaled.

If a completion is active, this aborts the completion only.

Key Bindings

Aliases

kotl-mode:completion-kill-region

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/kotl-mode.el
(defun kotl-mode:kill-region (start end &optional copy-flag)
  "Kill region between START and END within a single kcell.
With optional COPY-FLAG equal to t, copy region to kill ring but does not
kill it.  With COPY-FLAG any other non-nil value, return region as a
string without affecting kill ring.

If called interactively, `transient-mark-mode' is non-nil, and
there is no active region, copy any delimited selectable thing at
point; see `hui:delimited-selectable-thing'.

If the buffer is read-only and COPY-FLAG is nil, the region will not be deleted
but it will be copied to the kill ring and then an error will be signaled.

If a completion is active, this aborts the completion only."
  (interactive
   (progn (barf-if-buffer-read-only)
	  (list (when mark-active (region-beginning))
		(when mark-active (region-end)))))
  (let ((read-only (and (not copy-flag) buffer-read-only))
	(kill-commands '(kill-region kill-ring-save kotl-mode:completion-kill-region
                         kotl-mode:kill-region kotl-mode:copy-region-as-kill))
	thing-and-bounds
	thing)
    (when read-only
      (setq copy-flag t))
    (prog1 (cond
	    ((eq last-command 'complete)
	     (delete-region (point) cmpl-last-insert-location)
	     (insert cmpl-original-string)
	     (setq completion-to-accept nil))
	    ;; If called interactively, transient-mark-mode is non-nil, and no region is active, copy thing at point
	    ((and (memq this-command kill-commands)
		  transient-mark-mode
		  (not (use-region-p))
		  (setq thing-and-bounds (hui:selectable-thing-and-bounds)
			thing (nth 1 thing-and-bounds)
			start (nth 2 thing-and-bounds)
			end   (nth 3 thing-and-bounds)))
	     (if (and copy-flag (not (eq copy-flag t)))
		 ;; Return thing as a string
		 thing
	       (kotl-mode:kill-or-copy-region start end copy-flag thing)))
	    ;; If no thing to process, copy region whether active or not
	    ((and (number-or-marker-p start)
		  (number-or-marker-p end)
		  (eq (kcell-view:cell start)
		      (kcell-view:cell end)))
	     (save-excursion
	       (goto-char start)
	       (kotl-mode:kill-or-copy-region start end copy-flag)))
	    (t (error "(kotl-mode:kill-region): Bad region or not within a single Koutline cell")))
      (when (and copy-flag (memq this-command kill-commands))
	(cond (thing
	       (message "Saved selectable thing: %s" thing))
	      ((mark t)
	       (indicate-copied-region)))))))