2

我已经在 GNU Emacs 24.3 上使用 el-get 安装了官方 CEDET 2.0 并对其进行了配置。虽然它非常适合代码跳转和补全,但它不能与 Emacs 内置的 which-function-mode 一起正常工作。当主要模式是 Java 模式时,Emacs 模式行只显示 [???],就像没有识别出有效的函数一样。但是当我删除我的 CEDET 配置时,which-function-mode 运行良好。所以我认为问题应该与官方的CEDET 2.0有关。我尝试手动启用哪个功能模式,问题仍然存在。

我无法弄清楚我的配置哪里出了问题。

任何人都可以帮忙吗?谢谢。

更新: 如果我通过注释掉该行(语义模式 1)来禁用语义,那么 which-function-mode 将起作用。我检查了 CEDET 文档,语义以我所做的方式启用。

(add-to-list 'load-path (concat cedet-root-path "contrib"))

(add-to-list 'semantic-default-submodes 'global-semantic-mru-bookmark-mode)
(add-to-list 'semantic-default-submodes 'global-semanticdb-minor-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-scheduler-mode)
(add-to-list 'semantic-default-submodes 'global-cedet-m3-minor-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-highlight-func-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-local-symbol-highlight-mode)

;; Activate semantic
(semantic-mode 1)

;; Load contrib library
(require 'eassist)

(when (not (member system-type '(gnu gnu/linux darwin cygwin)))
  (if (executable-find "gcc")
      (semantic-gcc-setup)
    (message "GCC is not installed and semantic analysis will be restriced.")))

(setq pulse-flag 'never)  ; No fade in/out effect
(setq semanticdb-default-save-directory
      (expand-file-name "~/.emacs.d/semanticdb"))
(setq eassist-header-switches
      '(("h" . ("cpp" "cxx" "c++" "CC" "cc" "C" "c" "mm" "m"))
        ("hh" . ("cc" "CC" "cpp" "cxx" "c++" "C"))
        ("hpp" . ("cpp" "cxx" "c++" "cc" "CC" "C"))
        ("hxx" . ("cxx" "cpp" "c++" "cc" "CC" "C"))
        ("h++" . ("c++" "cpp" "cxx" "cc" "CC" "C"))
        ("H" . ("C" "CC" "cc" "cpp" "cxx" "c++" "mm" "m"))
        ("HH" . ("CC" "cc" "C" "cpp" "cxx" "c++"))
        ("cpp" . ("hpp" "hxx" "h++" "HH" "hh" "H" "h"))
        ("cxx" . ("hxx" "hpp" "h++" "HH" "hh" "H" "h"))
        ("c++" . ("h++" "hpp" "hxx" "HH" "hh" "H" "h"))
        ("CC" . ("HH" "hh" "hpp" "hxx" "h++" "H" "h"))
        ("cc" . ("hh" "HH" "hpp" "hxx" "h++" "H" "h"))
        ("C" . ("hpp" "hxx" "h++" "HH" "hh" "H" "h"))
        ("c" . ("h"))
        ("m" . ("h"))
        ("mm" . ("h"))))


;; Save the current jump point in order to jump back when using CEDET
;; http://comments.gmane.org/gmane.emacs.cedet/5127
(defvar semantic-tags-location-ring (make-ring 512))

(defun semantic-goto-definition (point)
  "Goto definition using semantic-ia-fast-jump
save the pointer marker if tag is found"
  (interactive "d")
  (condition-case err
      (progn
        (ring-insert semantic-tags-location-ring (point-marker))
        (semantic-ia-fast-jump point))
    (error
     ;;if not found remove the tag saved in the ring
     (set-marker (ring-remove semantic-tags-location-ring 0) nil nil)
     (signal (car err) (cdr err)))))

(defun semantic-pop-tag-mark ()
  "popup the tag save by semantic-goto-definition"
  (interactive)
  (if (ring-empty-p semantic-tags-location-ring)
      (message "%s" "No more tags available")
    (let* ((marker (ring-remove semantic-tags-location-ring 0))
           (buff (marker-buffer marker))
           (pos (marker-position marker)))
      (if (not buff)
          (message "Buffer has been deleted")
        (switch-to-buffer buff)
        (goto-char pos))
      (set-marker marker nil nil))))

(defun cedet-common-setup ()
  (local-set-key (kbd "C-c j") 'semantic-goto-definition)
  (local-set-key (kbd "C-c b") 'semantic-pop-tag-mark)
  (local-set-key (kbd "C-c o") 'semantic-ia-show-summary)
  (local-set-key (kbd "C-c d") 'semantic-ia-show-doc)
  (local-set-key (kbd "C-c p") 'semantic-analyze-proto-impl-toggle)

  (local-set-key (kbd "C-c f") 'semantic-symref)
  (local-set-key (kbd "C-c r") 'semantic-symref-symbol)

  (local-set-key (kbd "C-c <left>") 'semantic-tag-folding-fold-block)
  (local-set-key (kbd "C-c <right>") 'semantic-tag-folding-show-block)

  ;; We use auto complete to get candidate
  (if window-system
      (local-set-key (kbd "M-n") 'semantic-ia-complete-symbol-menu))

  (local-set-key (kbd "C-c m") 'eassist-list-methods))

(defun cedet-c-c++-setup ()
;;  (local-set-key "." 'semantic-complete-self-insert)
;;  (local-set-key ">" 'semantic-complete-self-insert)
(local-set-key (kbd "C-c h") 'eassist-switch-h-cpp) ; Jump between .c and .h
(when (executable-find "cscope")
  (require 'cedet-cscope)
  (require 'semantic/db-cscope)
  (semanticdb-enable-cscope-databases)
  (local-set-key (kbd "C-c i") 'cedet-cscope-create/update-database)))

(defun cedet-java-setup ()
  (require 'cedet-java)
  (require 'semantic/db-javap))
4

1 回答 1

0

次要模式global-semantic-idle-breadcrumbs-mode大致类似于which-func-mode但使用标题而不是模式行,因此它有更多空间来描述您的上下文。还有 `global-semantic-stickyfunc-mode' 也是类似的,但只显示哪些功能部分不在屏幕顶部,而不是光标所在的位置。

要启用原始which-func-mode而不禁用语义,您可能只需要禁用建议语义用于集成。用于ad-disable-advice关闭semantic-which它。最新版本的 CEDET 不会尝试重载 which-func,因此更新到最新版本也可以工作。

于 2014-07-15T02:56:47.033 回答