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 &optional INTERACTIVE)
Documentation
Kill up to, but not including ARGth occurrence of CHAR.
When run interactively, the argument INTERACTIVE is non-nil.
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.
If called interactively, do a case sensitive search if CHAR
is an upper-case character.
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 &optional interactive)
"Kill up to, but not including ARGth occurrence of CHAR.
When run interactively, the argument INTERACTIVE is non-nil.
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.
If called interactively, do a case sensitive search if CHAR
is an upper-case character."
(interactive (list (prefix-numeric-value current-prefix-arg)
(read-char-from-minibuffer "Zap up to char: "
nil 'read-char-history)
t))
(let ((direction (if (>= arg 0) 1 -1))
(case-fold-search (if (and interactive (char-uppercase-p char))
nil
case-fold-search)))
(kill-region (point)
(progn
(forward-char direction)
(unwind-protect
(search-forward (char-to-string char) nil nil arg)
(backward-char direction))
(point)))))