help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Zap-up-to-char in Emacs


From: Fredrik Staxeng
Subject: Re: Zap-up-to-char in Emacs
Date: 06 Dec 2002 07:34:04 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2

Benjamin Lewis <bclewis@cs.sfu.ca> writes:

>On Thu, 5 Dec 2002, Jiri Pejchal wrote:
>
>> Hi,
>> 
>> function zap-to-char
>> 
>> `M-z CHAR'
>> Kills through the next occurrence of CHAR (`zap-to-char'). 
>> 
>> is there a function in Emacs similar to zap-up-to-char in XEmacs that 
>> would kill up to and not including the next occurencce of CHAR?

>From my .emacs:

(defun zap-upto-char (arg char)
  "Kill up to and including ARG'th occurrence of CHAR.
Goes backward if ARG is negative; error if CHAR not found."
  (interactive "*p\ncZap 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))))
(define-key global-map "\M-z" 'zap-upto-char)

But I find I don't use it that much. There is no . command, so I 
use search and replace much more instead.

-- 
Fredrik Stax\"ang | rot13: sfgk@hcqngr.hh.fr


reply via email to

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