unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* copy-defun
@ 2006-07-01 15:50 Andreas Roehler
  2006-07-03 19:05 ` copy-defun Stefan Reichör
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Roehler @ 2006-07-01 15:50 UTC (permalink / raw)



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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-07-04  7:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-01 15:50 copy-defun Andreas Roehler
2006-07-03 19:05 ` copy-defun Stefan Reichör
2006-07-04  7:41   ` copy-defun Andreas Roehler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).