From: "Ehud Karni" <ehud@unix.mvs.co.il>
Cc: emacs-devel@gnu.org
Subject: Re: Zap-to-char behaviour
Date: Wed, 21 May 2003 23:31:43 +0300 [thread overview]
Message-ID: <200305212031.h4LKVheD021910@beta.mvs.co.il> (raw)
In-Reply-To: <200305211737.h4LHbEc08523@eel.dms.auburn.edu> (message from Luc Teirlinck on Wed, 21 May 2003 12:37:14 -0500 (CDT))
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wed, 21 May 2003 12:37:14 -0500 (CDT), Luc Teirlinck <teirllm@dms.auburn.edu> wrote:
>
> 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))))
> (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.
No, that is not enough, because, as RMS pointed out, running this a
second time (when arg = 1, the default) will do nothing. This will
make it inconsistent (2 times M-3 `zap-up-to-char' will be different
from 3 * M-2 `zap-up-to-char'). If you want a consistent function I
propose the following:
(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.
If ARG is 0, do nothing. If character at (point) is CHAR skip it."
(interactive "p\ncZap up to char: ")
(or (zerop arg)
(let ((direction (if (> arg 0) 1 -1)))
(kill-region (point)
(progn
(forward-char direction)
(search-forward (char-to-string char) nil nil arg)
(- (point) direction)))
(backward-char direction))))
This was was tested lightly and it seems consistent. The kill ring
is also seems OK when repeating the operation several times.
My personal opinion is that `zap-to-char' is good enough for me and
I don't need this one, but if you want it, it better be good.
Ehud.
- --
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
mailto:ehud@unix.mvs.co.il Better Safe Than Sorry
-----BEGIN PGP SIGNATURE-----
Comment: use http://www.keyserver.net/ to get my key (and others)
iD8DBQE+y+IuLFvTvpjqOY0RAmAiAJ0YLJxEe8cZhuZLKBIbNxRWMcJk5gCfY9Kj
QpPJf2tv/z+aHmQWFRwRz/w=
=CsQ7
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2003-05-21 20:31 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-21 16:30 Zap-to-char behaviour jmarant
2003-05-21 17:37 ` Luc Teirlinck
2003-05-21 19:03 ` Luc Teirlinck
2003-05-21 20:02 ` Jérôme Marant
2003-05-21 20:31 ` Ehud Karni [this message]
2003-05-21 20:50 ` Jérôme Marant
2003-05-21 21:58 ` Luc Teirlinck
2003-05-21 22:35 ` Luc Teirlinck
2003-05-23 12:04 ` Richard Stallman
2003-05-23 18:27 ` Jérôme Marant
-- strict thread matches above, loose matches on Subject: below --
2003-05-22 7:23 Jérôme Marant
2003-05-22 15:56 ` Luc Teirlinck
2003-05-22 21:04 ` Jérôme Marant
2003-05-20 20:40 Jérôme Marant
2003-05-20 20:59 ` John Paul Wallington
2003-05-20 21:08 ` Jérôme Marant
2003-05-21 15:31 ` Richard Stallman
2003-05-21 15:59 ` David Kastrup
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200305212031.h4LKVheD021910@beta.mvs.co.il \
--to=ehud@unix.mvs.co.il \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).