Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加pause和resume函数 #15

Closed
llcc opened this issue Jan 21, 2015 · 12 comments
Closed

添加pause和resume函数 #15

llcc opened this issue Jan 21, 2015 · 12 comments

Comments

@llcc
Copy link

llcc commented Jan 21, 2015

org-mode中使用speed-command时,每次还需要再切换到默认输入法,总感觉还是有点麻烦。
所以希望能添加两个函数和一个hook,比如这样:

(add-hook 'pyim-mode-hook 
      (lambda ()
              (if (bolp) (looking-at org-heading-regexp)
                     (pause-pyim-mode)
               (resume-pyim-mode)                      
@tumashu
Copy link
Owner

tumashu commented Jan 21, 2015

(add-hook 'pyim-mode-hook 
          (lambda ()
            (if (and (bolp)
                     (looking-at org-heading-regexp))
                (setq pyim-input-ascii t)
              (setq pyim-input-ascii nil))))

不知道这样行不行

@llcc
Copy link
Author

llcc commented Jan 21, 2015

我尝试了下没有效果,不过应该是有的啊。我还试过deactivate-input-mode,都没有效果,也不清楚是怎么回事。

@tumashu
Copy link
Owner

tumashu commented Jan 21, 2015

没有 pyim-mode 这个 mode

@tumashu
Copy link
Owner

tumashu commented Jan 22, 2015

(defvar pyim-org-speed-timer nil)
(defun pyim-org-speed ()
  (interactive)
  (when pyim-org-speed-timer
    (cancel-timer pyim-org-speed-timer))
  (setq pyim-org-speed-timer
        (run-with-timer
         nil 0.1
         '(lambda ()
            (if (and (bolp)
                     (looking-at org-heading-regexp))
                (setq pyim-input-ascii t)
              (setq pyim-input-ascii nil))))))

也个比较 diao si 的解决方法,可以暂时试一试。。。。。。。

@tumashu
Copy link
Owner

tumashu commented Jan 22, 2015

如果你的手太快,把 0.1 改为 0.01

@llcc
Copy link
Author

llcc commented Jan 22, 2015

这个方法好粗暴,不过那个pyim-active-mode是啥?

@tumashu
Copy link
Owner

tumashu commented Jan 22, 2015

pyim-active-mode? 我搜了一下代码,好像没有这个东西呀,抱歉。。。。这个代码一开始是从 eim fork过来的。。。我也得慢慢熟悉。

@tumashu
Copy link
Owner

tumashu commented Jan 22, 2015

倒是有一个 pyim-active-hook, 不过这个hook是第一次加载 pyim 时运行的。 似乎不适用与这种情况。

关键问题还是要让pyim识别 “org speed” ,但这些代码写到核心里不太适合。。。。 再想想有什么好注意。

@tumashu
Copy link
Owner

tumashu commented Jan 22, 2015

虽然说 timer 的方式比较 粗暴,不过不失为一种可行的方法。

@tumashu
Copy link
Owner

tumashu commented Jan 22, 2015

(setq-default pyim-english-input-switch-function
              `(lambda ()
                 (and (bolp)
                      (looking-at org-heading-regexp))))

@llcc
Copy link
Author

llcc commented Jan 23, 2015

万分感谢,问题已经解决。

@tumashu
Copy link
Owner

tumashu commented Jan 23, 2015

不客气,这个功能很有用,可以显著的提升输入法的体验。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants