unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stuart D. Herring" <herring@lanl.gov>
Cc: Eric Peterson <epeterson@mcdonaldbradley.com>, emacs-devel@gnu.org
Subject: Re: [EPeterson@mcdonaldbradley.com: Kill ring leak in winemacs  macros]
Date: Thu, 18 Aug 2005 15:17:25 -0700 (PDT)	[thread overview]
Message-ID: <45217.128.165.123.83.1124403445.squirrel@webmail.lanl.gov> (raw)
In-Reply-To: <ull2z7xps.fsf@jasonrumney.net>

> I'm still not convinced this change is worth making now. On X, even
> with clipboard enabled, the actual copying to the clipboard is only
> performed if another application requests it. Andrew Innes suggested
> many years ago that the W32 clipboard should work the same way, but
> noone has picked up that job yet. I don't know which way Mac does it,
> but that can probably be modified to use delayed copying if it does
> not already. So we are talking about reducing the functionality of
> keyboard macros to get around a performance problem that does not
> exist on the most important platforms, and that we know can be fixed
> on others.

The performance problem is entirely secondary (if it even exists); this is
a correctness problem.  Consider a macro like, say, this:

C-e C-w C-f C-y C-s . RET

(which would shuffle chunks of lines around based on periods).  Now set it
running enough times to take, say, 15 minutes of real time (unlikely for a
macro this simple, but just suppose).  While waiting you naturally want to
do something else; you switch into Firefox and do some searches on the
emacs-devel archives.  Finding a neat phrase to search for, you copy it. 
Unbeknownst to you, Emacs had just finished doing `forward-char' and was
about to do `yank', which then gets your search string instead of whatever
was killed last.  Now your text is corrupted, possibly irreversibly (if
the change falls off the end of the undo list and the mark ring before you
can try to recover it).  Moreover, it's quite likely that before you can
paste your text, Emacs loops around and kills some more text; your
copy/paste in Firefox has also been broken.

Sorry if this is belaboring the point too much; I just wanted to explain
what the original issue really was.

That said:
Eric Peterson (the bug reporter) did also say that macros seemed slower on
W32 than on some Unix system, and attributed it to the actual
data-copying.  I don't know if the slowdown is real, or if the clipboard
is to blame.  However, I don't see how copying on W32 (to the clipboard)
can be made any faster, since the W32 clipboard functions much like the
old X cut buffers and is actually real data storage on the part of the
window system.  I don't think there's a way to only interact with it "when
you have to", but I could be wrong.

Davis Herring

PS - Eric Peterson is cc'ed on this email in case he doesn't know the
issue is being resolved.  Eric: there are several ways to fix this
(emacs-devel is currently deciding among them), and it should be a
customizable option in the next version of Emacs.

Until then, here's two workarounds (put them in your .emacs or so, bind
keys to them, whatever).  The first function is self-contained and more
convenient, but if you have some reason to avoid recursive edits, use the
rest of it all together.  Note that the "real" fix may look nothing like
this!

(defun private-kills-recursive-edit ()
  "Disable interprogram cut and paste and do a recursive edit.
When the recursive edit finishes, any new text available from the window
system will be available for yanking."
  (interactive)
  (let (interprogram-cut-function interprogram-paste-function)
    (recursive-edit)))

(defvar suspended-interprogram-functions nil
  "\"Real\" interprogram functions, as a cons: (CUT . PASTE).")

(defun suspend-interprogram-kills ()
  "Disable interprogram cut and paste (temporarily).
It can be re-enabled with `resume-interprogram-kills'."
  (interactive)
  (if suspended-interprogram-functions
      (error "Interprogram kills already suspended")
    (setq suspended-interprogram-functions
          (cons interprogram-cut-function interprogram-paste-function)
          interprogram-cut-function nil
          interprogram-paste-function nil)))

(defun resume-interprogram-kills ()
  "Undo `suspend-interprogram-kills'.
Any new text available from the window system becomes available for
yanking."
  (interactive)
  (if suspended-interprogram-functions
      (setq interprogram-cut-function
            (car suspended-interprogram-functions)
            interprogram-paste-function
            (cdr suspended-interprogram-functions)
            suspended-interprogram-functions nil)
    (error "Interprogram kills not suspended")))

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.

  reply	other threads:[~2005-08-18 22:17 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-03 19:10 [EPeterson@mcdonaldbradley.com: Kill ring leak in winemacs macros] Richard M. Stallman
2005-08-03 19:27 ` Stuart D. Herring
2005-08-03 19:52   ` Lennart Borgman
2005-08-03 20:59     ` Stuart D. Herring
2005-08-03 21:41       ` Lennart Borgman
2005-08-04  3:55         ` Eli Zaretskii
2005-08-04  7:25           ` Lennart Borgman
2005-08-03 23:12       ` Kevin Rodgers
2005-08-04 15:34         ` Stuart D. Herring
2005-08-16 15:07         ` Stuart D. Herring
2005-08-16 16:10           ` Jason Rumney
2005-08-16 16:19             ` Jason Rumney
2005-08-17  6:24               ` Richard M. Stallman
2005-08-18 16:43               ` Kevin Rodgers
2005-08-18 21:15                 ` Jason Rumney
2005-08-18 22:17                   ` Stuart D. Herring [this message]
2005-08-16 16:31             ` Stuart D. Herring
2005-08-16 21:38               ` Jason Rumney
2005-08-18 16:57                 ` Kevin Rodgers
2005-08-18 16:56               ` Kevin Rodgers
2005-08-18 17:52                 ` Stuart D. Herring
2005-08-04 12:48       ` Richard M. Stallman
     [not found]   ` <E1E0f9R-0003Pk-NJ@fencepost.gnu.org>
2005-08-04 14:19     ` Lennart Borgman
2005-08-04 15:20     ` Juanma Barranquero
2005-08-05 11:59       ` Richard M. Stallman
2005-08-05 12:43         ` Juanma Barranquero
2005-08-06  6:27           ` Richard M. Stallman
2005-08-05 13:48         ` defadvice in Emacs code (was: " Lennart Borgman

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45217.128.165.123.83.1124403445.squirrel@webmail.lanl.gov \
    --to=herring@lanl.gov \
    --cc=emacs-devel@gnu.org \
    --cc=epeterson@mcdonaldbradley.com \
    /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 public inbox

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

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