Function: kotl-mode:delete-char

kotl-mode:delete-char is an interactive and byte-compiled function defined in kotl-mode.el.

Signature

(kotl-mode:delete-char ARG &optional KILL-FLAG)

Documentation

Delete up to prefix ARG characters following point.

Return number of characters deleted. Optional KILL-FLAG non-nil means save in kill ring instead of deleting. Do not delete across cell boundaries.

Key Bindings

Aliases

kotl-mode:delete-forward-char

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/kotl-mode.el
(defun kotl-mode:delete-char (arg &optional kill-flag)
  "Delete up to prefix ARG characters following point.
Return number of characters deleted.
Optional KILL-FLAG non-nil means save in kill ring instead of deleting.
Do not delete across cell boundaries."
  (interactive "*p\nP")
  (unless (integerp arg)
    (signal 'wrong-type-argument (list 'integerp arg)))
  (cond ((and (use-region-p)
	      delete-active-region
	      (= arg 1))
	 ;; If a region is active, kill or delete it.
	 (if (or kill-flag
                 (eq delete-active-region 'kill))
	     (kotl-mode:kill-region (region-beginning) (region-end))
	   (kotl-mode:delete-region (region-beginning) (region-end))))
        (t
         (if (not (and (boundp 'kotl-kview) (kview:is-p kotl-kview)))
             ;; Support use within Org tables outside of the Koutliner
             (delete-char arg kill-flag)
           (let ((del-count 0)
                 (indent (kcell-view:indent))
                 count start end
                 kotl-mode:delete-char-acc)
             (cl-flet ((delete-char (arg &optional kill-flag)
                         (kotl-mode:delete-char-acc arg kill-flag)))
               (cond ((> arg 0)
                      (if (kotl-mode:eocp)
                          (error "(kotl-mode:delete-char): End of cell")
                        (setq end (kcell-view:end)
                              arg (min arg (- end (point))))
                        (while (and (> arg 0) (not (kotl-mode:eocp)))
                          (if (kotl-mode:eolp)
                              (if (not (eq ?\  (char-syntax (following-char))))
                                  (setq arg 0
                                        del-count (1- del-count))
                                (delete-char 1 kill-flag)
                                ;; There may be non-whitespace characters in the
                                ;; indent area.  Don't delete them.
                                (setq count indent)
                                (while (and (> count 0)
                                            (eq ?\ (char-syntax (following-char))))
                                  (delete-char 1)
                                  (setq count (1- count))))
                            (delete-char 1 kill-flag))
                          (setq arg (1- arg)
                                del-count (1+ del-count)))))
                     ((< arg 0)
                      (if (kotl-mode:bocp)
                          (error "(kotl-mode:delete-char): Beginning of cell")
                        (setq start (kcell-view:start)
                              arg (max arg (- start (point))))
                        (while (and (< arg 0) (not (kotl-mode:bocp)))
                          (if (kotl-mode:bolp)
                              (if (not (eq ?\  (char-syntax (preceding-char))))
                                  (setq arg 0
                                        del-count (1- del-count))
                                ;; There may be non-whitespace characters in the
                                ;; indent area.  Don't delete them.
                                (setq count indent)
                                (while (and (> count 0)
                                            (eq ?\ (char-syntax (preceding-char))))
                                  (delete-char -1)
                                  (setq count (1- count)))
                                (if (zerop count)
                                    (delete-char -1 kill-flag)))
                            (delete-char -1 kill-flag))
                          (setq arg (1+ arg)
                                del-count (1+ del-count)))))))
             del-count)))))