help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: copy paragraph


From: Kevin Rodgers
Subject: Re: copy paragraph
Date: Fri, 14 Apr 2006 09:24:11 -0600
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

Nikos Apostolakis wrote:
Gary Wessle <not@defined.now> writes:
I am trying to copy paragraph under point and by binding C-cp like this
(global-set-key "\C-cp" "\M-A-{\C-@\M-A-}\M-w")
not working, could some one check it.

With "global-set-key" you can bind *commands* to a key, not key
sequences.

Of course, strings of keys and vectors of input events are
commands as well.  The "Keys and Commands" node of the Emacs
manual refers to the "What is a Function" node of the Emacs
Lisp manual for the defnition of a command:

     A "command" is an object that `command-execute' can invoke; it is
     a possible definition for a key sequence.  Some functions are
     commands; a function written in Lisp is a command if it contains an
     interactive declaration (*note Defining Commands::).  Such a
     function can be called from Lisp expressions like other functions;
     in this case, the fact that the function is a command makes no
     difference.

     Keyboard macros (strings and vectors) are commands also, even
     though they are not functions.  A symbol is a command if its
     function definition is a command; such symbols can be invoked with
     `M-x'.  The symbol is a function as well if the definition is a
     function.  *Note Command Overview::.

One way to do what you were trying to, is to record a
keyboard macro, give it a name and then to save it in your .emacs
see (info "(emacs) Save Keyboard Macro").

Or you could do something like

(global-set-key "\C-cp" '(lambda () (interactive)
                   (save-excursion
(copy-region-as-kill (or (search-backward-regexp "^\n") (beginning-of-buffer))
                      (or (search-forward-regexp "^\n" nil t 2) 
(end-of-buffer))))))


assuming that your paragraphs are seperated by blank lines (not
thoroughly tested).

--
Kevin Rodgers





reply via email to

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