|
From: | Jiegec |
Subject: | Re: [O] ox-clip.el |
Date: | Thu, 30 Jun 2016 18:19:04 +0800 |
By reading nsselect.m, there is: DEFUN ("ns-get-selection", Fns_get_selection, Sns_get_selection, 2, 2, 0, doc: /* Return text selected from some X window. SELECTION-SYMBOL is typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. \(Those are literal upper-case symbol names, since that's what X expects.) TARGET-TYPE is the type of data desired, typically `STRING'. */) (Lisp_Object selection_name, Lisp_Object target_type) { Lisp_Object val = Qnil; check_window_system (NULL); CHECK_SYMBOL (selection_name); CHECK_SYMBOL (target_type); if (ns_get_pb_change_count (selection_name) == ns_get_our_change_count_for (selection_name)) val = ns_get_local_selection (selection_name, target_type); if (NILP (val)) val = ns_get_foreign_selection (selection_name, target_type); if (CONSP (val) && SYMBOLP (Fcar (val))) { val = Fcdr (val); if (CONSP (val) && NILP (Fcdr (val))) val = Fcar (val); } val = clean_local_selection_data (val); return val; } and It seems that it implements the selection API. So we can use `gui-set-selection' and `gui-get-selection’. And it works: (gui-set-selection nil “hello”) (gui-get-selection) ;=> “hello” But the text to be copied here is in RTF, but Emacs is hardcoded to copy texts. Damn. We have to use pbcopy or to change Emacs internal code. Now things go back to finding the culprit of overwriting the clipboard. And I traced to `evil-visual-update-x-selection’ called in `evil-visual-{pre,post}-command’. Oh I don’t understand why evil does this. Disabling evil-mode works. Then here comes another bug: I’m testing on a Chinese org file. Here is the part: *** Evil-Surround [[https://github.com/timcharper/evil-surround][Evil-surround]] 是一个 Vim 上非常常用的插件改写的,使用它可以快速的将选中区域进行匹配的操作,例如选中区域两边同时进行添加或修改括号,引号等操作。 下载安装后使用下面的代码将其激活, #+BEGIN_SRC emacs-lisp (require 'evil-surround) (global-evil-surround-mode) #+END_SRC 简单的使用方法就是在选中所选区域后,使用 =S(= 来将选中区域包括在括号之中。如果想将括号改变成 ="= 可以在选中后使用 =cs("= You can get the whole file in https://github.com/emacs-china/Spacemacs-rocks/blob/master/README.org. But pasting the formatted resulted this: The encoding is wrong. Adding a ‘-inputencoding UTF-8’ fixes it. Really cool! That’s what I want. Any workaround for that unwanted evil behaviour? I rely on evil a lot.
|
[Prev in Thread] | Current Thread | [Next in Thread] |