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: Tue, 17 May 2016 09:45:10 +0400

David,

When I run the command for the first time I get the org-mode capture
buffer that goes, for example, like this:

----------------------------------------------------------------------------------
* GitHub - stumpwm/stumpwm: The Stump Window Manager - Mozilla Firefox
Stumpwm is a window manager written entirely in Common Lisp. It
attempts to be highly customizable while relying entirely on the
keyboard for input. You will not find buttons, icons, title bars, tool
bars, or any of the other conventional GUI widgets.

Stumpwm is a window manager written entirely in Common Lisp. It
attempts to be highly customizable while relying entirely on the
keyboard for input. You will not find buttons, icons, title bars, tool
bars, or any of the other conventional GUI widgets.
----------------------------------------------------------------------------------

Than I kill that buffer, get back to Firefox, reselect the paragraph
(because the primary selection contains the killed buffer now) and
repeat the command, getting the correct output:

----------------------------------------------------------------------------------
* GitHub - stumpwm/stumpwm: The Stump Window Manager - Mozilla Firefox
https://github.com/stumpwm/stumpwm

Stumpwm is a window manager written entirely in Common Lisp. It
attempts to be highly customizable while relying entirely on the
keyboard for input. You will not find buttons, icons, title bars, tool
bars, or any of the other conventional GUI widgets.
----------------------------------------------------------------------------------

Doesn't it work like that for you?


On 16 May 2016 at 21:59, David Bjergaard <address@hidden> wrote:
> Hi Dimitri,
>
> I'm not sure why you have to run it twice.  I tried the snippet, and I didn't
> see the text pop up until the second time I wrote it.  As for dropping 
> non-latin
> characters: this is a known issue with StumpWM, and one that I'm slowly trying
> to address.
>
> If you can get the bugs worked out (or not) you should put this on the wiki
> since its a great example of using stumpwm to automate window actions that may
> be tedious.
>
>     David
>
> Dimitri Minaev <address@hidden> writes:
>
>> 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]