Search code examples
emacstramp

How do I get tramp to use the local version of an executable


My scenario: I am editing a file remotely when I decide to switch tasks and run mysql as a subprocess using sql-interactive mode. Tramp tries to start the mysql client from the remote machine, where its not installed.

I would like to configure emacs so it always runs certain executables, such as mysql, locally and not from the tramp remote machine. How can I do this?


Solution

  • Tramp kicks in if the value of the variable default-directory (which if set becomes buffer-local) is in Tramp format. You can do something like this to ensure it gets reset to point to your local home directory wherever you need to run mysql:

    (defadvice sql-mysql (around sql-mysql-around activate)
      "Reset to local home, then connect"
      (let ((default-directory "/home/me"))
        ad-do-it))
    

    The code assumes you you use sql-mode to launch mysql.