[Tex/LaTex] Inverse search with Emacs/AucTeX and SumatraPDF [on Windows 10]

auctexemacsforward-inverse-searchsumatrapdf

I've been trying to use Emacs/AucTeX along with SumatraPDF to view my output. In particular, I would like to make the forward and inverse search work. I use Windows 10.

Problem

Every time I double click something in my pdf output, a new instance (or a new window) of Emacs opens. Once at least one instance has .tex file opened, the following instances give the following message:

Warning: desktop file appears to be in use by PID 5132.
Using it may cause conflicts. Use it anyway? (y or n)

Regardless of my decision (y/n), I get new instances of Emacs with my .tex file open after every subsequent double click in my pdf output file.

I believe I should be redirected to a proper place in an opened .tex file in Emacs instead.

My current configuration

Here's what I added to my .emacs:

(setq TeX-PDF-mode t)
(setq TeX-source-correlate-mode t)
(setq TeX-source-correlate-method 'synctex)
(setq TeX-view-program-list
'(("Sumatra PDF" ("\"C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe\" -reuse-instance"
   (mode-io-correlate " -forward-search %b %n ") " %o"))))

(eval-after-load 'tex
 '(progn
   (assq-delete-all 'output-pdf TeX-view-program-selection)
   (add-to-list 'TeX-view-program-selection '(output-pdf "Sumatra PDF")))

My "Set inverse search" command in SumatraPDF:

"C:\Program Files (x86)\GNU Emacs 24.5\bin\runemacs.exe"  +%l "%f" 

Help will be greatly appreciated.

Disclaimer: I am new to Emacs — sorry if my question is trivial.

Best Answer

Arash's suggestion in the comment above has solved the problem for me.

Related Question