Search code examples
emacslatexgrepauctex

Using next-error and previous-error keybindings for grep under Auctex's LaTeX-mode


How can I navigate through text found by M-x grep using C-x ` and M-g p? These are normally bound to next-error and previous-error but in Auctex's LaTeX-mode they are re-bound to TeX-next-error and TeX-previous-error. I have tried using both local-set-key and global-set-key to rebind these keystrokes, but neither method works.

MWE: install Auctex, make a tex file, grep for something, and try the above keystrokes from within the tex buffer. Using M-x next-error will work, so will using the keystrokes from inside the *grep* buffer.


Solution

  • (defun jpk/LaTeX-mode-hook ()
      (local-set-key [remap next-error] nil)
      (local-set-key [remap previous-error] nil))
    
    (add-hook 'LaTeX-mode-hook 'jpk/LaTeX-mode-hook)