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

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

Re: Newbie: Unable to write a custom function


From: Mathias Dahl
Subject: Re: Newbie: Unable to write a custom function
Date: Mon, 04 Dec 2006 10:03:35 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.90 (windows-nt)

"deech" <address@hidden> writes:

> ;;Search backwards from a point for a string. If found delete
> ;;all characters from that string to the point.
> ;;Eg Given the argument 't', 'alligator' becomes 'alliga'
> (defun isearch-backward-tophrase ()
>   (set-mark-command ())
>   (isearch-backward )
>   (kill-region ()())
> )

Maybe this is what you want:

(defun del-back-to-string (str)
  (interactive "sString: ")
  (let ((start (point)))
    (if (search-backward str nil t)
        (kill-region (point) start))))

Also, you don't have to restart Emacs to test your new command; just
place point after the last parenthesis and type C-x C-e
(`eval-last-sexp') and it will be evaluated and ready to be used.


reply via email to

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