[compile/org] add headings, handle prefix arg, remove old version
This commit is contained in:
parent
b29c6054cd
commit
19129eae62
53
init.org
53
init.org
|
@ -3799,7 +3799,7 @@ Potentially useful - https://www.draketo.de/software/emacs-javascript.html
|
|||
|
||||
#+END_SRC
|
||||
|
||||
**
|
||||
** compile
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package compile
|
||||
:config
|
||||
|
@ -3807,32 +3807,39 @@ Potentially useful - https://www.draketo.de/software/emacs-javascript.html
|
|||
;; (lambda (proc)
|
||||
;; (delete-other-windows)))
|
||||
(setq compilation-always-kill t))
|
||||
#+END_SRC
|
||||
|
||||
;; 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)))
|
||||
*** jump to Org LP from compilation output
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: compile-org-lp-jump
|
||||
:END:
|
||||
|
||||
(defun my-org-lp-goto-error (oldfn &rest args)
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun my-org-lp-goto-error (oldfn &optional prefix &rest args)
|
||||
"Make `compile-goto-error' lead to an Org literate program."
|
||||
(let (buffer position column tangled-file-p)
|
||||
(save-window-excursion
|
||||
(interactive "P")
|
||||
(if prefix
|
||||
(funcall oldfn)
|
||||
(setq column (- (point) (point-at-bol)))
|
||||
;; `compile-goto-error' might be called from the output of
|
||||
;; `literate-elisp-byte-compile-file', which means
|
||||
;; `org-babel-tangle-jump-to-org' would error
|
||||
(when (ignore-errors (org-babel-tangle-jump-to-org))
|
||||
(setq buffer (current-buffer)
|
||||
position (point)
|
||||
tangled-file-p t)))
|
||||
;; back to where we started - the `compilation-mode' buffer
|
||||
(if tangled-file-p
|
||||
(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)))
|
||||
(funcall oldfn))))
|
||||
(let (buffer position column tangled-file-p)
|
||||
(save-window-excursion
|
||||
(funcall oldfn)
|
||||
(setq column (- (point) (point-at-bol)))
|
||||
;; `compile-goto-error' might be called from the output of
|
||||
;; `literate-elisp-byte-compile-file', which means
|
||||
;; `org-babel-tangle-jump-to-org' would error
|
||||
(when (ignore-errors (org-babel-tangle-jump-to-org))
|
||||
(setq buffer (current-buffer)
|
||||
position (point)
|
||||
tangled-file-p t)))
|
||||
;; back to where we started - the `compilation-mode' buffer
|
||||
(if tangled-file-p
|
||||
(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)))
|
||||
(funcall oldfn)))))
|
||||
|
||||
(advice-add 'compile-goto-error :around #'my-org-lp-goto-error)
|
||||
;; (advice-remove 'compile-goto-error #'my-org-lp-goto-error)
|
||||
|
|
Loading…
Reference in New Issue