hippie-expand

直到前两天才通过Most useful Emacs features – Stack Overflow知道hippie-expand这么好用的东西,然后抄了一段Alex Schroeder的配置,也就是根据可能性重新排列一下补全的规则,如将补全文件名放到链表的后面。另外还从wiki页上抄了一段用tag做补全的配置。

虽然补全文件或路径很少用到,但是在添加load-path的时候就很方便了,感觉就像在mini-buffer里输入路径一样。当然用得最多的还是在写程序的时候了。下面是我的配置:

(global-set-key (kbd "M-/") 'hippie-expand)

(defun he-tag-beg ()
  (let ((p
         (save-excursion
           (backward-word 1)
           (point))))
    p))

(defun try-expand-tag (old)
  (unless  old
    (he-init-string (he-tag-beg) (point))
    (setq he-expand-list (sort
                          (all-completions he-search-string 'tags-complete-tag) 'string-lessp)))
  (while (and he-expand-list
              (he-string-member (car he-expand-list) he-tried-table))
              (setq he-expand-list (cdr he-expand-list)))
  (if (null he-expand-list)
      (progn
        (when old (he-reset-string))
        ())
    (he-substitute-string (car he-expand-list))
    (setq he-expand-list (cdr he-expand-list))
    t))

(setq hippie-expand-try-functions-list
      '(try-expand-all-abbrevs try-expand-dabbrev
 try-expand-dabbrev-all-buffers try-expand-dabbrev-from-kill
 try-complete-lisp-symbol-partially try-complete-lisp-symbol
 try-complete-file-name-partially try-complete-file-name try-expand-tag))

3 thoughts on “hippie-expand

  1. Sucha says:

    很早就开始用 hippie-expand 了,可是相当地好用,感觉关于 cc++ 的 tag,emacs 下 gtags 很好用,速度要比 cscope 来得快

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据