0

I am using emacs to edit Latex. My work flow is to open the latex file, open a new buffer in a separate window via C-x 2. Then moving the context into the new windowbuffer via C-x o, I type M x shell to open a terminal.

This is all fine but I then need to type in the changing of directories to get to the Latex file, and I do this frequently. So I would like to know if there is a quick way to open the shell in the current directory of the Latex file?

  • 1
    on my system it does just that (emacs 24.5.1). Maybe check variable default-directory? – JeanPierre Aug 23 '16 at 20:25
  • @JeanPierre, I am a bit of an amateur in Emacs, but how do I execute this default-directory? I tried M x default-directory' which did not work. – Vass Aug 24 '16 at 0:37
  • 1
    default-directory is a variable, so use C-h v default-directory to see the value of the default directory in the shell buffer that you opened up. – Kevin Aug 24 '16 at 4:08
  • @Kevin,default-directory is a variable defined in C source code'. Its value is "~/Documents/Latex/UCF/STA4102/2/" Local in buffer 2.tex; global value is nil Automatically becomes permanently buffer-local when set. This variable is safe as a file local variable if its value satisfies the predicate stringp'. Documentation: Name of default directory of current buffer. Should end with slash. To interactively change the default directory, use command `cd'. – Vass Aug 24 '16 at 20:33
1

One way to do what you want is to open the shell in the window that displays the Latex file. That way, the shell opens up in the directory containing the Latex file. Then switch windows C-x o and switch buffers C-x b back to the Latex file. This is just a different ordering of the actions that you are currently taking.

  • Simple solution that works. Nice and clever :) – Vass Aug 24 '16 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.