@rayslava Thanks! I'll try it later, when I have enough mental power to read what it does :blobcatgiggle:
Top-level
@rayslava Thanks! I'll try it later, when I have enough mental power to read what it does :blobcatgiggle: 4 comments
@rayslava Yay :) (defun zap-up-to-last-char (char) @rayslava Looking at the source of zap-up-to-char it needs to be a bit longer, so it could be used non-interactively… :) |
@tennoseremel yep.
Also, a one-line-shorter version that saves the zapped part into kill-ring:
(defun zap-up-to-last-char (char)
"Zap up to the last occurrence of `char' in the line"
(interactive "cZap up to char: ")
(let* ((start (point))
(end (save-excursion
(move-end-of-line 1)
(search-backward (char-to-string char) start t))))
(if end
(kill-region start end)
(error "Character not found"))))