Friday, May 20, 2011

Is GNU Global hijacking your middle click in Emacs?

Someone asked me today about using GNU Global gtags with Emacs. This is certainly a useful feature to have. I prefer gtags over etags even though some quirks still exist. The problem is that the default gtags behavior is to override the function of the middle click. If you are a long-time user of Emacs, you know this button is bound by default in Emacs to mouse-yank-at-click. The gtags authors realized this and added a variable to control this mapping. To disable the new binding by gtags, first, make sure you are using the latest gtags.el from the GNU Global distribution. Second, set gtags-disable-pushy-mouse-mapping to a non-nil value. Add the following to your .emacs file.

(autoload 'gtags-mode "gtags" "" t)
(setq gtags-mode-hook
      '(lambda ()
         (setq gtags-path-style 'relative)
         (setq gtags-disable-pushy-mouse-mapping t)
         ))
(add-hook 'c-mode-common-hook
          '(lambda ()
             (gtags-mode t)
             ))

Update: It looks like release 5.9.7 of GNU Global has disabled the mouse mapping by default.

No comments: