Find tags in a included tags file

etags-select首先列出所有候选的tag定义位置,然后由用户选择其中一个;而不像etags那样每次跳到其中一个定义,如果用户发现不是自己想要的结果,则继续往下跳。

etags-select有一个缺陷,不能处理included tags file,如Emacs Lisp的tags文件TAGS-LISP。不过,如果想弥补它也很容易,只需重定义其中一个函数即可。

(defun etags-select-get-tag-files ()
  "Get tag files."
  (if etags-select-use-xemacs-etags-p
      (buffer-tag-table-list)
    (mapcar 'tags-expand-table-name tags-table-list)
    (tags-table-check-computed-list)
    tags-table-computed-list))

Auto complete

hippie-expand提供的补全功能帮了我不少忙,可是我个人不太偏好这种MS Dos方式的补全。auto-complete.el正合我意,它的作者用一段视频展示了auto complete提供怎样的功能。

我的配置如下:

(when (require-maybe 'auto-complete)
  (global-auto-complete-mode t)
  (define-key ac-complete-mode-map "C-n" 'ac-next)
  (define-key ac-complete-mode-map "C-p" 'ac-previous)
  (setq ac-auto-start 4)
  (add-hook 'emacs-lisp-mode-hook
            (lambda ()
              (make-local-variable 'ac-sources)
              (setq ac-sources '(ac-source-words-in-buffer ac-source-symbols))))

  (defvar ac-source-etags
    '((candidates
       . (lambda () (all-completions ac-target (tags-completion-table))))))
  (defun wl-add-ac-source-etags ()
    (make-local-variable 'ac-sources)
    (add-to-list 'ac-sources 'ac-source-etags))

  (add-hook 'c-mode-common-hook 'wl-add-ac-source-etags))