我想将CEDET模式连接到c++模式。我在我的.emacs文件中使用了以下脚本:
(add-hook 'c++-mode-hook
(lambda ()
...
(my_cedet_load)
)
)哪里
(defun my_cedet_load ()
(interactive)
(semantic-mode)
(global-semantic-stickyfunc-mode t)
(global-semantic-idle-scheduler-mode t)
(global-semantic-idle-completions-mode t)
(global-semantic-highlight-edits-mode t)
)现在,问题是,一旦我打开一个.cpp文件,语义模式就会在所有缓冲区中启用。如何仅在.cpp文件中启用这种模式?
发布于 2014-03-10 14:55:21
语义是一种全局次要模式。来自semantic.el
要启用语义,请打开“语义模式”,这是一种全局次要模式(M语义模式RET,或“Tools”菜单中的“源代码解析器”)。要在启动时启用它,请将(语义模式1)放在init文件中。
因此,当您执行semantic-mode时,在所有缓冲区中都启用了它。可以使用semantic-inhibit-functions限制激活semantic的缓冲区。从文件中
在设置语义之前不带参数调用的函数列表。如果这些函数中的任何一个返回非零,则不设置当前缓冲区以使用语义。
下面是使用此变量的示例。它将指示semantic仅在c-mode、cc-mode和java-mode缓冲区中激活。
(add-to-list 'semantic-inhibit-functions
(lambda () (not (member major-mode '(java-mode c-mode c++-mode)))))发布于 2014-03-10 07:48:20
我猜关键在于global这个词。所以使用semantic-stickyfunc-mode而不是global-semantic-stickyfunc-mode等等。
更新:
试试这个:
(add-hook 'c++-mode-hook 'my-c++-hook)
(defun my-c++-hook ()
(semantic-mode 1)
(semantic-stickyfunc-mode 1)
(semantic-idle-scheduler-mode 1)
(semantic-idle-completions-mode 1)
(semantic-highlight-edits-mode 1))https://stackoverflow.com/questions/22291985
复制相似问题