From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan =?iso-8859-1?Q?Reich=F6r?= Newsgroups: gmane.emacs.help Subject: Re: copy-defun Date: Mon, 03 Jul 2006 21:05:49 +0200 Organization: Tele2UTA Telecommunications GmbH Message-ID: <87k66uzeya.fsf@utanet.at> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1151955681 29895 80.91.229.2 (3 Jul 2006 19:41:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 3 Jul 2006 19:41:21 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 03 21:41:19 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FxUIG-0004a0-1s for geh-help-gnu-emacs@m.gmane.org; Mon, 03 Jul 2006 21:41:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FxUIF-0003x7-CK for geh-help-gnu-emacs@m.gmane.org; Mon, 03 Jul 2006 15:41:15 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed01.chello.at!newsfeed.utanet.at!newsspool.utanet.at!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 52 Original-NNTP-Posting-Host: linzu2-210-165.utaonline.at Original-X-Trace: newsreader2.utanet.at 1151953706 5580 212.152.210.165 (3 Jul 2006 19:08:26 GMT) Original-X-Complaints-To: abuse@uta.at Original-NNTP-Posting-Date: Mon, 3 Jul 2006 19:08:26 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:wtFbIadtmTU0pBkIzuwrWuoGqcs= Original-Xref: shelby.stanford.edu gnu.emacs.help:140171 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:35796 Archived-At: Andreas Roehler writes: > Was looking for a function to copy (kill-ring-save) the > function the point is in. > > Wrote the following. Maybe it's already written somewhere? What about M-x mark-defun followed by M-x kill-ring-save: C-M-h M-w Stefan. > __ > Andreas Roehler > > (defun defun-beginning-position-interactive () > "Print the position where the current defun starts" > (interactive) > (let ((pos > (save-excursion > (progn > (beginning-of-defun) (point))))) > (message "%s" pos))) > > (defun defun-beginning-position () > "Return the position where the current defun starts" > (save-excursion > (progn > (beginning-of-defun) (point)))) > > (defun defun-end-position-interactive () > "Print the position where the current defun ends" > (interactive) > (let ((pos > (save-excursion > (progn > (end-of-defun) (point))))) > (message "%s" pos))) > > (defun defun-end-position () > "Return the position where the current defun ends" > (save-excursion > (progn > (end-of-defun) (point)))) > > (defun copy-defun () > (interactive) > (save-excursion > (kill-ring-save > (defun-beginning-position) (defun-end-position)))) > > ;;;;; end