From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David De La Harpe Golden Newsgroups: gmane.emacs.devel Subject: Re: "pasteboard doesn't contain valid data" on OSX Date: Sun, 08 Aug 2010 23:58:47 +0100 Message-ID: <4C5F36A7.5040005@harpegolden.net> References: <86y6ci5jbn.fsf@red.stonehenge.com> <4C5F02CD.6050500@swipnet.se> <4C5F1C79.5070104@harpegolden.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050004080403030805080609" X-Trace: dough.gmane.org 1281308572 23748 80.91.229.12 (8 Aug 2010 23:02:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 8 Aug 2010 23:02:52 +0000 (UTC) Cc: Chong Yidong , =?UTF-8?B?RGrDpHJ2?= , "Randal L. Schwartz" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 09 01:02:49 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OiEtC-0005wQ-RB for ged-emacs-devel@m.gmane.org; Mon, 09 Aug 2010 01:02:47 +0200 Original-Received: from localhost ([127.0.0.1]:41690 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OiEpW-0002eJ-Nr for ged-emacs-devel@m.gmane.org; Sun, 08 Aug 2010 18:58:58 -0400 Original-Received: from [140.186.70.92] (port=59913 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OiEpP-0002bA-UT for emacs-devel@gnu.org; Sun, 08 Aug 2010 18:58:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OiEpO-00042c-Kb for emacs-devel@gnu.org; Sun, 08 Aug 2010 18:58:51 -0400 Original-Received: from harpegolden.net ([65.99.215.13]:34452) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OiEpO-00042W-DZ for emacs-devel@gnu.org; Sun, 08 Aug 2010 18:58:50 -0400 Original-Received: from [87.198.55.108] (87-198-55-108.ptr.magnet.ie [87.198.55.108]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "David De La Harpe Golden", Issuer "David De La Harpe Golden Personal CA rev 3" (verified OK)) by harpegolden.net (Postfix) with ESMTPSA id 72E4A683D1; Sun, 8 Aug 2010 23:58:45 +0100 (IST) User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100620 Icedove/3.0.5 In-Reply-To: <4C5F1C79.5070104@harpegolden.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:128436 Archived-At: This is a multi-part message in MIME format. --------------050004080403030805080609 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 08/08/10 22:07, David De La Harpe Golden wrote: > > Plus, the ns port is doing something strange elsewhere (ns-win.el) (that > can be summed up as "cut buffers? ...wtf?"). > Seems stuff that's named "cut buffer" in the ns-specific parts has basically nothing to do with x11 cut buffers. I don't know if there was a misunderstanding, or an active decision to reuse the name, or what (I suppose I could paw through the logs), but it's a terrible name given the opportunity for confusion with an obsolete x11 feature (especially remembering that ns emacs /runs on/ x11 in some incarnations). Anyway. The attached patch brings emacs to the point I can call the (unfortunately named) ns-store/get-cut-buffer-internal functions* in ns emacs to set/get the various ns pasteboards that gnustep/x11 maps to clipboard/primary/secondary as previously mentioned, and read/write them from x11 selections in x11 emacs etc. It should also improve the macosx experience (untested), though there are still problems*. * N.B., higher level stuff isn't all working right yet. --------------050004080403030805080609 Content-Type: text/x-patch; name="ns-clipboard-pboard_r2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ns-clipboard-pboard_r2.diff" === modified file 'lisp/term/ns-win.el' --- lisp/term/ns-win.el 2010-07-13 10:41:49 +0000 +++ lisp/term/ns-win.el 2010-08-08 22:40:49 +0000 @@ -998,25 +998,25 @@ ;;;; Pasteboard support. (declare-function ns-get-cut-buffer-internal "nsselect.m" (buffer)) (defun ns-get-pasteboard () "Returns the value of the pasteboard." - (ns-get-cut-buffer-internal 'PRIMARY)) + (ns-get-cut-buffer-internal 'CLIPBOARD)) (declare-function ns-store-cut-buffer-internal "nsselect.m" (buffer string)) (defun ns-set-pasteboard (string) "Store STRING into the pasteboard of the Nextstep display server." ;; Check the data type of STRING. (if (not (stringp string)) (error "Nonstring given to pasteboard")) - (ns-store-cut-buffer-internal 'PRIMARY string)) + (ns-store-cut-buffer-internal 'CLIPBOARD string)) ;; We keep track of the last text selected here, so we can check the ;; current selection against it, and avoid passing back our own text ;; from x-cut-buffer-or-selection-value. (defvar ns-last-selected-text nil) (defun x-select-text (text &optional push) "Select TEXT, a string, according to the window system. === modified file 'src/nsselect.m' --- src/nsselect.m 2010-07-08 21:25:08 +0000 +++ src/nsselect.m 2010-08-08 20:42:05 +0000 @@ -31,51 +31,56 @@ #include #include "lisp.h" #include "nsterm.h" #include "termhooks.h" #define CUT_BUFFER_SUPPORT -Lisp_Object QPRIMARY, QSECONDARY, QTEXT, QFILE_NAME; +Lisp_Object QCLIPBOARD, QPRIMARY, QSECONDARY, QTEXT, QFILE_NAME; static Lisp_Object Vns_sent_selection_hooks; static Lisp_Object Vns_lost_selection_hooks; static Lisp_Object Vselection_alist; static Lisp_Object Vselection_converter_alist; static Lisp_Object Qforeign_selection; -NSString *NXSecondaryPboard; +/* CLIPBOARD mapped to NSGeneralPboard */ +NSString *NXPrimaryPboard; +NSString *NXSecondaryPboard; /* ========================================================================== Internal utility functions ========================================================================== */ static NSString * symbol_to_nsstring (Lisp_Object sym) { CHECK_SYMBOL (sym); - if (EQ (sym, QPRIMARY)) return NSGeneralPboard; + if (EQ (sym, QCLIPBOARD)) return NSGeneralPboard; + if (EQ (sym, QPRIMARY)) return NXPrimaryPboard; if (EQ (sym, QSECONDARY)) return NXSecondaryPboard; if (EQ (sym, QTEXT)) return NSStringPboardType; return [NSString stringWithUTF8String: SDATA (XSYMBOL (sym)->xname)]; } static Lisp_Object ns_string_to_symbol (NSString *t) { if ([t isEqualToString: NSGeneralPboard]) + return QCLIPBOARD; + if ([t isEqualToString: NXPrimaryPboard]) return QPRIMARY; if ([t isEqualToString: NXSecondaryPboard]) return QSECONDARY; if ([t isEqualToString: NSStringPboardType]) return QTEXT; if ([t isEqualToString: NSFilenamesPboardType]) return QFILE_NAME; if ([t isEqualToString: NSTabularTextPboardType]) @@ -531,22 +536,27 @@ return Qnil; } #endif void nxatoms_of_nsselect (void) { - NXSecondaryPboard = @"Selection"; + /* These are the names GNUStep's pasteboard daemon uses, + using them for interoperability */ + + NXPrimaryPboard = @"Selection"; + NXSecondaryPboard = @"Secondary"; } void syms_of_nsselect (void) { + QCLIPBOARD = intern ("CLIPBOARD"); staticpro (&QCLIPBOARD); QPRIMARY = intern ("PRIMARY"); staticpro (&QPRIMARY); QSECONDARY = intern ("SECONDARY"); staticpro (&QSECONDARY); QTEXT = intern ("TEXT"); staticpro (&QTEXT); QFILE_NAME = intern ("FILE_NAME"); staticpro (&QFILE_NAME); defsubr (&Sx_disown_selection_internal); defsubr (&Sx_get_selection_internal); defsubr (&Sx_own_selection_internal); --------------050004080403030805080609--