From sasdjb@unx.sas.com  Wed Apr  8 11:47:41 1998
X-VM-v5-Data: ([nil nil nil nil nil nil nil nil nil]
	[nil "Wed" " 8" "April" "1998" "14:46:49" "-0400" "David Biesack" "sasdjb@unx.sas.com" nil "59" "Re: ESC-w doesn't always save the whole region" "^From:" nil nil "4" nil nil nil nil]
	nil)
Received: from lamb.sas.com (lamb.sas.com [192.35.83.8]) by june.cs.washington.edu (8.8.7+CS/7.2ju) with ESMTP id LAA21603; Wed, 8 Apr 1998 11:47:40 -0700
Received: from mozart (mozart.unx.sas.com [192.58.184.8]) 	by lamb.sas.com (8.8.7/8.8.7) with SMTP id OAA25994; 	Wed, 8 Apr 1998 14:46:50 -0400 (EDT)
Received: from lgnsrv62.unx.sas.com by mozart (5.65c/SAS/Domains/5-6-90) 	id AA12263; Wed, 8 Apr 1998 14:46:50 -0400
Received: by lgnsrv62.unx.sas.com (5.65c/SAS/Generic 9.01/3-26-93) 	id AA01471; Wed, 8 Apr 1998 14:46:49 -0400
Message-Id: <199804081846.AA01471@lgnsrv62.unx.sas.com>
In-Reply-To: <199804081452.PAA05115@shirow.long.harlequin.co.uk> (message from Andrew Innes on Wed, 8 Apr 1998 15:52:06 +0100 (BST))
From: David Biesack <sasdjb@unx.sas.com>
To: ntemacs-users@cs.washington.edu, rxmarsha@bechtel.com,         andrewi@harlequin.co.uk
Cc: voelker@cs.washington.edu
Subject: Re: ESC-w doesn't always save the whole region
Date: Wed, 8 Apr 1998 14:46:49 -0400

> Date: Wed, 8 Apr 1998 15:52:06 +0100 (BST)
> From: Andrew Innes <andrewi@harlequin.co.uk>
> Cc: ntemacs-users@cs.washington.edu
> 
> On Wed, 08 Apr 1998 15:53:51 +0100, "Marshall, Robert X" <rxmarsha@bechtel.com> said:
> >If there is a null character (C-@) in a region then ESC-w only copies
> >the region up to the null character into the kill ring.  This is in
> >19.34.6 (but not in 19.34 or 20.2 under AIX) so I guess it is an NT
> >specific bug.
> 
> Yes, it's Windows-specific.  Basically the standard clipboard text
> formats don't support NUL characters (it is used to mark the end of the
> text).
> 
> The solution is to reimplement the selection/clipboard support so that
> Emacs registers additional Emacs-specific clipboard data types (as well
> as supporting the standard text types for compatibility with other
> apps).  That way, Emacs can cut&paste arbitrary text within itself (or
> between instances of Emacs).  Also, the rewrite should avoid actually
> copying all the data when setting the selection, and just provide the
> data "on demand", as it does on X (this is more efficient).
> 
> AndrewI

A temporary workaround is to temporarily bin interprogram-cut-function
to nil then do the copy. I wrote the following and bind the function to
M-W (ESC Shift W).  You won't be able to paste the text outside of
Emacs, but you can at least copy and paste the text with NUL bytes
within Emacs.

    (defun copy-region-as-kill-no-interprogram-cut-function (start end)
      "Copy the region as if killed, but don't kill it.
    Temporarily sets interprogram-cut-function to nil."
      (interactive "r")
      (setq this-command 'copy-region-as-kill)
      (let ((interprogram-cut-function nil))
        (copy-region-as-kill start end)))

    (defvar orig-interprogram-cut-function interprogram-cut-function)

    (defun toggle-interprogram-cut-function (arg)
      "Toggle interprogram-cut-function between the default value and nil.
    With a prefix < 0, turn off the interprogram-cut-function, and
    with prefix > 1, unconditionally turn it on."
       (interactive "p")
       (if (or (< arg 0) (and (eq arg 1) interprogram-cut-function))
           (setq interprogram-cut-function nil)
       (setq interprogram-cut-function orig-interprogram-cut-function))
       (message "interprogram-cut-function: %s" interprogram-cut-function))

    (global-set-key  "\M-W" 'copy-region-as-kill-no-interprogram-cut-function)

Geoff; should this be a FAQ item?

-- 
David J. Biesack                                    sasdjb@unx.sas.com
Object Programming Technology                  (919) 677-8000 ext 7771
SAS Institute Inc. SAS Campus Drive Cary, NC 27513  http://www.sas.com
<<<<   Join the Coalition Against UCE at http://www.cauce.org/    >>>>

