emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-compat: Support for getting data from Windows clipboard
@ 2013-11-17  0:42 Alexander Vorobiev
  2013-11-17  8:20 ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Vorobiev @ 2013-11-17  0:42 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1296 bytes --]

I noticed that %x capture template doesn't work under Windows which made my
templates non-portable, so I made this small change to org-get-x-clipboard
to fix that. This is my very first patch, please let me know if it is
acceptable.

Thanks,
Alex

* lisp/org-compat.el (org-get-x-clipboard): Use w32-get-clipboard-data
to get the clipboard data under Windows.

TINYCHANGE
---
 lisp/org-compat.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index b714f13..a3eb960 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -190,10 +190,12 @@ If DELETE is non-nil, delete all those overlays."
     found))

 (defun org-get-x-clipboard (value)
-  "Get the value of the x clipboard, compatible with XEmacs, and GNU Emacs
21."
-  (if (eq window-system 'x)
-      (let ((x (org-get-x-clipboard-compat value)))
- (if x (org-no-properties x)))))
+  "Get the value of the x or Windows clipboard, compatible with XEmacs,
and GNU Emacs 21."
+  (cond ((eq window-system 'x)
+ (let ((x (org-get-x-clipboard-compat value)))
+   (if x (org-no-properties x))))
+ ((and (eq window-system 'w32) (fboundp 'w32-get-clipboard-data))
+ (w32-get-clipboard-data))))

 (defsubst org-decompose-region (beg end)
   "Decompose from BEG to END."
--

[-- Attachment #2: Type: text/html, Size: 2006 bytes --]

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

* Re: [PATCH] org-compat: Support for getting data from Windows clipboard
  2013-11-17  0:42 [PATCH] org-compat: Support for getting data from Windows clipboard Alexander Vorobiev
@ 2013-11-17  8:20 ` Bastien
  2013-11-18  0:31   ` Alexander Vorobiev
  0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2013-11-17  8:20 UTC (permalink / raw)
  To: Alexander Vorobiev; +Cc: emacs-orgmode

Hi Alexander,

Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:

> I noticed that %x capture template doesn't work under Windows which
> made my templates non-portable, so I made this small change to
> org-get-x-clipboard to fix that. This is my very first patch, please
> let me know if it is acceptable.

The patch looks good but it got mangled by the HTML format of
the email.  Can you resend it as an attachement?

Thanks!

-- 
 Bastien

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

* Re: [PATCH] org-compat: Support for getting data from Windows clipboard
  2013-11-17  8:20 ` Bastien
@ 2013-11-18  0:31   ` Alexander Vorobiev
  2013-11-18  9:25     ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Vorobiev @ 2013-11-18  0:31 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 636 bytes --]

Hi Bastien,

Sorry for the mis-formatting. Here is the patch as an attachment.

Thanks,
Alex


On Sun, Nov 17, 2013 at 2:20 AM, Bastien <bzg@gnu.org> wrote:

> Hi Alexander,
>
> Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:
>
> > I noticed that %x capture template doesn't work under Windows which
> > made my templates non-portable, so I made this small change to
> > org-get-x-clipboard to fix that. This is my very first patch, please
> > let me know if it is acceptable.
>
> The patch looks good but it got mangled by the HTML format of
> the email.  Can you resend it as an attachement?
>
> Thanks!
>
> --
>  Bastien
>

[-- Attachment #1.2: Type: text/html, Size: 1193 bytes --]

[-- Attachment #2: 0001-org-compat-Support-for-getting-data-from-Windows-cli.patch --]
[-- Type: application/octet-stream, Size: 1314 bytes --]

From 68fc5ea5492d9ba1e85c2ac11af34ae0f5bcefaa Mon Sep 17 00:00:00 2001
From: Alexander Vorobiev <alexander.vorobiev@gmail.com>
Date: Sun, 17 Nov 2013 18:27:14 -0600
Subject: [PATCH] org-compat: Support for getting data from Windows clipboard

* lisp/org-compat.el (org-get-x-clipboard): Use w32-get-clipboard-data
to get the clipboard data under Windows.

TINYCHANGE
---
 lisp/org-compat.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index b714f13..a3eb960 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -190,10 +190,12 @@ If DELETE is non-nil, delete all those overlays."
     found))
 
 (defun org-get-x-clipboard (value)
-  "Get the value of the x clipboard, compatible with XEmacs, and GNU Emacs 21."
-  (if (eq window-system 'x)
-      (let ((x (org-get-x-clipboard-compat value)))
-	(if x (org-no-properties x)))))
+  "Get the value of the x or Windows clipboard, compatible with XEmacs, and GNU Emacs 21."
+  (cond ((eq window-system 'x)
+	 (let ((x (org-get-x-clipboard-compat value)))
+	   (if x (org-no-properties x))))
+	((and (eq window-system 'w32) (fboundp 'w32-get-clipboard-data))
+	 (w32-get-clipboard-data))))
 
 (defsubst org-decompose-region (beg end)
   "Decompose from BEG to END."
-- 
1.8.4.msysgit.0


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

* Re: [PATCH] org-compat: Support for getting data from Windows clipboard
  2013-11-18  0:31   ` Alexander Vorobiev
@ 2013-11-18  9:25     ` Bastien
  2013-11-18 11:34       ` Fabrice Popineau
  0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2013-11-18  9:25 UTC (permalink / raw)
  To: Alexander Vorobiev; +Cc: emacs-orgmode

Hi Alexander,

Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:

> Sorry for the mis-formatting. Here is the patch as an attachment.

Thanks -- digging into this again, maybe we need to fix
`org-get-x-clipboard-compat' directly?

I'm not using Windows so I can't test the patch.

Can a Windows user help here?

-- 
 Bastien

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

* Re: [PATCH] org-compat: Support for getting data from Windows clipboard
  2013-11-18  9:25     ` Bastien
@ 2013-11-18 11:34       ` Fabrice Popineau
  2013-11-19  4:53         ` Alexander Vorobiev
  0 siblings, 1 reply; 10+ messages in thread
From: Fabrice Popineau @ 2013-11-18 11:34 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode, Alexander Vorobiev

[-- Attachment #1: Type: text/plain, Size: 880 bytes --]

Yes, you could lift the patch up to `org-get-x-clipboard-compat',
but this way, òrg-no-properties' would be applied to the w32 data too.
Is that relevant? I don't know if w32 clipboard data can have text
properties.

Fabrice


2013/11/18 Bastien <bzg@gnu.org>

> Hi Alexander,
>
> Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:
>
> > Sorry for the mis-formatting. Here is the patch as an attachment.
>
> Thanks -- digging into this again, maybe we need to fix
> `org-get-x-clipboard-compat' directly?
>
> I'm not using Windows so I can't test the patch.
>
> Can a Windows user help here?
>
> --
>  Bastien
>
>


-- 
Fabrice Popineau
-----------------------------
SUPELEC
Département Informatique
3, rue Joliot Curie
91192 Gif/Yvette Cedex
Tel direct : +33 (0) 169851950
Standard : +33 (0) 169851212
------------------------------

[-- Attachment #2: Type: text/html, Size: 1885 bytes --]

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

* Re: [PATCH] org-compat: Support for getting data from Windows clipboard
  2013-11-18 11:34       ` Fabrice Popineau
@ 2013-11-19  4:53         ` Alexander Vorobiev
  2013-11-19  9:40           ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Vorobiev @ 2013-11-19  4:53 UTC (permalink / raw)
  To: Fabrice Popineau; +Cc: Bastien, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2009 bytes --]

I too was thinking of making the change to org-get-x-clipboard-compat
instead, but somehow decided not to. It calls x-get-selection and the
latter, while it does have w32-specific flavor (in w32-common-fns.el),
doesn't seem to support clipboard and its primary purpose is stated as "Fix
interface to (X-specific) mouse.el."

As far as org-no-properties goes, I don't think it will make any difference
on Windows because it looks like only plain text is supported (see e.g.
http://www.mail-archive.com/help-emacs-windows@gnu.org/msg03026.html and
the code in http://git.savannah.gnu.org/cgit/emacs.git/tree/src/w32select.c)
anyway. So it is hard to say where the patch clearly belongs
(w32-common-fns.el (x-get-selection) perhaps?). I can move it to
org-get-x-clipboard-compat of course but some change would still need to be
done to org-get-x-clipboard because it checks for (eq window-system 'x)
explicitly. Let me know what works better.

Thanks
Alex



On Mon, Nov 18, 2013 at 5:34 AM, Fabrice Popineau <
fabrice.popineau@supelec.fr> wrote:

> Yes, you could lift the patch up to `org-get-x-clipboard-compat',
> but this way, òrg-no-properties' would be applied to the w32 data too.
> Is that relevant? I don't know if w32 clipboard data can have text
> properties.
>
> Fabrice
>
>
> 2013/11/18 Bastien <bzg@gnu.org>
>
>> Hi Alexander,
>>
>> Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:
>>
>> > Sorry for the mis-formatting. Here is the patch as an attachment.
>>
>> Thanks -- digging into this again, maybe we need to fix
>> `org-get-x-clipboard-compat' directly?
>>
>> I'm not using Windows so I can't test the patch.
>>
>> Can a Windows user help here?
>>
>> --
>>  Bastien
>>
>>
>
>
> --
> Fabrice Popineau
> -----------------------------
> SUPELEC
> Département Informatique
> 3, rue Joliot Curie
> 91192 Gif/Yvette Cedex
> Tel direct : +33 (0) 169851950
> Standard : +33 (0) 169851212
> ------------------------------
>
>

[-- Attachment #2: Type: text/html, Size: 4548 bytes --]

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

* Re: [PATCH] org-compat: Support for getting data from Windows clipboard
  2013-11-19  4:53         ` Alexander Vorobiev
@ 2013-11-19  9:40           ` Bastien
  2013-11-21 23:21             ` Alexander Vorobiev
  0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2013-11-19  9:40 UTC (permalink / raw)
  To: Alexander Vorobiev; +Cc: Fabrice Popineau, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 94 bytes --]

Hi Alexander,

can you test the attached patch and let me know if it works for you?

Thanks,


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: x-select-w32.patch --]
[-- Type: text/x-diff, Size: 483 bytes --]

diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index b714f13..2eea724 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -350,7 +350,8 @@ Works on both Emacs and XEmacs."
 	     (or (x-get-selection value 'UTF8_STRING)
 		 (x-get-selection value 'COMPOUND_TEXT)
 		 (x-get-selection value 'STRING)
-		 (x-get-selection value 'TEXT))
+		 (x-get-selection value 'TEXT)
+		 (x-get-selection-value))
 	   (error nil)))))
 
 (defun org-propertize (string &rest properties)

[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

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

* Re: [PATCH] org-compat: Support for getting data from Windows clipboard
  2013-11-19  9:40           ` Bastien
@ 2013-11-21 23:21             ` Alexander Vorobiev
  2013-11-22  9:54               ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Vorobiev @ 2013-11-21 23:21 UTC (permalink / raw)
  To: Bastien; +Cc: Fabrice Popineau, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 507 bytes --]

Hi Bastien,

The patch doesn't work unfortunately. I stepped through
x-get-selection-value in w32-common-fns.el and the correct value from the
clipboard gets assigned to x-last-selected-text but then the function just
returns nil (line 120). I would say x-last-selected text needs to be used
somehow.

Thanks,
Alex


On Tue, Nov 19, 2013 at 3:40 AM, Bastien <bzg@gnu.org> wrote:

> Hi Alexander,
>
> can you test the attached patch and let me know if it works for you?
>
> Thanks,
>
>
>
> --
>  Bastien
>
>

[-- Attachment #2: Type: text/html, Size: 900 bytes --]

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

* Re: [PATCH] org-compat: Support for getting data from Windows clipboard
  2013-11-21 23:21             ` Alexander Vorobiev
@ 2013-11-22  9:54               ` Bastien
  2013-11-24 21:37                 ` Alexander Vorobiev
  0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2013-11-22  9:54 UTC (permalink / raw)
  To: Alexander Vorobiev; +Cc: Fabrice Popineau, emacs-orgmode

Hi Alexander,

Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:

> The patch doesn't work unfortunately. I stepped through
> x-get-selection-value in w32-common-fns.el and the correct value from
> the clipboard gets assigned to x-last-selected-text but then the
> function just returns nil (line 120). I would say x-last-selected
> text needs to be used somehow.

Okay.  I applied your previous patch.  Let's keep this under the radar
and see if there is a way to improve clipboard handling for Windows.

Thanks!

-- 
 Bastien

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

* Re: [PATCH] org-compat: Support for getting data from Windows clipboard
  2013-11-22  9:54               ` Bastien
@ 2013-11-24 21:37                 ` Alexander Vorobiev
  0 siblings, 0 replies; 10+ messages in thread
From: Alexander Vorobiev @ 2013-11-24 21:37 UTC (permalink / raw)
  To: Bastien; +Cc: Fabrice Popineau, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 696 bytes --]

Thanks, I will try and see if it can be improved.

Regards,
Alex


On Fri, Nov 22, 2013 at 3:54 AM, Bastien <bzg@gnu.org> wrote:

> Hi Alexander,
>
> Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:
>
> > The patch doesn't work unfortunately. I stepped through
> > x-get-selection-value in w32-common-fns.el and the correct value from
> > the clipboard gets assigned to x-last-selected-text but then the
> > function just returns nil (line 120). I would say x-last-selected
> > text needs to be used somehow.
>
> Okay.  I applied your previous patch.  Let's keep this under the radar
> and see if there is a way to improve clipboard handling for Windows.
>
> Thanks!
>
> --
>  Bastien
>

[-- Attachment #2: Type: text/html, Size: 1257 bytes --]

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

end of thread, other threads:[~2013-11-24 21:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-17  0:42 [PATCH] org-compat: Support for getting data from Windows clipboard Alexander Vorobiev
2013-11-17  8:20 ` Bastien
2013-11-18  0:31   ` Alexander Vorobiev
2013-11-18  9:25     ` Bastien
2013-11-18 11:34       ` Fabrice Popineau
2013-11-19  4:53         ` Alexander Vorobiev
2013-11-19  9:40           ` Bastien
2013-11-21 23:21             ` Alexander Vorobiev
2013-11-22  9:54               ` Bastien
2013-11-24 21:37                 ` Alexander Vorobiev

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).