unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* copy paragraph
@ 2006-04-13 21:46 Gary Wessle
  2006-04-13 22:21 ` B. T. Raven
  2006-04-14 11:03 ` Nikos Apostolakis
  0 siblings, 2 replies; 6+ messages in thread
From: Gary Wessle @ 2006-04-13 21:46 UTC (permalink / raw)


Hi

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.

thank you

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

* Re: copy paragraph
  2006-04-13 21:46 copy paragraph Gary Wessle
@ 2006-04-13 22:21 ` B. T. Raven
  2006-04-13 23:08   ` Lennart Borgman
  2006-04-14 11:03 ` Nikos Apostolakis
  1 sibling, 1 reply; 6+ messages in thread
From: B. T. Raven @ 2006-04-13 22:21 UTC (permalink / raw)



"Gary Wessle" <not@defined.now> wrote in message
news:874q0xb13p.fsf@localhost.localdomain...
> Hi
>
> 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.
>
> thank you


M-h M-w puts a copy of the paragraph surrounding point into the kill-ring.
On my keyboard this is no slower than C-cp but a standard keyboard layout
may not allow you to touch type those keychords. Still you can hold down
the Meta(Alt) key with one finger and hw with the other hand.

Ed.

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

* Re: copy paragraph
  2006-04-13 22:21 ` B. T. Raven
@ 2006-04-13 23:08   ` Lennart Borgman
  0 siblings, 0 replies; 6+ messages in thread
From: Lennart Borgman @ 2006-04-13 23:08 UTC (permalink / raw)
  Cc: help-gnu-emacs

B. T. Raven wrote:
> "Gary Wessle" <not@defined.now> wrote in message
> news:874q0xb13p.fsf@localhost.localdomain...
>   
>> Hi
>>
>> 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.
>>
>> thank you
>>     
>
>
> M-h M-w puts a copy of the paragraph surrounding point into the kill-ring.
> On my keyboard this is no slower than C-cp but a standard keyboard layout
> may not allow you to touch type those keychords. Still you can hold down
> the Meta(Alt) key with one finger and hw with the other hand.
>
> Ed.
>   
StickyModifiers can maybe help:

    http://www.emacswiki.org/cgi-bin/wiki/StickyModifiers

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

* Re: copy paragraph
  2006-04-13 21:46 copy paragraph Gary Wessle
  2006-04-13 22:21 ` B. T. Raven
@ 2006-04-14 11:03 ` Nikos Apostolakis
  2006-04-14 15:24   ` Kevin Rodgers
  1 sibling, 1 reply; 6+ messages in thread
From: Nikos Apostolakis @ 2006-04-14 11:03 UTC (permalink / raw)


Gary Wessle <not@defined.now> writes:

> Hi
>
> 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.  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).

HTH,
Nikos

> thank you

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

* Re: copy paragraph
  2006-04-14 11:03 ` Nikos Apostolakis
@ 2006-04-14 15:24   ` Kevin Rodgers
  2006-04-15  0:05     ` Nikos Apostolakis
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Rodgers @ 2006-04-14 15:24 UTC (permalink / raw)


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

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

* Re: copy paragraph
  2006-04-14 15:24   ` Kevin Rodgers
@ 2006-04-15  0:05     ` Nikos Apostolakis
  0 siblings, 0 replies; 6+ messages in thread
From: Nikos Apostolakis @ 2006-04-15  0:05 UTC (permalink / raw)


Kevin Rodgers <ihs_4664@yahoo.com> writes:

> 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:
>

I'll be ... 

I don't know where I got this idea but before your message I was
sure that one could not use a sequence of keys as the second
argument to "global-set-key".  Actually I could swear that I read it
in the manual!

Sorry for the noise.
Nikos

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

end of thread, other threads:[~2006-04-15  0:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-13 21:46 copy paragraph Gary Wessle
2006-04-13 22:21 ` B. T. Raven
2006-04-13 23:08   ` Lennart Borgman
2006-04-14 11:03 ` Nikos Apostolakis
2006-04-14 15:24   ` Kevin Rodgers
2006-04-15  0:05     ` Nikos Apostolakis

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).