clipmon icon indicating copy to clipboard operation
clipmon copied to clipboard

Clipmon only getting the first one or two values copied to the system clipboard - Linux

Open emanresusername opened this issue 7 years ago • 14 comments

i'm on OSX, emacs 25.1, the latest push fixed all my issues with #9, #8 and #5 , but now there are some other behaviors that don't seem to be functioning like they were before.

  1. yank:
    • before: i think it was adding everything to the kill ring when the clipboard contents changed.
    • now: seems to be tracking the most recent thing. so yanking will behave as expected (i.e. paste the most recent thing copied to the clipboard from any application), BUT, searching the kill ring BEFORE the yank won't show any of the most recent clipboard content changes
  2. insert: similarly
    • before: upon any change in the clipboard content, the new content would be yanked into the current buffer
    • now: not seeing any new clipboard contents auto yanked into the current buffer

IMHO, i personally would vote for the emacs 25 compatible push over reverting for the old functionality (assuming the old functionality is on some path to being restored), but not sure how the rest of the user base and/or you feels?

all that aside, this project is awesome.

emanresusername avatar Sep 22 '16 08:09 emanresusername

Thanks for all your testing! I'm trying to get it set up so I can test everything with 24.5 and 25.1 on Windows, Linux, and OSX, and didn't get as far as I'd intended last night. I'd also like to automate it with the unit tests, but as far as I can tell the C api doesn't allow you to write to the clipboard and then get those contents back out, at least on Windows -

DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data, ... {
...
  /* Don't pass our own text from the clipboard (which might be
     troublesome if the killed text includes null characters).  */
  if (!NILP (current_text))
    return ret; // nil

with no way to get current_text or set it to nil directly.

Anyway, will work on this issue next -

bburns avatar Sep 22 '16 12:09 bburns

No problem, this is a package I use damn near every day! Glad to help out where I can

My elisp-fu is weak (if it exists at all 😅), but if there are any things I can provide from my env, lmk

On Thu, Sep 22, 2016 at 05:14 Brian Burns [email protected] wrote:

Thanks for all your testing! I'm trying to get it set up so I can test everything with 24.5 and 25.1 on Windows, Linux, and OSX, and didn't get as far as I'd intended last night. I'd also like to automate it with the unit tests, but as far as I can tell the C api doesn't allow you to write to the clipboard and then get those contents back out, at least on Windows -

DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data, ... { ... /* Don't pass our own text from the clipboard (which might be troublesome if the killed text includes null characters). */ if (!NILP (current_text)) return ret; // nil

with no way to get current_text or set it to nil directly.

Anyway, will work on this issue next -

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bburns/clipmon/issues/13#issuecomment-248886524, or mute the thread https://github.com/notifications/unsubscribe-auth/AA0hN6WBc8JARbd8EZCC7VADQzZMCEwRks5qsnFBgaJpZM4KDpr5 .

emanresusername avatar Sep 22 '16 15:09 emanresusername

Thanks! :) For such a simple concept debugging this package is proving to be pretty complex - everything was broken on the last push - here is the testing matrix:

| test                    | result                                  | windows/emacs24  | windows/emacs25          | linux/emacs24                   | linux/emacs25              | osx24 | osx25 |
|-------------------------+-----------------------------------------+------------------+--------------------------+---------------------------------+----------------------------+-------+-------|
| startup emacs           |                                         |                  | ok                       | error - couldn't convert string |                            |       |       |
| copy from emacs         | shouldn't insert it                     | ok               | fail                     | fail - copies it                |                            |       |       |
| copy from scite 3x      | should insert them ok                   | ok               | ok                       | fail - just gets 1st or 2nd val | fail - just gets first val |       |       |
| copy chinese from scite | should insert chinese ok                | fail - puts '??' | almost                   | fail - adds literal \u5b57 etc  |                            |       |       |
| check killring          | should just have one plain copy of each | ok               | fail - double emacs text | fail - double emacs text        |                            |       |       |

(This is why I'd really like to be able to do this with unit tests on Travis CI!)

So I tried to revert to a good place and added a few fixes -

* 5531a49 add test for clipboard contents function, notes (HEAD -> master, origin/master) 4 minutes ago
* 3eccbd0 change ignore-errors to with-demoted-errors - will display an error msg and continue 14 minutes ago
* d21a7b2 fix #7 and #9 - x-selection-owner-p renamed in emacs25.1 50 minutes ago
* 8dc73a4 fix #6 correct UTF8-STRING to UTF8_STRING 61 minutes ago
| * 277c334 add testing notes (upgrade-broken) 64 minutes ago
| * bd448db correct UTF8-STRING to UTF8_STRING, add testing comments 64 minutes ago
| * 72037ca add test for new clipboard functions 30 hours ago
| * 1d396d8 whitespace 30 hours ago
| * 04b1b30 fix #7 and #9 - x-selection-owner-p renamed in emacs25.1 30 hours ago
|/
* 81bad7a travis comment 30 hours ago
* 7919b6a fix #6 - Unreadable codes when dealing with Chinese 2 days ago
* 1a9f34f fix #10 - error if no sound device found 2 days ago
* 90e24ba try to fix travis.ci builds - make test works ok on windows and xubuntu 8 months ago
* 0f49459 declare x-selection-owner-p - travis.cl was saying it was a void function 8 months ago
* e64fccc comment out dos2unix in makefile - travis.cl was choking on it 8 months ago
* 6198fe2 remove clipmon-use-primary-selection option - doesn't work very well with big selections (tag: v20160127) 8 months ago
* e1620af fix #4 to avoid duplicates in kill-ring, and add clipmon-use-primary-selection option 8 months ago
* 6a25adb comments, whitespace 8 months ago

But things appear to still be broken on Linux (and probably OSX?) - it seems to just grab the first 1 or 2 values from the system clipboard and then gets stuck on the last value. It's just calling the x-get-selection function to get the clipboard contents, so I don't know what's causing the problem.

And I just tried reverting to the last tagged version (v20160127) and it has the same problem on Linux - so either people haven't been using it on Linux or there's a problem with my VM setup, which is possible - the clipboard has to be handled by a guest addition driver.

I'll have to continue later - hopefully things are working on OSX!

bburns avatar Sep 23 '16 00:09 bburns

Just for reference, this is the outline of the function causing problems -

(defun clipmon--clipboard-contents ()
  "Get current contents of system clipboard - returns a string, or nil."
  (if (eq window-system 'w32)
      (x-get-selection-value)
     (x-get-selection 'CLIPBOARD 'UTF8_STRING)))

The x- functions have different implementations for the different OS's. I'd really like to get some unit tests working for them and run them on Travis, so I could find out what's going on - would be much easier that way.

bburns avatar Sep 23 '16 00:09 bburns

thanks! i'll let ya know how things are working on the osx front when the next version hits melpa!

emanresusername avatar Sep 23 '16 00:09 emanresusername

not sure if things are still in flux or not, but seeing this in emacs 25 on OSX in version 20160923.923

clipmon--clipboard-contents: Symbol’s function definition is void: selection-owner-p

emanresusername avatar Sep 23 '16 20:09 emanresusername

Hmm, thanks - I'll revert some of the recent changes and see if it fixes it - it's not doing that on Windows or Linux. Wish I had a Mac to experiment on also... I'm trying to get Travis CI to handle OSX also, to at least minimally test things.

Just for reference, reverted from

;; handle renamed function - x-selection-owner-p was renamed to
;; gui-selection-owner-p in emacs 25.1
(defalias 'selection-owner-p 'x-selection-owner-p)
(if (fboundp 'gui-selection-owner-p)
    (defalias 'selection-owner-p 'gui-selection-owner-p))

to

;; add declare-functions for travis continuous integration builder
(declare-function x-selection-owner-p "xselect.c" (&optional selection terminal))
(declare-function gui-selection-owner-p "xselect.c" (&optional selection terminal))

;; handle renamed function - x-selection-owner-p was renamed to
;; gui-selection-owner-p in emacs 25.1
(if (fboundp #'x-selection-owner-p)
    (defalias 'selection-owner-p 'x-selection-owner-p)
  (defalias 'selection-owner-p 'gui-selection-owner-p))

Hopefully that will fix it.

bburns avatar Sep 23 '16 20:09 bburns

same thing, but i caught something new that i missed last time. this appears up higher in the messages:

face-attribute: Symbol’s function definition is void: selection-owner-p

not sure if that's relevant?

emanresusername avatar Sep 24 '16 00:09 emanresusername

Rats... I think I'm going to have to do some debugging on a Mac - found macincloud.com - $1/hr - will see if I can figure out what's going on.

Here's the test matrix - just a few issues...

| test                          | result                                  | windows/emacs24 | windows/emacs25               | linux/emacs24                | linux/emacs25                | osx/emacs24 | osx/emacs25                   |
|-------------------------------+-----------------------------------------+-----------------+-------------------------------+------------------------------+------------------------------+-------------+-------------------------------|
| start autoinsert              | should beep and change cursor color     | ok              | ok                            | ok                           | ok                           |             | fail - selection-owner-p void |
| copy from emacs               | shouldn't insert it                     | ok              | fail - copies it              | fail - copies it             | fail - copies it             |             |                               |
| copy from scite 3x            | should insert them ok                   | ok              | ok                            | fail - just gets 1st/2nd val | fail - just gets 1st/2nd val | fail        | fail                          |
| copy chinese from scite       | should insert chinese ok                | fail - puts '?' | fail - puts Chinese, then '?' | fail - puts literal '\u5b57' | fail - puts '?'              |             |                               |
| check killring                | should just have one plain copy of each | ok              | fail - double emacs text      | fail - double emacs text     | fail - double emacs text     |             |                               |
| open gui dialog (eg C-mouse1) | shouldn't hang emacs                    | ok              | ok                            | fail - locks up              | fail - locks up              |             |                               |

bburns avatar Sep 24 '16 02:09 bburns

lmk if there's anything i can send you from my env to help out. I have slim to no skills in elisp debugging, but could do a screen share or something with you driving. idk if that's more or less trouble than macincloud 😅

emanresusername avatar Sep 24 '16 02:09 emanresusername

Thanks for the offer :) I'll see how macincloud works out - for now though I'll revert to an earlier commit when things were working a little better, and will build from that...

bburns avatar Sep 24 '16 04:09 bburns

Okay, this seems to be fixed for OSX now - tested on OSX 10.11.6 with macincloud.com. Thanks for your help - let me know if you have any problems with it -

Version 20160925 -

| test                          | result                                  | windows/emacs24 | windows/emacs25               | linux/emacs24                 | linux/emacs25 | osx/emacs24 | osx/emacs25 |
|-------------------------------+-----------------------------------------+-----------------+-------------------------------+-------------------------------+---------------+-------------+-------------|
| copy from emacs               | shouldn't insert it                     | ok              | ok                            | ok                            | ok            | ok          | ok          |
| copy from scite 4x            | should insert them ok                   | ok              | ok                            | fail - just gets 1st 1-4 vals | fail - same   | ok          | ok          |
| copy chinese from scite       | should insert chinese ok                | fail - puts '?' | fail - puts Chinese, then '?' | fail - puts literal '\u6c49'  | fail - same   | ok          | ok          |
| check killring                | should just have one plain copy of each | ok              | ok                            | fail - double emacs text      | fail - same   | ok          | ok          |
| open gui dialog (eg C-mouse1) | shouldn't hang emacs                    | ok              | ok                            | fail - locks up               | fail - same   | ok          | ok          |

It's still a problem on Linux though - the function x-get-selection-internal just seems to get stuck on a certain value. But I tried reverting to the previous version from January and the same problem existed, so either no one has been using it on Linux, or else it's a problem with my VM setup. It must be the VM, as I know I had tested it before with a different VM setup...

bburns avatar Sep 26 '16 16:09 bburns

gif-keyboard-980023455885842985

emanresusername avatar Sep 26 '16 18:09 emanresusername

Hah, awesome!

I'm gonna leave this open til I can fix it on Linux though, or test it on a non-VM Linux.

bburns avatar Sep 26 '16 18:09 bburns