-
Notifications
You must be signed in to change notification settings - Fork 0
/
synorg.el
44 lines (40 loc) · 1.75 KB
/
synorg.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(defun synorg-forward ()
"Forward syntex for Org.
Trying to jump from current line to matched line LaTeX counterpart.
From there, jump to PDF line via `AUCTeX'\'s `TeX-view'.
See `synorg-backward' for backward direction and command line
setup."
(interactive)
(let ((text (replace-regexp-in-string
;; leading, trailing spaces;
;; backslashes, brackets, curly braces, dollars
"\\(^[ \t]+\\|[ \t]+$\\|\\\\[^ {\\[]*\\|\\[.*\\]\\|{.*}\\|\\$.*\\$\\)" ".*"
(buffer-substring-no-properties
(line-beginning-position) (line-end-position))))
(tex-file (replace-regexp-in-string "org\\'" "tex" (buffer-file-name))))
(save-window-excursion
(find-file tex-file)
(goto-char (point-min))
(re-search-forward text)
(TeX-view))))
(defun synorg-backward (file line)
"Backward syntex for Org.
Trying to jump from `line' in LaTeX `file'.
`emacsclient --no-wait --eval \"(synorg-backward \\\"%file\\\" %line)\"'"
(let ((text (save-window-excursion
(find-file file)
(goto-line line)
(replace-regexp-in-string
;; leading, trailing spaces;
;; backslashes, brackets, curly braces, dollars
"\\(^[ \t]+\\|[ \t]+$\\|\\\\[^ {\\[]*\\|\\[.*\\]\\|{.*}\\|\\$.*\\$\\)" ".*"
(buffer-substring-no-properties
(line-beginning-position) (line-end-position)))))
(org-file (replace-regexp-in-string "tex\\'" "org" file)))
(find-file org-file)
(goto-char (point-min))
(re-search-forward text)
(org-show-entry)
(recenter)
(global-hl-line-mode global-hl-line-mode)))
(provide 'synorg)