[compile/org] automatically jump to Org LP from compilation-mode errors
This commit is contained in:
parent
073d7ce234
commit
31da5dcf03
22
init.org
22
init.org
|
@ -3813,6 +3813,28 @@ Potentially useful - https://www.draketo.de/software/emacs-javascript.html
|
||||||
;; (delete-other-windows)))
|
;; (delete-other-windows)))
|
||||||
(setq compilation-always-kill t))
|
(setq compilation-always-kill t))
|
||||||
|
|
||||||
|
;; The first attempt - this works, but results in the window configuration changing each time you jump to an error, and leaves the buffer visiting the tangled source lying around...
|
||||||
|
;; (advice-add 'compile-goto-error :after (lambda (&rest args) (org-babel-tangle-jump-to-org)))
|
||||||
|
|
||||||
|
(defun my-org-lp-goto-error (oldfn &rest args)
|
||||||
|
"Make `compile-goto-error' lead to an Org literate program."
|
||||||
|
(let (buffer position column)
|
||||||
|
(save-window-excursion
|
||||||
|
(funcall oldfn)
|
||||||
|
(setq column (- (point) (point-at-bol)))
|
||||||
|
(org-babel-tangle-jump-to-org)
|
||||||
|
(setq buffer (current-buffer)
|
||||||
|
position (point)))
|
||||||
|
(let ((org-window (get-buffer-window buffer)))
|
||||||
|
;; if the Org buffer is visible, switch to its window
|
||||||
|
(if (window-live-p org-window)
|
||||||
|
(select-window org-window)
|
||||||
|
(switch-to-buffer buffer)))
|
||||||
|
(goto-char (+ position column))))
|
||||||
|
|
||||||
|
(advice-add 'compile-goto-error :around #'my-org-lp-goto-error)
|
||||||
|
;; (advice-remove 'compile-goto-error #'my-org-lp-goto-error)
|
||||||
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
**
|
**
|
||||||
|
|
Loading…
Reference in New Issue