[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Zap-to-char behaviour

From: Luc Teirlinck
Subject: Re: Zap-to-char behaviour
Date: Wed, 21 May 2003 12:37:14 -0500 (CDT)

J. Marant wrote:

   Anyway, would it be of any annoyance to add a
   'zap-up-to-char' function which does the same as zap-to-char
   except from removing the character? (I'm currently
   not fluent at Elisp).

No, as John Paul Wallington already pointed out, all you need to do is
uncomment a comment in the function definition.  If you are planning
on using both functions, I would also suggest differentiating between
the two echo area messages.  Result:

(defun zap-up-to-char (arg char)
  "Kill up to, but not including ARG'th 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."
  (interactive "p\ncZap up to char: ")
  (kill-region (point) (progn
                         (search-forward (char-to-string char) nil nil arg)
                         (goto-char (if (> arg 0) (1- (point)) (1+ (point))))

The problem now is that if you want to keep the regular M-z binding to
zap-to-char, then you probably will need to bind the new command to a
longer key sequence and it takes only one keystroke to retype the
character anyway.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]