4

find-tagデフォルトのオプション (ポイントの単語) を自動的に受け入れて、プロンプトを表示せずにタグの位置にジャンプしたいと思います。

これは可能ですか?

また、一致した場合に ctags を再実行する、Emacswiki の推奨バージョンの find-tag も使用しています。だから私はこのようなものが欲しい:

is current word a known tag?
-> yes: jump to it without further confirmation
-> no: rerun ctags
is it known now?
-> yes: jump to it without further confirmation
-> no: prompt user for input

ありがとうございました!

4

5 に答える 5

2

さて、私はハックの解決策を見つけました:

;; auto jump
(global-set-key (kbd "C-x C-M->") 'find-tag) ; bind to some unused placeholder
(global-set-key (kbd "M-.") (kbd "C-x C-M-> <return>"))

まず、find-tag を、決して使用しないダミー バインドにバインドします (この手順は、無限ループを回避するために必要です)。次にM-.、この新しいバインディング + にバインドし<return>ます。

醜いですが、うまくいきます...誰かがより良い答えを持っている場合は、質問を開いたままにします(元の質問で説明されている失敗した検索の処理を含む)。

于 2012-08-23T07:50:11.703 に答える
2

これがctagsの私の設定です。私にとっては素晴らしい作品です。ここから 借ります.

(require 'eproject)
(require 'etags-select)

(defun build-ctags ()
  (interactive)
  (message "building project tags")
  (let ((root (eproject-root)))
    (shell-command
     (concat "ctags-exuberant -e -R --extra=+fq --exclude=db --exclude=test --exclude=.git --exclude=public -f " root "TAGS " root)))
  (visit-project-tags)
  (message "tags built successfully"))

(defun visit-project-tags ()
  (interactive)
  (let ((tags-file (concat (eproject-root) "TAGS")))
    (visit-tags-table tags-file)
    (message (concat "Loaded " tags-file))))

(defun hbin-find-tag ()
  "Borrow from http://mattbriggs.net/blog/2012/03/18/awesome-emacs-plugins-ctags/"
  (interactive)
  (if (file-exists-p (concat (eproject-root) "TAGS"))
      (visit-project-tags)
    (build-ctags))
  (etags-select-find-tag-at-point))

(global-set-key (kbd "M-.") 'hbin-find-tag)

PS:これらが必要になる場合があります:

git://github.com/jrockway/eproject.git
git://github.com/emacsmirror/etags-select.git
于 2012-08-22T14:26:37.440 に答える
0

これは、依存するgemをロードするわずかに変更されたバージョンです(Ruby on Railsで役立ちます)

  (defun build-ctags ()
      (interactive)
      (message "building project tags")
      (let ((default-directory (eproject-root)))
        (shell-command (concat "exctags -e -R --extra=+fq --exclude=db --exclude=test --exclude=.git --exclude=public -f TAGS * " (trim-string (shell-command-to-string "rvm gemdir")) "/gems/*"))
        (visit-project-tags)
        (message "tags built successfully")))
于 2013-03-20T17:47:55.410 に答える