[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
copy-defun
From: |
Andreas Roehler |
Subject: |
copy-defun |
Date: |
Sat, 01 Jul 2006 17:50:21 +0200 |
User-agent: |
KNode/0.9.2 |
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?
__
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 <=