[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: copy-defun
From: |
Stefan Reichör |
Subject: |
Re: copy-defun |
Date: |
Mon, 03 Jul 2006 21:05:49 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
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
- copy-defun, Andreas Roehler, 2006/07/01
- Re: copy-defun,
Stefan Reichör <=