stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [STUMP] Stump, Emacs and X selection.


From: Dimitri Minaev
Subject: Re: [STUMP] Stump, Emacs and X selection.
Date: Mon, 16 May 2016 08:42:09 +0400

Ah, that `setf'... :) It was just a leftover of one of my panicky
experiments when I tried to get rid of all possible delayed
evaluations.

On 13 May 2016 at 21:12, Dany Haddad <address@hidden> wrote:
> Dimitri,
>
> Cool snippet!
>
> I have not tried to run your code, but just looking over it brielfy:
> - Why are you setting `sel` in the `let` expression and immediately after
> using `setf`?
> - I believe copy-seq does a shallow copy, so the elements will still be
> aliased, causing `quantum entanglement`
> - I haven't looked into the `get-x-selection` routine, but it could be
> stateful. Try looking into the source and maybe doing a deep copy on its
> return value.
>
> Hope that helps!
>
> Dany
>
> On Fri, May 13, 2016 at 5:23 AM Patricio Martinez <address@hidden> wrote:
>>
>> Amazing, I'll probe it soon and I'll see how work.
>>
>> Thank you very much
>>
>> Sent from Nylas N1, the extensible, open source mail client.
>> On may. 13 2016, at 1:27 pm, Dimitri Minaev <address@hidden> wrote:
>>>
>>> Hello,
>>>
>>> I'm trying to write a Stumpwm command that would create a note in
>>> Org-mode and paste the current selection and some other info taken
>>> from Firefox -- the URL and the tab title. While trying to implement
>>> the command I met a couple of problems.
>>>
>>> First, it doesn't work with non-Latin characters. I'm not sure whether
>>> this is related to Stumpwm or Emacs. Stump's get-x-selection yields
>>> correct result, but window-send-string seemingly drops all Cyrillic
>>> characters from that string.
>>>
>>> Then the other problem appeared. To avoid confusion between the
>>> primary selection and the URL, I save the selection content in a
>>> variable before putting the URL to another variable, but it seems that
>>> these two variables are in the state of quantum entanglement. When one
>>> of them is changed, the other one changes, too. I thought that the two
>>> calls of (get-x-selection) might return the same object, which would
>>> result in 'url' being replaced by 'sel'. So, I tried to copy the
>>> string using copy-seq before assigning it to 'sel', but it didn't
>>> help. Now I'm completely lost :)
>>>
>>> Finally, I came up with the version that works correctly when it is
>>> run two times :). After the first execution, it pastes two selections
>>> and no URL. If you re-select the area in Firefox and run the same
>>> command, the expected output will appear. What is wrong here?
>>>
>>> (defcommand emacs-remember () ()
>>>   "Send selection into emacs org-mode"
>>>   (let ((current-window-name (if (current-window) (window-title
>>> (current-window)) "No current window"))
>>>       (current-window-class (if (current-window) (window-class
>>> (current-window)) "No window class"))
>>>       (copy-from-firefox (equal (window-class (current-window))
>>> "Firefox"))
>>>       (sel (get-x-selection))
>>>       (url ""))
>>>       (setf sel (get-x-selection))
>>>     (when copy-from-firefox
>>>         (send-meta-key (current-screen) (kbd "F6"))
>>>         (send-meta-key (current-screen) (kbd "C-c"))
>>>         (setf url (get-x-selection))
>>>         (send-meta-key (current-screen) (kbd "F6")))
>>>     (run-or-raise "emacs" '(:class "Emacs"))
>>>     (send-meta-key (current-screen) (kbd "M-x"))
>>>     (window-send-string "org-capture")
>>>     (send-meta-key (current-screen) (kbd "RET"))
>>>     (window-send-string "f")
>>>     (window-send-string (format nil "~a~%~a~%~%" current-window-name
>>> url))
>>>     (window-send-string sel)))
>>>
>>> Thanks.
>>>
>>> --
>>> With best regards,
>>> Dimitri Minaev
>>>
>>> _______________________________________________
>>> Stumpwm-devel mailing list
>>> address@hidden
>>> https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
>>
>> _______________________________________________
>> Stumpwm-devel mailing list
>> address@hidden
>> https://lists.nongnu.org/mailman/listinfo/stumpwm-devel



-- 
With best regards,
Dimitri Minaev



reply via email to

[Prev in Thread] Current Thread [Next in Thread]