Open tex file corresponding to an opened pdf file
0
votes
1
answer
59
views
Suppose I have opened a pdf file (say
/path/to/my/file.pdf
generated from LaTeX) in evince and want to open the corresponding LaTeX source file (/path/to/my/file.tex
) in my emacs editor, I click on properties in evince and copy the path to the file to the clipboard, paste it to the minibuffer from emacs find-file
dialogue, manually change the file ending pdf to tex and open the file.
Now I want to ask if there is a significantly faster way to do the same thing (maybe using another pdf-viewer), for example by configuring a keyboard shortcut (for example in the pdf-viewer itself or on wm level, in my case xmonad) or configuring a custom button in the pdf viewer.
**Edit** I should add that the situation where I need it is, that I have 20 pdf documents opened at the same time.
**Edit 2** Following @meuh suggestion I tried the following
cat get_tex_name.sh
#!/bin/sh
pid=xprop _NET_WM_PID
filename=ls -l /proc/'$pid'/fd/ | grep pdf | sed 's/.*\(\/.*home.*\).pdf/\1tex/'
#emacsclient -c $filename
urxvt -hold -e sh -c "echo $filename"
and in my .xmonad
file:
[...]
-- find corresponding tex file
, ((modm, xK_p ), spawn "get_tex_name.sh")
Now if I have a focused evince instance and run the stript via Windows-p, it doesn't seem to get the filename (I think because xprop doesn't seem to return the pid of the focused window but only after clicking on it).
So how to make it work?
Asked by student
(18865 rep)
Aug 30, 2022, 08:47 AM
Last activity: Dec 1, 2022, 03:37 PM
Last activity: Dec 1, 2022, 03:37 PM