Emacs 23.2 in emacs v1有C-x C-i (或ido-imenu) (类似于崇高文本的Cmd+R)。emacs中的Emacs24缺乏这一功能.我找到了这个github问题和固定物,它们试图重新创建该功能。虽然这个ido-imenu在elisp-mode中工作,但它在ruby-mode中停止工作。我得到:
imenu--make-index-alist: No items suitable for an index found in this buffer发布于 2012-10-05 08:48:58
因此,在再次阅读emacs上的部分之后,我终于明白了这一点。
简短回答:您需要将这一点添加到您的定制中。可以随意添加更多的类型到列表中(我对仅仅的方法很满意)。
(add-hook 'ruby-mode-hook
(lambda ()
(set (make-local-variable imenu-generic-expression)
'(("Methods" "^\\( *\\(def\\) +.+\\)" 1)
))))Longer应答:我首先尝试定义ruby-imenu-generic-expression函数并使用ruby-mode-hook将其设置为imenu-generic-expression
(defvar ruby-imenu-generic-expression
'(("Methods" "^\\( *\\(def\\) +.+\\)" 1))
"The imenu regex to parse an outline of the ruby file")
(defun ruby-set-imenu-generic-expression ()
(make-local-variable 'imenu-generic-expression)
(make-local-variable 'imenu-create-index-function)
(setq imenu-create-index-function 'imenu-default-create-index-function)
(setq imenu-generic-expression ruby-imenu-generic-expression))
(add-hook 'ruby-mode-hook 'ruby-set-imenu-generic-expression)但是,这没有起作用(我会得到与以前相同的错误)。更多关于部分的阅读给我指明了方向。现在,我不是elisp专家,下面是我的假设:基本上,上面的方法适用于
mode模式支持“真正”变量‘imenu-泛型-表达式’的缓冲区本地副本。如果您的模式没有做到这一点,您将不得不依赖一个钩子。
foo-mode的示例说明了如何为ruby-mode执行此操作。因此,ruby-mode似乎没有真正的imenu-generic-expression变量的缓冲区本地副本。我仍然无法解释为什么它在Emacs23.2(与ESK v1一起使用)中工作,但在Emacs24上却不起作用,但是至少我找到了一个可行的解决方案。
https://stackoverflow.com/questions/12703110
复制相似问题