all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Grab and yank
@ 2010-01-23 21:31 andrea
  2010-01-24 10:34 ` andrea
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: andrea @ 2010-01-23 21:31 UTC (permalink / raw
  To: help-gnu-emacs

I notice that I often do this operation:
I am in one buffer and I need to fetch something from another buffer.
So I visit the other one, select what I need, go back and yank.
Now something like that would be nice instead:
- visit the buffer in view mode
- when quitting automatically put it in kill-ring and yank it to the
  point of the original buffer

This would save quite a lot of time, what do you thik?
I started something like that

-8<---------------cut here---------------start------------->8---
 (defun grab-and-yank (buffer)
 "Grabs from another buffer and yank it to your point"
 (interactive "bbuffer:\n")
 (switch-to-buffer-other-window buffer)
 (view-mode 1))
--8<---------------cut here---------------end--------------->8---

But the view mode apparently don't keep it read only, and I think I
should change the keymap to make "q" do something different than just
exiting






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

* Re: Grab and yank
  2010-01-23 21:31 Grab and yank andrea
@ 2010-01-24 10:34 ` andrea
  2010-01-24 16:43   ` Drew Adams
  2010-01-24 11:24 ` Lennart Borgman
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: andrea @ 2010-01-24 10:34 UTC (permalink / raw
  To: help-gnu-emacs

andrea <andrea.crotti.0@gmail.com> writes:

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?





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

* Re: Grab and yank
  2010-01-23 21:31 Grab and yank andrea
  2010-01-24 10:34 ` andrea
@ 2010-01-24 11:24 ` Lennart Borgman
  2010-01-24 11:50   ` Andrea Crotti
  2010-01-24 14:32 ` Andreas Röhler
       [not found] ` <mailman.99.1264332314.14305.help-gnu-emacs@gnu.org>
  3 siblings, 1 reply; 14+ messages in thread
From: Lennart Borgman @ 2010-01-24 11:24 UTC (permalink / raw
  To: andrea; +Cc: help-gnu-emacs

On Sat, Jan 23, 2010 at 10:31 PM, andrea <andrea.crotti.0@gmail.com> wrote:
> I notice that I often do this operation:
> I am in one buffer and I need to fetch something from another buffer.
> So I visit the other one, select what I need, go back and yank.
> Now something like that would be nice instead:
> - visit the buffer in view mode
> - when quitting automatically put it in kill-ring and yank it to the
>  point of the original buffer
>
> This would save quite a lot of time, what do you thik?
> I started something like that

I thought it was a good idea so I just added something like it to
ourcomments-util.el. See the function ourcomments-set-paste-point
there.

You can find it in the nXhtml repository. (See EmacsWiki if you do not
know where it is.)




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

* Re: Grab and yank
  2010-01-24 11:24 ` Lennart Borgman
@ 2010-01-24 11:50   ` Andrea Crotti
  2010-01-24 12:05     ` Lennart Borgman
  0 siblings, 1 reply; 14+ messages in thread
From: Andrea Crotti @ 2010-01-24 11:50 UTC (permalink / raw
  To: help-gnu-emacs

Lennart Borgman <lennart.borgman@gmail.com> writes:

> On Sat, Jan 23, 2010 at 10:31 PM, andrea <andrea.crotti.0@gmail.com> wrote:
>
> I thought it was a good idea so I just added something like it to
> ourcomments-util.el. See the function ourcomments-set-paste-point
> there.
>
> You can find it in the nXhtml repository. (See EmacsWiki if you do not
> know where it is.)

Ok I found it here
http://tinyurl.com/yzrt26b
and looks really nice, thanks.

Is it maybe possible to have a single commands that
- sets the point to where I am
- find a buffer and for me to select something
- bury it and paste when it's done

It's very close to what I would like already anyway, I can also try to
adapt it...

By the way is not my own business, but I see there are many nice things
in that file, and they don't have so much to do with a xml mode in
general.
Why don't make them part of something more generic somehow?





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

* Re: Grab and yank
  2010-01-24 11:50   ` Andrea Crotti
@ 2010-01-24 12:05     ` Lennart Borgman
  2010-01-24 13:48       ` Lennart Borgman
  0 siblings, 1 reply; 14+ messages in thread
From: Lennart Borgman @ 2010-01-24 12:05 UTC (permalink / raw
  To: Andrea Crotti; +Cc: help-gnu-emacs

On Sun, Jan 24, 2010 at 12:50 PM, Andrea Crotti
<andrea.crotti.0@gmail.com> wrote:
> Lennart Borgman <lennart.borgman@gmail.com> writes:
>
>> On Sat, Jan 23, 2010 at 10:31 PM, andrea <andrea.crotti.0@gmail.com> wrote:
>>
>> I thought it was a good idea so I just added something like it to
>> ourcomments-util.el. See the function ourcomments-set-paste-point
>> there.
>>
>> You can find it in the nXhtml repository. (See EmacsWiki if you do not
>> know where it is.)
>
> Ok I found it here
> http://tinyurl.com/yzrt26b
> and looks really nice, thanks.
>
> Is it maybe possible to have a single commands that
> - sets the point to where I am
> - find a buffer and for me to select something
> - bury it and paste when it's done


I think it is best keeping it separate so you can find the other
buffer any way you want to.

I doubt it is a good thing to make it too specialized. Maybe restoing
window configuration could be an option?


> It's very close to what I would like already anyway, I can also try to
> adapt it...
>
> By the way is not my own business, but I see there are many nice things
> in that file, and they don't have so much to do with a xml mode in
> general.
> Why don't make them part of something more generic somehow?


Because I do not have time for it then. Keeping it all in one bundle
is more simple.

I would like a package manager that could keep track of
interdependencies instead, but sofar no one else have been interested
really. I suggested a solution with web download of elisp files as you
need them which I think is what is needed. (It is implemented as part
of nXhtml too ;-) ... )




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

* Re: Grab and yank
  2010-01-24 12:05     ` Lennart Borgman
@ 2010-01-24 13:48       ` Lennart Borgman
  2010-01-24 15:13         ` Richard Riley
  0 siblings, 1 reply; 14+ messages in thread
From: Lennart Borgman @ 2010-01-24 13:48 UTC (permalink / raw
  To: Andrea Crotti; +Cc: help-gnu-emacs

On Sun, Jan 24, 2010 at 1:05 PM, Lennart Borgman
<lennart.borgman@gmail.com> wrote:
> On Sun, Jan 24, 2010 at 12:50 PM, Andrea Crotti
> <andrea.crotti.0@gmail.com> wrote:
>> Lennart Borgman <lennart.borgman@gmail.com> writes:
>>
>>> On Sat, Jan 23, 2010 at 10:31 PM, andrea <andrea.crotti.0@gmail.com> wrote:
>>>
>>> I thought it was a good idea so I just added something like it to
>>> ourcomments-util.el. See the function ourcomments-set-paste-point
>>> there.
>>>
>>> You can find it in the nXhtml repository. (See EmacsWiki if you do not
>>> know where it is.)
>>
>> Ok I found it here
>> http://tinyurl.com/yzrt26b
>> and looks really nice, thanks.


I polished it a bit and renamed it to ourcomments-copy+paste-set-point.




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

* Re: Grab and yank
  2010-01-23 21:31 Grab and yank andrea
  2010-01-24 10:34 ` andrea
  2010-01-24 11:24 ` Lennart Borgman
@ 2010-01-24 14:32 ` Andreas Röhler
       [not found] ` <mailman.99.1264332314.14305.help-gnu-emacs@gnu.org>
  3 siblings, 0 replies; 14+ messages in thread
From: Andreas Röhler @ 2010-01-24 14:32 UTC (permalink / raw
  To: help-gnu-emacs

andrea wrote:
> I notice that I often do this operation:
> I am in one buffer and I need to fetch something from another buffer.
> So I visit the other one, select what I need, go back and yank.
> Now something like that would be nice instead:
> - visit the buffer in view mode
> - when quitting automatically put it in kill-ring and yank it to the
>   point of the original buffer
>
> This would save quite a lot of time, what do you thik?
> I started something like that
>
> -8<---------------cut here---------------start------------->8---
>  (defun grab-and-yank (buffer)
>  "Grabs from another buffer and yank it to your point"
>  (interactive "bbuffer:\n")
>  (switch-to-buffer-other-window buffer)
>  (view-mode 1))
> --8<---------------cut here---------------end--------------->8---
>
> But the view mode apparently don't keep it read only, and I think I
> should change the keymap to make "q" do something different than just
> exiting
>
>
>
>
>
>   

Hi,

what about the following procedure:

1) register your point
2) swirl around and collect your honey into a second register :-)
3) back to point (first register)
4 insert second register

Andreas





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

* Re: Grab and yank
  2010-01-24 13:48       ` Lennart Borgman
@ 2010-01-24 15:13         ` Richard Riley
  2010-01-24 15:16           ` Lennart Borgman
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Riley @ 2010-01-24 15:13 UTC (permalink / raw
  To: help-gnu-emacs

Lennart Borgman <lennart.borgman@gmail.com> writes:

> On Sun, Jan 24, 2010 at 1:05 PM, Lennart Borgman
> <lennart.borgman@gmail.com> wrote:
>> On Sun, Jan 24, 2010 at 12:50 PM, Andrea Crotti
>> <andrea.crotti.0@gmail.com> wrote:
>>> Lennart Borgman <lennart.borgman@gmail.com> writes:
>>>
>>>> On Sat, Jan 23, 2010 at 10:31 PM, andrea <andrea.crotti.0@gmail.com> wrote:
>>>>
>>>> I thought it was a good idea so I just added something like it to
>>>> ourcomments-util.el. See the function ourcomments-set-paste-point
>>>> there.
>>>>
>>>> You can find it in the nXhtml repository. (See EmacsWiki if you do not
>>>> know where it is.)
>>>
>>> Ok I found it here
>>> http://tinyurl.com/yzrt26b
>>> and looks really nice, thanks.
>
> I polished it a bit and renamed it to ourcomments-copy+paste-set-point.
>

Hi Lennart,

thingatpt+ might be a good place for this?

http://www.emacswiki.org/emacs/thingatpt+.el

regards

r.






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

* Re: Grab and yank
  2010-01-24 15:13         ` Richard Riley
@ 2010-01-24 15:16           ` Lennart Borgman
  2010-01-24 17:29             ` Richard Riley
  0 siblings, 1 reply; 14+ messages in thread
From: Lennart Borgman @ 2010-01-24 15:16 UTC (permalink / raw
  To: Richard Riley; +Cc: help-gnu-emacs

On Sun, Jan 24, 2010 at 4:13 PM, Richard Riley <rileyrgdev@gmail.com> wrote:
> Lennart Borgman <lennart.borgman@gmail.com> writes:
>
>> On Sun, Jan 24, 2010 at 1:05 PM, Lennart Borgman
>> <lennart.borgman@gmail.com> wrote:
>>> On Sun, Jan 24, 2010 at 12:50 PM, Andrea Crotti
>>> <andrea.crotti.0@gmail.com> wrote:
>>>> Lennart Borgman <lennart.borgman@gmail.com> writes:
>>>>
>>>>> On Sat, Jan 23, 2010 at 10:31 PM, andrea <andrea.crotti.0@gmail.com> wrote:
>>>>>
>>>>> I thought it was a good idea so I just added something like it to
>>>>> ourcomments-util.el. See the function ourcomments-set-paste-point
>>>>> there.
>>>>>
>>>>> You can find it in the nXhtml repository. (See EmacsWiki if you do not
>>>>> know where it is.)
>>>>
>>>> Ok I found it here
>>>> http://tinyurl.com/yzrt26b
>>>> and looks really nice, thanks.
>>
>> I polished it a bit and renamed it to ourcomments-copy+paste-set-point.
>>
>
> Hi Lennart,
>
> thingatpt+ might be a good place for this?
>
> http://www.emacswiki.org/emacs/thingatpt+.el

Hi Richard,

Why?




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

* RE: Grab and yank
  2010-01-24 10:34 ` andrea
@ 2010-01-24 16:43   ` Drew Adams
  0 siblings, 0 replies; 14+ messages in thread
From: Drew Adams @ 2010-01-24 16:43 UTC (permalink / raw
  To: 'andrea', help-gnu-emacs

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

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





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

* Re: Grab and yank
  2010-01-24 15:16           ` Lennart Borgman
@ 2010-01-24 17:29             ` Richard Riley
  2010-01-24 17:39               ` Drew Adams
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Riley @ 2010-01-24 17:29 UTC (permalink / raw
  To: help-gnu-emacs

Lennart Borgman <lennart.borgman@gmail.com> writes:

> On Sun, Jan 24, 2010 at 4:13 PM, Richard Riley <rileyrgdev@gmail.com> wrote:
>> Lennart Borgman <lennart.borgman@gmail.com> writes:
>>
>>> On Sun, Jan 24, 2010 at 1:05 PM, Lennart Borgman
>>> <lennart.borgman@gmail.com> wrote:
>>>> On Sun, Jan 24, 2010 at 12:50 PM, Andrea Crotti
>>>> <andrea.crotti.0@gmail.com> wrote:
>>>>> Lennart Borgman <lennart.borgman@gmail.com> writes:
>>>>>
>>>>>> On Sat, Jan 23, 2010 at 10:31 PM, andrea <andrea.crotti.0@gmail.com> wrote:
>>>>>>
>>>>>> I thought it was a good idea so I just added something like it to
>>>>>> ourcomments-util.el. See the function ourcomments-set-paste-point
>>>>>> there.
>>>>>>
>>>>>> You can find it in the nXhtml repository. (See EmacsWiki if you do not
>>>>>> know where it is.)
>>>>>
>>>>> Ok I found it here
>>>>> http://tinyurl.com/yzrt26b
>>>>> and looks really nice, thanks.
>>>
>>> I polished it a bit and renamed it to ourcomments-copy+paste-set-point.
>>>
>>
>> Hi Lennart,
>>
>> thingatpt+ might be a good place for this?
>>
>> http://www.emacswiki.org/emacs/thingatpt+.el
>
> Hi Richard,
>
> Why?
>

It's an existing documented library of things that specialises in doing
"things at point"... nxhtml is rather heavy for many - although I
recommend it at every opportunity ;) Obviously if you prefer to keep it
in the domains of nxhtml that is your prerogative.


-- 
Google Talk : rileyrgdev@googlemail.com  http://www.google.com/talk
ASCII ribbon campaign ( )
 - against HTML email  X
             & vCards / \





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

* RE: Grab and yank
  2010-01-24 17:29             ` Richard Riley
@ 2010-01-24 17:39               ` Drew Adams
  2010-01-24 17:47                 ` Richard Riley
  0 siblings, 1 reply; 14+ messages in thread
From: Drew Adams @ 2010-01-24 17:39 UTC (permalink / raw
  To: 'Richard Riley', help-gnu-emacs

> >> thingatpt+ might be a good place for this?
> >> http://www.emacswiki.org/emacs/thingatpt+.el
> >
> > Why?
> 
> It's an existing documented library of things that 
> specialises in doing "things at point"...

I think Andrea wanted something that:

 (a) goes and gets a function definition
     (from a tags file or the function's source code)
 (b) returns to the original location, and
 (c) yanks the definition at point.

The thing-at-pt functions pick up stuff at or near point.
They don't (and shouldn't) do excursion stuff or yanking.

That said, these functions in `thingatpt+.el' might be of some use in this
context: `region-or-word-nearest-point', `region-or-word-at-point'. They pick up
the active region or (if inactive) the word nearest/at point.





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

* Re: Grab and yank
  2010-01-24 17:39               ` Drew Adams
@ 2010-01-24 17:47                 ` Richard Riley
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Riley @ 2010-01-24 17:47 UTC (permalink / raw
  To: help-gnu-emacs

"Drew Adams" <drew.adams@oracle.com> writes:

>> >> thingatpt+ might be a good place for this?
>> >> http://www.emacswiki.org/emacs/thingatpt+.el
>> >
>> > Why?
>> 
>> It's an existing documented library of things that 
>> specialises in doing "things at point"...
>
> I think Andrea wanted something that:
>
>  (a) goes and gets a function definition
>      (from a tags file or the function's source code)
>  (b) returns to the original location, and
>  (c) yanks the definition at point.
>
> The thing-at-pt functions pick up stuff at or near point.
> They don't (and shouldn't) do excursion stuff or yanking.
>
> That said, these functions in `thingatpt+.el' might be of some use in this
> context: `region-or-word-nearest-point', `region-or-word-at-point'. They pick up
> the active region or (if inactive) the word nearest/at point.
>

That was my thinking of it. And to be honest I'm not sure yank is out of
the realms of a "thing at pt" functionality. Anyway, I wanted to bring
attention to the library too since that might well help Andrea. I know
it did me when I first started scratching around trying to find simple
functions to get the word or region at pt without needing to learn about
the myriad of ways mark and point interact.

-- 
Google Talk : rileyrgdev@googlemail.com  http://www.google.com/talk
ASCII ribbon campaign ( )
 - against HTML email  X
             & vCards / \





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

* Re: Grab and yank
       [not found] ` <mailman.99.1264332314.14305.help-gnu-emacs@gnu.org>
@ 2010-01-25 18:07   ` Stefan Monnier
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2010-01-25 18:07 UTC (permalink / raw
  To: help-gnu-emacs

>> I notice that I often do this operation:
>> I am in one buffer and I need to fetch something from another buffer.
>> So I visit the other one, select what I need, go back and yank.
>> Now something like that would be nice instead:
>> - visit the buffer in view mode
>> - when quitting automatically put it in kill-ring and yank it to the
>>  point of the original buffer
>> 
>> This would save quite a lot of time, what do you thik?
>> I started something like that

If you want to do it "the GUI way", I remember an elisp package that
provided "single click copy&paste": just press the mouse-button at
start, drag to end, and when you release the mouse button, the selected
text is copied&yanked at point.
Can't remember the package's name, tho.


        Stefan


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

end of thread, other threads:[~2010-01-25 18:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-23 21:31 Grab and yank andrea
2010-01-24 10:34 ` andrea
2010-01-24 16:43   ` Drew Adams
2010-01-24 11:24 ` Lennart Borgman
2010-01-24 11:50   ` Andrea Crotti
2010-01-24 12:05     ` Lennart Borgman
2010-01-24 13:48       ` Lennart Borgman
2010-01-24 15:13         ` Richard Riley
2010-01-24 15:16           ` Lennart Borgman
2010-01-24 17:29             ` Richard Riley
2010-01-24 17:39               ` Drew Adams
2010-01-24 17:47                 ` Richard Riley
2010-01-24 14:32 ` Andreas Röhler
     [not found] ` <mailman.99.1264332314.14305.help-gnu-emacs@gnu.org>
2010-01-25 18:07   ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.