【问题标题】:In Emacs irb (inferior-ruby-mode), how to make Autocomplete honor words from Ruby mode buffers?在 Emacs irb (inferior-ruby-mode) 中,如何从 Ruby 模式缓冲区中自动完成荣誉词?
【发布时间】:2012-11-08 11:00:39
【问题描述】:

setting up autocomplete in Emacs irb (inferior-ruby-mode) 时,我遇到了无法仅添加 Ruby 模式缓冲区作为 AC 源的问题。我可以例如。在当前目录下添加文件

(setq ac-sources '(ac-source-files-in-current-dir))

或者我可以通过

添加所有缓冲区(我最终使用的)
(setq ac-sources '(ac-source-words-in-all-buffer))

但我真正想要的是只添加 Ruby 模式缓冲区。 ^^

【问题讨论】:

    标签: ruby emacs autocomplete


    【解决方案1】:

    ac-source-words-in-same-mode-buffers...我们可以重复使用这种方法来构建我们自己的完成源,例如:

     (ac-define-source words-in-ruby-buffers
       '((init . ac-update-word-index)
         (candidates . (ac-word-candidates
                         (lambda (buffer)
                           (eq (buffer-local-value 'major-mode buffer) 'ruby-mode))))))
    

    会给我们ac-source-words-in-ruby-buffers完成源。

    附:我没有测试过它,但它应该可以工作;-)

    【讨论】:

    • 抱歉,但我认为这行不通,否则 Emacs 将不得不神奇地将劣质 ruby​​-mode 视为与 ruby​​-mode 相同。为了安心,我明天试试。
    • 哇,你是什么自动完成首席开发者?
    • 你太棒了,如果你不是 10k 用户,我会调查奖励赏金的事后如何 :) 再次感谢,Emacs 虽然是一个优秀的工具,但对于我来处理(我是生物学家)。
    • 不,我很少使用自动完成功能,但我使用 Emacs 已经超过 15 年了,所以可以快速阅读代码 ;-) 如果您有问题,请不要犹豫直接与我联系(通过电子邮件)...
    猜你喜欢
    • 2011-08-10
    • 2010-11-25
    • 2015-10-06
    • 1970-01-01
    • 1970-01-01
    • 2011-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多