[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Grab and yank

From: Drew Adams
Subject: RE: Grab and yank
Date: Sun, 24 Jan 2010 08:43:38 -0800

> Another very nice feature that I would like to have is a sort of
> semantic grabbing of code, if for example I want to take the 
> code of the python function foo I should just do M-x grab-code RET
> foo and that could even work for anything that works with tags (for
> example), what could be the best general solution for that?

I probably don't understand. What's wrong with this?

M-. foo ; go to foo's definition
C-M-h   ; select it
M-w     ; copy it
C-x b   ; return
C-y     ; yank

If that does what you want but you think it's too much work ;-), just roll it
into (a keyboard macro) or a command that uses `save-excursion' and the
constituent commands (`find-tag', `mark-defun', `kill-ring-save', and `yank').

A simple alternative, but which assumes that the function's definition is not

(defun grab (fn)
  (interactive "aFunction: ")
  (let ((strg (format "%s" (symbol-function fn))))
    (insert strg))) ; or use `insert-for-yank'

reply via email to

[Prev in Thread] Current Thread [Next in Thread]