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 Stumpwm-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/stumpwm-devel