Function: zap-up-to-char

zap-up-to-char is an autoloaded, interactive and byte-compiled function defined in misc.el.gz.

Signature

(zap-up-to-char ARG CHAR)

Documentation

Kill up to, but not including ARGth occurrence of CHAR.

Case is ignored if case-fold-search is non-nil in the current buffer. Goes backward if ARG is negative; error if CHAR not found. Ignores CHAR at point.

Probably introduced at or before Emacs version 28.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/misc.el.gz
;; Variation of `zap-to-char'.

;;;###autoload
(defun zap-up-to-char (arg char)
  "Kill up to, but not including ARGth occurrence of CHAR.
Case is ignored if `case-fold-search' is non-nil in the current buffer.
Goes backward if ARG is negative; error if CHAR not found.
Ignores CHAR at point."
  (interactive (list (prefix-numeric-value current-prefix-arg)
		     (read-char-from-minibuffer "Zap up to char: "
						nil 'read-char-history)))
  (let ((direction (if (>= arg 0) 1 -1)))
    (kill-region (point)
		 (progn
		   (forward-char direction)
		   (unwind-protect
		       (search-forward (char-to-string char) nil nil arg)
		     (backward-char direction))
		   (point)))))