From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: Simple copy & paste problem
Date: Sun, 05 Sep 2010 03:55:52 +0200 [thread overview]
Message-ID: <87lj7hgdhz.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: i5uslp$ois$1@reader1.panix.com
dkcombs@panix.com (David Combs) writes:
> In article <87fwyl9haf.fsf@kuiper.lan.informatimago.com>,
> Pascal J. Bourguignon <pjb@informatimago.com> wrote:
>>
>>Use delete-region-and-yank instead of yank:
>>
>>(defun delete-region-and-yank (&optional arg)
>> "Deletes region if mark is active and yanks the last kill.
>>Always replaces the region with the yank, whether the region was
>>selected via keyboard or mouse. Also works for normal
>>yank even with ARGS (thus it can be mapped to \\C-y)"
>> (interactive "*P") ; raw, like yank.
>> (message "arg=%S" arg)
>> (cond
>> (mark-active ; delete region
>> (let ((str (buffer-substring (point) (mark))))
>> (delete-region (point) (mark))
>> (if (string=* str (current-kill 0 1))
>> (let ((str2 (current-kill 1 1)))
>> (kill-new str2 t))))
>> (if arg
>> (yank arg)
>> (yank)))
>> ;; else no region selected:
>> ((consp arg) ; delete forward sexp
>> (set-mark (point))
>> (forward-sexp 1)
>> (delete-region-and-yank))
>> (arg (yank arg))
>> (t (yank))))
>>
>>
>>--
>>__Pascal Bourguignon__ http://www.informatimago.com/
>
>
> That function, delete-region-and-yank, is not part
> of standard emacs -- its yours, you wrote it.
>
> What, writing code is so easy that it flies off
> your fingers as fast as you can type?
Exactly.
> No, of course not.
Yes, indeed.
> So, pjb, what do you have,
> a whole library of these useful tools that you wrote?
Of course, I don't like to do twice the same thing.
> With a little annotation of why you wrote function x,
> and how it works, you'd have something you could,
> if you felt super generous, provide it to everyone,
> the library.
I have, and I do.
> (For all I know, you already have!)
Indeed.
> (With sufficient annotation (commenting), it'd be good
> for additional examples of using elisp).
Why don't you try to follow this little
link you can find in all my signatures: ---------------+
Why do you think we take the pain of |
putting such links in our signatures? |
V
--
__Pascal Bourguignon__ http://www.informatimago.com/
next prev parent reply other threads:[~2010-09-05 1:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.4.1281546350.9082.help-gnu-emacs@gnu.org>
2010-08-11 17:43 ` Simple copy & paste problem Pascal J. Bourguignon
2010-09-05 1:44 ` David Combs
2010-09-05 1:55 ` Pascal J. Bourguignon [this message]
2010-08-11 18:11 ` notbob
2010-08-11 16:51 Andrea Crotti
2010-08-11 17:51 ` Drew Adams
2010-08-11 18:10 ` Andrea Crotti
2010-08-11 19:05 ` Glauber Alex Dias Prado
2010-08-11 19:15 ` Joel James Adamson
2010-08-11 20:06 ` Thierry Volpiatto
2010-08-11 22:44 ` Andrea Crotti
2010-08-12 17:25 ` Joel James Adamson
2010-08-12 18:14 ` Thierry Volpiatto
[not found] ` <mailman.4.1281557372.27891.help-gnu-emacs@gnu.org>
2010-09-05 1:59 ` David Combs
2010-08-12 5:42 ` Jonathan Groll
2010-08-13 2:35 ` Kevin Rodgers
2010-08-25 13:47 ` Leo
[not found] ` <mailman.0.1281553020.25709.help-gnu-emacs@gnu.org>
2010-09-05 1:48 ` David Combs
2010-09-29 21:20 ` David Combs
[not found] ` <mailman.4.1282744218.27059.help-gnu-emacs@gnu.org>
2010-09-05 2:02 ` David Combs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lj7hgdhz.fsf@kuiper.lan.informatimago.com \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.