Skip to main content
added 85 characters in body
Source Link
Tobias
  • 33.7k
  • 1
  • 38
  • 78

I am not aware of a function shipped with org that jumps to the tangled file. Furthermore, there is no separate function that generates the file name(s) for the tangled file(s) in org-babel-tangle. That makes the job a bit cumbersome.

The following hack overridesfunction deleteorg-file and writebabel-regiontangle-jump locally forcalls org-babel-tangle and letswith write-region delivertemporarily modified such that it does not write the region contents to a file but just delivers the file name that is passed to it in a variable file locally bound in org-babel-tangle-jump. Finally, org-babel-tangle-jump opens the file with that name if it already exists.

(defun org-babel-tangle-jump ()
  "Jump to tangle file for the source block at point."
  (interactive)
  (let (file org-babel-pre-tangle-hook org-babel-post-tangle-hook)
    (cl-letf (((symbol-function 'write-region) (lambda (start end filename &rest _ignore)
                         (setq file filename)))
          ((symbol-function 'delete-file) #'ignore))
      (org-babel-tangle '(4)))
    (when file
      (setq file (expand-file-name file))
      (if (file-readable-p file)
      (find-file file)
    (error "Cannot open tangle file %S" file)))))

I am not aware of a function shipped with org that jumps to the tangled file. Furthermore, there is no separate function that generates the file name(s) for the tangled file(s) in org-babel-tangle. That makes the job a bit cumbersome.

The following hack overrides delete-file and write-region locally for org-babel-tangle and lets write-region deliver the file name that is passed to it. Finally, org-babel-tangle-jump opens the file with that name if it already exists.

(defun org-babel-tangle-jump ()
  "Jump to tangle file for the source block at point."
  (interactive)
  (let (file org-babel-pre-tangle-hook org-babel-post-tangle-hook)
    (cl-letf (((symbol-function 'write-region) (lambda (start end filename &rest _ignore)
                         (setq file filename)))
          ((symbol-function 'delete-file) #'ignore))
      (org-babel-tangle '(4)))
    (when file
      (setq file (expand-file-name file))
      (if (file-readable-p file)
      (find-file file)
    (error "Cannot open tangle file %S" file)))))

I am not aware of a function shipped with org that jumps to the tangled file. Furthermore, there is no separate function that generates the file name(s) for the tangled file(s) in org-babel-tangle. That makes the job a bit cumbersome.

The function org-babel-tangle-jump calls org-babel-tangle with write-region temporarily modified such that it does not write the region contents to a file but just delivers the file name that is passed to it in a variable file locally bound in org-babel-tangle-jump. Finally, org-babel-tangle-jump opens the file with that name if it already exists.

(defun org-babel-tangle-jump ()
  "Jump to tangle file for the source block at point."
  (interactive)
  (let (file org-babel-pre-tangle-hook org-babel-post-tangle-hook)
    (cl-letf (((symbol-function 'write-region) (lambda (start end filename &rest _ignore)
                         (setq file filename)))
          ((symbol-function 'delete-file) #'ignore))
      (org-babel-tangle '(4)))
    (when file
      (setq file (expand-file-name file))
      (if (file-readable-p file)
      (find-file file)
    (error "Cannot open tangle file %S" file)))))
added 85 characters in body
Source Link
Tobias
  • 33.7k
  • 1
  • 38
  • 78

I am not aware of a function shipped with org that jumps to the tangled file. Furthermore, there is no separate function that generates the file name(s) for the tangled file(s) in org-babel-tangle. That makes the job a bit cumbersome.

The following hack overrides delete-file and write-region locally for org-babel-tangle and lets write-region deliver the file name that is passed to it. Finally, org-babel-tangle-jump opens the file with that name if it already exists.

(defun org-babel-tangle-jump ()
  "Jump to tangle file for the source block at point."
  (interactive)
  (let (file org-babel-pre-tangle-hook org-babel-post-tangle-hook)
    (cl-letf (((symbol-function 'write-region) (lambda (start end filename &rest _ignore)
                         (setq file filename)))
          ((symbol-function 'delete-file) #'ignore))
      (org-babel-tangle '(4)))
    (when file
      (setq file (expand-file-name file))
      (if (file-readable-p file)
      (find-file file)
    (error "Cannot open tangle file %S" file)))))

I am not aware of a function shipped with org that jumps to the tangled file. Furthermore, there is no separate function that generates the file name(s) for the tangled file(s) in org-babel-tangle. That makes the job a bit cumbersome.

The following hack overrides delete-file and write-region locally for org-babel-tangle and lets write-region deliver the file name that is passed to it.

(defun org-babel-tangle-jump ()
  "Jump to tangle file for the source block at point."
  (interactive)
  (let (file org-babel-pre-tangle-hook org-babel-post-tangle-hook)
    (cl-letf (((symbol-function 'write-region) (lambda (start end filename &rest _ignore)
                         (setq file filename)))
          ((symbol-function 'delete-file) #'ignore))
      (org-babel-tangle '(4)))
    (when file
      (setq file (expand-file-name file))
      (if (file-readable-p file)
      (find-file file)
    (error "Cannot open tangle file %S" file)))))

I am not aware of a function shipped with org that jumps to the tangled file. Furthermore, there is no separate function that generates the file name(s) for the tangled file(s) in org-babel-tangle. That makes the job a bit cumbersome.

The following hack overrides delete-file and write-region locally for org-babel-tangle and lets write-region deliver the file name that is passed to it. Finally, org-babel-tangle-jump opens the file with that name if it already exists.

(defun org-babel-tangle-jump ()
  "Jump to tangle file for the source block at point."
  (interactive)
  (let (file org-babel-pre-tangle-hook org-babel-post-tangle-hook)
    (cl-letf (((symbol-function 'write-region) (lambda (start end filename &rest _ignore)
                         (setq file filename)))
          ((symbol-function 'delete-file) #'ignore))
      (org-babel-tangle '(4)))
    (when file
      (setq file (expand-file-name file))
      (if (file-readable-p file)
      (find-file file)
    (error "Cannot open tangle file %S" file)))))
added 1 character in body
Source Link
Tobias
  • 33.7k
  • 1
  • 38
  • 78

I am not aware of a function shipped with org that jumps to the tangled file. Furthermore, there is no separate function that generates the file name(s) for the tangled file(s) in org-babel-tangle. That makes the job a bit cumbersome.

The following hack overrides delete-file and write-region locally for org-babel-tangle and letlets write-region deliver the file name that is passed to it.

(defun org-babel-tangle-jump ()
  "Jump to tangle file for the source block at point."
  (interactive)
  (let (file org-babel-pre-tangle-hook org-babel-post-tangle-hook)
    (cl-letf (((symbol-function 'write-region) (lambda (start end filename &rest _ignore)
                         (setq file filename)))
          ((symbol-function 'delete-file) #'ignore))
      (org-babel-tangle '(4)))
    (when file
      (setq file (expand-file-name file))
      (if (file-readable-p file)
      (find-file file)
    (error "Cannot open tangle file %S" file)))))

I am not aware of a function shipped with org that jumps to the tangled file. Furthermore, there is no separate function that generates the file name(s) for the tangled file(s) in org-babel-tangle. That makes the job a bit cumbersome.

The following hack overrides delete-file and write-region locally for org-babel-tangle and let write-region deliver the file name that is passed to it.

(defun org-babel-tangle-jump ()
  "Jump to tangle file for the source block at point."
  (interactive)
  (let (file org-babel-pre-tangle-hook org-babel-post-tangle-hook)
    (cl-letf (((symbol-function 'write-region) (lambda (start end filename &rest _ignore)
                         (setq file filename)))
          ((symbol-function 'delete-file) #'ignore))
      (org-babel-tangle '(4)))
    (when file
      (setq file (expand-file-name file))
      (if (file-readable-p file)
      (find-file file)
    (error "Cannot open tangle file %S" file)))))

I am not aware of a function shipped with org that jumps to the tangled file. Furthermore, there is no separate function that generates the file name(s) for the tangled file(s) in org-babel-tangle. That makes the job a bit cumbersome.

The following hack overrides delete-file and write-region locally for org-babel-tangle and lets write-region deliver the file name that is passed to it.

(defun org-babel-tangle-jump ()
  "Jump to tangle file for the source block at point."
  (interactive)
  (let (file org-babel-pre-tangle-hook org-babel-post-tangle-hook)
    (cl-letf (((symbol-function 'write-region) (lambda (start end filename &rest _ignore)
                         (setq file filename)))
          ((symbol-function 'delete-file) #'ignore))
      (org-babel-tangle '(4)))
    (when file
      (setq file (expand-file-name file))
      (if (file-readable-p file)
      (find-file file)
    (error "Cannot open tangle file %S" file)))))
Source Link
Tobias
  • 33.7k
  • 1
  • 38
  • 78
Loading