From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Ehud Karni" Newsgroups: gmane.emacs.devel Subject: Re: Zap-to-char behaviour Date: Wed, 21 May 2003 23:31:43 +0300 Organization: Mivtach-Simon Insurance agencies Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200305212031.h4LKVheD021910@beta.mvs.co.il> References: <20030521163038.2792062E4D@mallaury.noc.nerim.net> <200305211737.h4LHbEc08523@eel.dms.auburn.edu> Reply-To: ehud@unix.mvs.co.il NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-8 Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1053550830 28296 80.91.224.249 (21 May 2003 21:00:30 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 21 May 2003 21:00:30 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed May 21 23:00:14 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19IafH-0007A9-00 for ; Wed, 21 May 2003 22:58:23 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19IaqE-0003VP-00 for ; Wed, 21 May 2003 23:09:42 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19IaZy-0001Sk-0s for emacs-devel@quimby.gnus.org; Wed, 21 May 2003 16:52:54 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19IaXm-00011j-FT for emacs-devel@gnu.org; Wed, 21 May 2003 16:50:38 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19IaHh-00067s-QU for emacs-devel@gnu.org; Wed, 21 May 2003 16:34:02 -0400 Original-Received: from unix.mvs.co.il ([192.114.178.12]) by monty-python.gnu.org with esmtp (Exim 4.20) id 19IaGC-000624-OR; Wed, 21 May 2003 16:32:29 -0400 Original-Received: from beta.mvs.co.il (beta [10.253.0.3]) by unix.mvs.co.il (8.11.6/8.11.6) with ESMTP id h4LKVjs10226; Wed, 21 May 2003 23:31:45 +0300 Original-Received: from beta.mvs.co.il (localhost [127.0.0.1]) by beta.mvs.co.il (8.12.5/8.12.5) with ESMTP id h4LKViTV021916; Wed, 21 May 2003 23:31:44 +0300 Original-Received: (from root@localhost) by beta.mvs.co.il (8.12.5/8.12.5/Submit) id h4LKVheD021910; Wed, 21 May 2003 23:31:43 +0300 Original-To: teirllm@dms.auburn.edu In-reply-to: <200305211737.h4LHbEc08523@eel.dms.auburn.edu> (message from Luc Teirlinck on Wed, 21 May 2003 12:37:14 -0500 (CDT)) X-Mailer: Emacs 21.3.1 rmail (send-msg 1.108) Original-cc: rms@gnu.org Original-cc: jmarant@nerim.net X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:14061 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:14061 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wed, 21 May 2003 12:37:14 -0500 (CDT), Luc Teirlinck 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-----