From: "Stefan Reichör" <stefan@xsteve.at>
Subject: Re: copy-defun
Date: Mon, 03 Jul 2006 21:05:49 +0200 [thread overview]
Message-ID: <87k66uzeya.fsf@utanet.at> (raw)
In-Reply-To: e865ip$507$1@online.de
Andreas Roehler <andreas.roehler@online.de> 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
next prev parent reply other threads:[~2006-07-03 19:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-01 15:50 copy-defun Andreas Roehler
2006-07-03 19:05 ` Stefan Reichör [this message]
2006-07-04 7:41 ` copy-defun Andreas Roehler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k66uzeya.fsf@utanet.at \
--to=stefan@xsteve.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.