From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Lute Kamstra Newsgroups: gmane.emacs.devel Subject: Re: Addition to lisp/misc.el Date: Mon, 08 Sep 2003 12:55:47 +0200 Organization: CWI, Amsterdam Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <1062321287.3f51bc87d20ae@impt1-2.free.fr> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1063271642 24561 80.91.224.253 (11 Sep 2003 09:14:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 11 Sep 2003 09:14:02 +0000 (UTC) Cc: =?iso-8859-1?q?J=E9r=F4me_Marant?= Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Sep 11 11:14:00 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19xNWa-0004C3-00 for ; Thu, 11 Sep 2003 11:14:00 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19xNXL-0003Ay-00 for ; Thu, 11 Sep 2003 11:14:47 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 19xNVd-0006E1-UM for emacs-devel@quimby.gnus.org; Thu, 11 Sep 2003 05:13:01 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.22) id 19xNV2-0006AT-N3 for emacs-devel@gnu.org; Thu, 11 Sep 2003 05:12:24 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.22) id 19xNUz-0006AC-Rc for emacs-devel@gnu.org; Thu, 11 Sep 2003 05:12:22 -0400 Original-Received: from [192.16.191.8] (helo=hera.cwi.nl) by monty-python.gnu.org with esmtp (Exim 4.22) id 19xNUz-00069l-9R for emacs-devel@gnu.org; Thu, 11 Sep 2003 05:12:21 -0400 Original-Received: from occarina.pna.cwi.nl (occarina.pna.cwi.nl [192.16.184.200]) by hera.cwi.nl with ESMTP id LAA05359 for ; Thu, 11 Sep 2003 11:12:19 +0200 (MEST) Original-Received: (from lute@localhost) by occarina.pna.cwi.nl (8.12.8/8.12.5) id h8B9CIAr003888 for emacs-devel@gnu.org; Thu, 11 Sep 2003 11:12:18 +0200 X-Authentication-Warning: occarina.pna.cwi.nl: lute set sender to Lute.Kamstra@cwi.nl using -f Resent-To: emacs-devel@gnu.org Resent-From: Lute Kamstra Resent-Message-ID: Resent-User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) Resent-Date: Thu, 11 Sep 2003 11:12:18 +0200 Original-To: emacs-devel@gnu.org In-Reply-To: <1062321287.3f51bc87d20ae@impt1-2.free.fr> =?iso-8859-1?q?=28J=E9r=F4me?= Marant's message of "Sun, 31 Aug 2003 11:14:47 +0200") User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) Original-Lines: 50 Resent-Date: Thu, 11 Sep 2003 05:12:21 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:16289 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:16289 J=E9r=F4me Marant writes: > Could someone please install this (zap-up-to-char) > > http://mail.gnu.org/archive/html/emacs-devel/2003-05/msg00478.html > > in lisp/misc.el. I use it very often so I think it would deserve > being part of Emacs. Richard proposed to include it in misc.el. I reread the original discussion. In the archived mail J=E9r=F4me Marant refers to, Ehud Karni proposes this implementation: (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 ar= g) (- (point) direction))) (backward-char direction)))) This way, point is moved forward by one character if the search-forward fails. Seems undesirable to me. I think this implementation would be better: (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. Ignores CHAR at point." (interactive "p\ncZap up to char: ") (let ((direction (if (>=3D arg 0) 1 -1))) (kill-region (point) (progn (forward-char direction) (unwind-protect (search-forward (char-to-string char) nil nil arg) (backward-char direction)) (point))))) If nobody objects, I'll put it in lisp/misc.el. Lute.