Rework all custom bindings keys

This commit is contained in:
Thomas Dehaeze 2020-03-22 19:42:41 +01:00
parent 4b8ceb723e
commit 33d7056d85

View File

@ -122,16 +122,16 @@ Documentation:
:en "C-l" #'evil-window-right))
#+end_src
Make movement keys work like they should
#+begin_src emacs-lisp
;; Make movement keys work like they should
(define-key evil-normal-state-map (kbd "<remap> <evil-next-line>") 'evil-next-visual-line)
(define-key evil-normal-state-map (kbd "<remap> <evil-previous-line>") 'evil-previous-visual-line)
(define-key evil-motion-state-map (kbd "<remap> <evil-next-line>") 'evil-next-visual-line)
(define-key evil-motion-state-map (kbd "<remap> <evil-previous-line>") 'evil-previous-visual-line)
#+end_src
Make horizontal movement cross lines
#+begin_src emacs-lisp
; Make horizontal movement cross lines
(setq-default evil-cross-lines t)
#+end_src
@ -830,115 +830,16 @@ by spaces.
#+end_src
** Org LaTeX
*** Org latex fragment
Don't change the font size for subscripts and superscripts in latex fragments.
This cause the orgmode tables not to be well aligned.
#+begin_src emacs-lisp
(after! org
(setq font-latex-fontify-script nil))
#+end_src
#+begin_src emacs-lisp
(defvar tdh-org-latex-fragment-last nil
"Holds last fragment/environment you were on.")
(defun tdh-org-in-latex-fragment-p ()
"Return the point where the latex fragment begins, if inside
a latex fragment. Else return false"
(let* ((el (org-element-context))
(el-type (car el)))
(and (or (eq 'latex-fragment el-type) (eq 'latex-environment el-type))
(org-element-property :begin el))))
(defun tdh-org-latex-fragment-toggle ()
"Toggle a latex fragment image "
(and (eq 'org-mode major-mode)
(let ((begin (tdh-org-in-latex-fragment-p)))
(cond
;; were on a fragment and now on a new fragment
((and
;; fragment we were on
tdh-org-latex-fragment-last
;; and are on a fragment now
begin
;; but not on the last one this is a little tricky. as you edit the
;; fragment, it is not equal to the last one. We use the begin
;; property which is less likely to change for the comparison.
(not (and tdh-org-latex-fragment-last
(= begin
tdh-org-latex-fragment-last))))
;; go back to last one and put image back, provided there is still a fragment there
(save-excursion
(goto-char tdh-org-latex-fragment-last)
(when (tdh-org-in-latex-fragment-p) (org-preview-latex-fragment))
;; now remove current image
(goto-char begin)
(let ((ov (loop for ov in (org--list-latex-overlays)
if
(and
(<= (overlay-start ov) (point))
(>= (overlay-end ov) (point)))
return ov)))
(when ov
(delete-overlay ov)))
;; and save new fragment
(setq tdh-org-latex-fragment-last begin)))
;; were on a fragment and now are not on a fragment
((and
;; not on a fragment now
(not begin)
;; but we were on one
tdh-org-latex-fragment-last)
;; put image back on, provided that there is still a fragment here.
(save-excursion
(goto-char tdh-org-latex-fragment-last)
(when (tdh-org-in-latex-fragment-p) (org-preview-latex-fragment)))
;; unset last fragment
(setq tdh-org-latex-fragment-last nil))
;; were not on a fragment, and now are
((and
;; we were not one one
(not tdh-org-latex-fragment-last)
;; but now we are
begin)
;; remove image
(save-excursion
(goto-char begin)
(let ((ov (loop for ov in (org--list-latex-overlays)
if
(and
(<= (overlay-start ov) (point))
(>= (overlay-end ov) (point)))
return ov)))
(when ov
(delete-overlay ov))))
(setq tdh-org-latex-fragment-last begin))))))
#+end_src
#+begin_src emacs-lisp
(map! :map org-mode-map
;; Activate Automatic LaTeX fragment
:n ",ol" '(lambda () (interactive) (add-hook 'post-command-hook 'tdh-org-latex-fragment-toggle t))
;; ;; Disable Automatic LaTeX fragment
:n ",oL" '(lambda () (interactive) (remove-hook 'post-command-hook 'tdh-org-latex-fragment-toggle)))
#+end_src
*** TODO Latex Fragments
- [ ] The remove hook does not seems to work
http://slumpy.org/blog/2017-02-01-automatic-latex-preview-in-org-mode/
*** LaTeX Fragments
#+begin_src emacs-lisp
(after! org
;; Highligh latex parts in org mode
(setq org-highlight-latex-and-related '(native))
;; Use F9 to globally generate all the latex fragments
(map! :map org-mode-map :n "<f9>" (lambda () (interactive) (org-preview-latex-fragment 16)))
(map! :map org-mode-map
:n "<f9>"
(lambda () (interactive) (org-preview-latex-fragment 16)))
;; Put all the preview images in some directory
(setq org-preview-latex-image-directory "~/.ltximg/")
@ -976,6 +877,10 @@ http://slumpy.org/blog/2017-02-01-automatic-latex-preview-in-org-mode/
;; Use imagemagick/dvisvgm to generate png from pdf
(setq org-preview-latex-default-process 'dvisvgm)
;; Don't change the font size for subscripts and superscripts in latex fragments.
;; This cause the orgmode tables not to be well aligned.
(setq font-latex-fontify-script nil)
;; Colors of latex fragments
(setq org-format-latex-options (plist-put org-format-latex-options :foreground 'default))
(setq org-format-latex-options (plist-put org-format-latex-options :background (face-background 'fringe)))
@ -1594,149 +1499,6 @@ Nice Functions:
:table-of-contents nil)))
#+end_src
** Custom key bindings
*** Insert Link to paper / notes
#+begin_src emacs-lisp
(defun tdh-insert-paper-org-link (paper)
"Insert an org link to some paper, choosing the file with completion"
(interactive
(list (read-file-name "Paper: " "~/Cloud/thesis/ressources/pdfs/" nil t)))
(insert (format "[[papers:%s]]" (file-name-base paper))))
(after! org
(map! :map org-mode-map :n ",ip" 'tdh-insert-paper-org-link))
#+end_src
#+begin_src emacs-lisp
(defun tdh-insert-note-org-link (note)
"Insert an org link to some note, choosing the file with completion"
(interactive
(list (read-file-name "Note: " "~/Cloud/thesis/ressources/pdfs/" nil t)))
(insert (format "[[notes:%s]]" (file-name-base note))))
(after! org
(map! :map org-mode-map :n ",in" 'tdh-insert-note-org-link))
#+end_src
*** Insert Image that is in the figs folder
#+begin_src emacs-lisp
(defun tdh-insert-image-org-link (img)
"Insert an org image link, choosing the file with completion
and starting from `my-default-image-directory'."
(interactive
(list (file-relative-name (read-file-name "Image: " (concat default-directory "figs/")) default-directory)))
(insert (format "[[file:%s]]" img)))
(after! org
(map! :map org-mode-map :n ",if" 'tdh-insert-image-org-link))
#+end_src
*** Watch LaTeX file using latexmk
#+begin_src emacs-lisp
(defun tdh-latex/watch ()
"Watch LaTeX file using latexmk"
(interactive)
(start-process-shell-command "latexmk-watch" "*latexmk-watch-output*"
"latexmk" (format "-pdflatex=\"xelatex -synctex=1 -shell-escape -interaction nonstopmode -output-directory='%s'\" -pdf -pvc -bibtex -f %s.tex"
(file-name-directory buffer-file-name)
(file-name-base buffer-file-name))))
(defun tdh-latex/watch/kill ()
"Kill the currently running TeX job."
(interactive)
(delete-process "latexmk-watch")
)
(after! org
(map! :map org-mode-map
:n ",ow" 'tdh-latex/watch
:n ",ok" 'tdh-latex/watch/kill))
#+end_src
*** Helm-Bibtex
#+begin_src emacs-lisp
(after! org
(map! :map org-mode-map
:n ",ob" 'helm-bibtex
:n ",of" 'helm-bibtex-favorites
:n ",or" 'helm-resume))
#+end_src
*** Open terminal in current directory
#+begin_src emacs-lisp
(defun tdh-open-terminal-in-workdir ()
(interactive)
(call-process-shell-command
(concat "termite --directory=" default-directory) nil 0))
(after! org
(map! :map org-mode-map :n ",ot" 'tdh-open-terminal-in-workdir))
#+end_src
*** Open ranger in current directory
#+begin_src emacs-lisp
(defun tdh-open-ranger-in-workdir ()
(interactive)
(call-process-shell-command
(concat "termite --directory=" default-directory " --exec=ranger") nil 0))
(after! org
(map! :map org-mode-map :n ",oo" 'tdh-open-ranger-in-workdir))
#+end_src
*** Export to LaTeX
#+begin_src emacs-lisp
(after! org
(map! :map org-mode-map :n ",l" 'org-latex-export-to-latex))
#+end_src
*** Open pdf externally.
#+begin_src emacs-lisp
(defun tdh-open-org-pdf-externally ()
(interactive)
(call-process "zathura" nil 0 nil (concat (file-name-sans-extension (buffer-file-name)) ".pdf"))
)
(after! org
(map! :map org-mode-map :n ",vp" 'tdh-open-org-pdf-externally))
#+end_src
*** Open HTML externally.
#+begin_src emacs-lisp
(defun tdh-open-org-html-externally ()
(interactive)
(call-process "xdg-open" nil 0 nil (concat (file-name-sans-extension (buffer-file-name)) ".html"))
)
(after! org
(map! :map org-mode-map :n ",vh" 'tdh-open-org-html-externally))
#+end_src
*** Take Screenshot and insert a link
- Ask for a name =screenshot_name=
- use =maim -s figs/screenshot_name.png= to take a screenshot with selection
- Then insert the following to the buffer
#+begin_src text :tangle no
#+name: sreenshot_name
[[file:figs/screenshot_name.png]]
#+end_src
Then it would be nice to automatically prefix the =CUSTOM_ID= property (until the first =_=).
#+begin_src emacs-lisp
(defun tdh-insert-screenshot-org-link ()
"Capture screenshot and insert the resulting file.
The screenshot tool is determined by `org-download-screenshot-method'."
(interactive)
(setq filename (concat "./figs/" (read-string "Enter file name:") ".png"))
(shell-command (concat "maim -s " filename))
(insert (format "[[file:%s]]" filename))
)
(after! org
(map! :map org-mode-map :n ",is" 'tdh-insert-screenshot-org-link))
#+end_src
** Automatically run =startblock= when opening org-mode files
#+begin_src emacs-lisp
(after! org
@ -1895,6 +1657,159 @@ https://www.reddit.com/r/emacs/comments/d3a8or/pretty_org_tables_in_the_buffer_c
)
#+end_src
** Custom Keybindings - =,= leader key
*** Insert Elements =,i=
Insert Link to paper
#+begin_src emacs-lisp
(defun tdh-insert-paper-org-link (paper)
"Insert an org link to some paper, choosing the file with completion"
(interactive
(list (read-file-name "Paper: " "~/Cloud/thesis/ressources/pdfs/" nil t)))
(insert (format "[[papers:%s]]" (file-name-base paper))))
#+end_src
Insert Link to notes
#+begin_src emacs-lisp
(defun tdh-insert-note-org-link (note)
"Insert an org link to some note, choosing the file with completion"
(interactive
(list (read-file-name "Note: " "~/Cloud/thesis/ressources/pdfs/" nil t)))
(insert (format "[[notes:%s]]" (file-name-base note))))
#+end_src
Insert Image that is in the figs folder
#+begin_src emacs-lisp
(defun tdh-insert-image-org-link (img)
"Insert an org image link, choosing the file with completion
and starting from `my-default-image-directory'."
(interactive
(list (file-relative-name (read-file-name "Image: " (concat default-directory "figs/")) default-directory)))
(insert (format "[[file:%s]]" img)))
#+end_src
Take Screenshot and insert a link:
- Ask for a name =screenshot_name=
- use =maim -s figs/screenshot_name.png= to take a screenshot with selection
- Then insert the following to the buffer
#+begin_src emacs-lisp
(defun tdh-insert-screenshot-org-link ()
"Capture screenshot and insert the resulting file.
The screenshot tool is determined by `org-download-screenshot-method'."
(interactive)
(setq filename (concat "./figs/" (read-string "Enter file name:") ".png"))
(shell-command (concat "maim -s " filename))
(insert (format "[[file:%s]]" filename))
)
#+end_src
Map Keys
#+begin_src emacs-lisp
(after! org
(map! :map org-mode-map
(:prefix (",i" . "Insert")
:n "p" 'tdh-insert-paper-org-link
:n "n" 'tdh-insert-note-org-link
:n "f" 'tdh-insert-image-org-link
:n "s" 'tdh-insert-screenshot-org-link)))
#+end_src
*** LaTeX =,l=
#+begin_src emacs-lisp
(defun tdh-latex-watch ()
"Watch LaTeX file using latexmk"
(interactive)
(start-process-shell-command "latexmk-watch" "*latexmk-watch-output*"
"latexmk" (format "-pdflatex=\"xelatex -synctex=1 -shell-escape -interaction nonstopmode -output-directory='%s'\" -pdf -pvc -bibtex -f %s.tex"
(file-name-directory buffer-file-name)
(file-name-base buffer-file-name))))
#+end_src
#+begin_src emacs-lisp
(defun tdh-latex-watch-kill ()
"Kill the currently running TeX job."
(interactive)
(delete-process "latexmk-watch")
)
#+end_src
#+begin_src emacs-lisp
(after! org
(map! :map org-mode-map
(:prefix (",l" . "LaTeX")
:n "w" 'tdh-latex-watch
:n "k" 'tdh-latex-watch-kill
:n "l" 'org-latex-export-to-latex)))
#+end_src
*** Org LaTeX Automatic fragment
#+begin_src emacs-lisp
(defun tdh-automatic-latex-fragment-activate ()
(interactive)
(add-hook 'org-mode-hook 'org-fragtog-mode))
(defun tdh-automatic-latex-fragment-deactivate ()
(interactive)
(remove-hook 'org-mode-hook 'org-fragtog-mode))
#+end_src
#+begin_src emacs-lisp
(after! org
(map! :map org-mode-map
(:prefix (",l" . "LaTeX")
:n "f" 'tdh-automatic-latex-fragment-activate
:n "F" 'tdh-automatic-latex-fragment-deactivate)))
#+end_src
*** Bibtex =,n=
#+begin_src emacs-lisp
(after! org
(map! :map org-mode-map
(:prefix (",b" . "BibTeX")
:n "b" 'helm-bibtex
:n "f" 'helm-bibtex-favorites
:n "r" 'helm-resume)))
#+end_src
*** Open ranger in current directory =,o=
#+begin_src emacs-lisp
(defun tdh-open-ranger-in-workdir ()
(interactive)
(call-process-shell-command
(concat "termite --directory=" default-directory " --exec=ranger") nil 0))
#+end_src
#+begin_src emacs-lisp
(after! org
(map! :map org-mode-map
:n ",o" 'tdh-open-ranger-in-workdir))
#+end_src
*** View in External programs =,v=
Open PDF output with =zathura=
#+begin_src emacs-lisp
(defun tdh-open-org-pdf-externally ()
(interactive)
(call-process "zathura" nil 0 nil (concat (file-name-sans-extension (buffer-file-name)) ".pdf"))
)
#+end_src
Open HTML output externally
#+begin_src emacs-lisp
(defun tdh-open-org-html-externally ()
(interactive)
(call-process "xdg-open" nil 0 nil (concat (file-name-sans-extension (buffer-file-name)) ".html"))
)
#+end_src
#+begin_src emacs-lisp
(after! org
(map! :map org-mode-map
(:prefix (",v" . "View")
:n "p" 'tdh-open-org-pdf-externally
:n "h" 'tdh-open-org-html-externally)))
#+end_src
* Org Babel
** Main configuration
Don't ask for confirmation when evaluating following blocs
@ -1943,6 +1858,15 @@ If required, it is possible to set custom colors for different source blocks
;; )
#+end_src
** Indentation
#+begin_src emacs-lisp
(after! org
(setq org-edit-src-content-indentation 2
org-src-tab-acts-natively nil
org-src-preserve-indentation nil)
)
#+end_src
** Library of Babel
Add all named source blocks to =org-babel-library-of-babel=.
@ -1952,6 +1876,113 @@ Add all named source blocks to =org-babel-library-of-babel=.
#+end_src
** Org-Babel Matlab
#+begin_src emacs-lisp
(after! org
(setq org-babel-matlab-shell-command "/home/thomas/bin/matlab -nodesktop -nosplash")
(setq org-babel-matlab-emacs-link-wrapper-method
"%s
if ischar(ans);
echo('test');
fid = fopen('%s', 'w');
fprintf(fid, '%s', ans);
fclose(fid);
else;
save -ascii %s ans;
end
delete('%s');
")
)
#+end_src
Default options for Matlab code
#+begin_src emacs-lisp
(after! org
(setq org-babel-default-header-args:matlab
'((:results . "none")
(:session . "*MATLAB*")
(:comments . "org")
(:exports . "both")
(:cache . "no")
(:noweb . "no")
(:hlines . "no")
(:tangle . "no")
(:mkdir . "yes")
(:eval . "no-export")))
)
#+end_src
** Some functions for using Matlab with Org Babel =,m=
=whos= matlab function
#+begin_src emacs-lisp
(defun tdh-matlab-whos (&optional start end)
"Get what is in the Matlab workspace"
(interactive)
(if (use-region-p)
(let ((regionp (buffer-substring (region-beginning) (region-end))))
(process-send-string "*MATLAB*" (concat "whosEmacs " regionp "\n")))
(process-send-string "*MATLAB*" (concat "whosEmacs" "\n"))))
#+end_src
=help= matlab function
#+begin_src emacs-lisp
(defun tdh-matlab-help (&optional start end)
"Get help on the selected function"
(interactive)
(if (use-region-p)
(let ((regionp (buffer-substring (region-beginning) (region-end))))
(process-send-string "*MATLAB*" (concat "help " regionp "\n")))
(process-send-string "*MATLAB*" (concat "help " (read-string "Matlab help:") "\n")))
)
#+end_src
Specify a Matlab command to run
#+begin_src emacs-lisp
(defun tdh-matlab-run-command ()
"Prompt user to enter a matlab command"
(interactive)
(process-send-string "*MATLAB*" (concat (read-string "Matlab Command: ") "\n")))
#+end_src
Specify a Matlab command to run and show output in mini-buffer
#+begin_src emacs-lisp
(defun tdh-matlab-run-command-show-output ()
"Prompt user to enter a matlab command"
(interactive)
(process-send-string "*MATLAB*" (concat "evalEmacs('" (read-string "Matlab Command: ") "')\n")))
#+end_src
Org-Babel Tangle File and Execute with Matlab
#+begin_src emacs-lisp
(defun tdh-matlab-tangle-and-execute ()
"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)
(process-send-string "*MATLAB*" (concat "run " file "\n"))
(error "Cannot open tangle file %S" file)))))
#+end_src
Map Functions
#+begin_src emacs-lisp
(after! org
(map! :map org-mode-map
(:prefix (",m" . "Matlab")
:n "e" 'tdh-matlab-run-command
:n "E" 'tdh-matlab-run-command-show-output
:n "T" 'tdh-matlab-tangle-and-execute
:nv "h" 'tdh-matlab-help
:nv "w" 'tdh-matlab-whos)))
#+end_src
** Remap =ctrl-ret= used to execute the src block and go to the next one
https://emacs.stackexchange.com/questions/13869/how-to-toggle-org-mode-source-code-block-eval-no-status
@ -1979,6 +2010,7 @@ when inside a source block. Otherwise, keep the normal behavior for =ctrl-ret=.
#+end_src
** Remap =ctrl-shift-ret= used to execute the (matlab) src block in the background and go to the next one
*** =tdh-org-babel-execute-matlab-background=
#+begin_src emacs-lisp
(defun tdh-org-babel-execute-matlab-background (&optional arg info params)
(interactive)
@ -2041,6 +2073,16 @@ when inside a source block. Otherwise, keep the normal behavior for =ctrl-ret=.
)
#+end_src
*** =tdh-matlab-execute-selected=
#+begin_src emacs-lisp
(defun tdh-matlab-execute-selected (start end)
"Execute selected text in the *MATLAB* buffer"
(interactive "r")
(let ((regionp (buffer-substring start end)))
(process-send-string "*MATLAB*" (concat regionp "\n"))))
#+end_src
*** Remap =ctrl-shift-ref=
This function:
- first check if inside a source block, if not does nothing
- when check if the language is =matlab=
@ -2049,7 +2091,7 @@ This function:
if no region is selected, it runs all the code blocks and goes to the next block
#+begin_src emacs-lisp
(defun tdh-ctrl-shit-ret ()
(defun tdh-ctrl-shift-ret ()
(interactive)
(defun in-src-block-p ()
"Returns t when the point is inside a source code block"
@ -2071,103 +2113,11 @@ This function:
#+begin_src emacs-lisp
(map! :after evil-org
:map evil-org-mode-map
:n "<C-S-return>" #'tdh-ctrl-shit-ret)
:n "<C-S-return>" #'tdh-ctrl-shift-ret)
#+end_src
** Org-Babel Matlab
#+begin_src emacs-lisp
(after! org
(setq org-babel-matlab-shell-command "/home/thomas/bin/matlab -nodesktop -nosplash")
(setq org-babel-matlab-emacs-link-wrapper-method
"%s
if ischar(ans);
echo('test');
fid = fopen('%s', 'w');
fprintf(fid, '%s', ans);
fclose(fid);
else;
save -ascii %s ans;
end
delete('%s');
")
)
#+end_src
** Default options for Matlab code
#+begin_src emacs-lisp
(after! org
(setq org-babel-default-header-args:matlab
'((:results . "none")
(:session . "*MATLAB*")
(:comments . "org")
(:exports . "both")
(:cache . "no")
(:noweb . "no")
(:hlines . "no")
(:tangle . "no")
(:mkdir . "yes")
(:eval . "no-export")))
)
#+end_src
** Indentation
#+begin_src emacs-lisp
(after! org
(setq org-edit-src-content-indentation 2
org-src-tab-acts-natively nil
org-src-preserve-indentation nil)
)
#+end_src
** Some functions for using Matlab with Org Babel
*** =whos= matlab function
#+begin_src emacs-lisp
(defun tdh-matlab-whos (&optional start end)
"Get what is in the Matlab workspace"
(interactive)
(if (use-region-p)
(let ((regionp (buffer-substring (region-beginning) (region-end))))
(process-send-string "*MATLAB*" (concat "whosEmacs " regionp "\n")))
(process-send-string "*MATLAB*" (concat "whosEmacs" "\n"))))
#+end_src
*** =help= matlab function
#+begin_src emacs-lisp
(defun tdh-matlab-help (start end)
"Get help on the selected function"
(interactive "r")
(let ((regionp (buffer-substring start end)))
(process-send-string "*MATLAB*" (concat "help " regionp "\n"))))
#+end_src
*** Execute selected text
#+begin_src emacs-lisp
(defun tdh-matlab-execute-selected (start end)
"Execute selected text in the *MATLAB* buffer"
(interactive "r")
(let ((regionp (buffer-substring start end)))
(process-send-string "*MATLAB*" (concat regionp "\n"))))
#+end_src
*** Specify a Matlab command to run
#+begin_src emacs-lisp
(defun tdh-matlab-run-command ()
"Prompt user to enter a matlab command"
(interactive)
(process-send-string "*MATLAB*" (concat (read-string "Matlab Command: ") "\n")))
#+end_src
*** Specify a Matlab command to run and show output in minibuffer
#+begin_src emacs-lisp
(defun tdh-matlab-run-command-show-output ()
"Prompt user to enter a matlab command"
(interactive)
(process-send-string "*MATLAB*" (concat "evalEmacs('" (read-string "Matlab Command: ") "')\n")))
#+end_src
** Helping Functions - Tangling
*** Org-Babel Tangle Sub-tree
** Helping Functions - Tangling =,b=
Org-Babel Tangle Sub-tree
#+begin_src emacs-lisp
(defun tdh-org-babel-tangle-subtree ()
"Tangle the current subtree"
@ -2179,9 +2129,7 @@ This function:
)
#+end_src
*** Org-Babel Jump to Tangle File
Actually this tangle the file and then go to the file. Maybe I would like to ignore the tangling phase.
Org-Tangle and Org-Babel Jump to Tangle File
#+begin_src emacs-lisp
(defun tdh-org-babel-jump-to-tangle-file ()
"Jump to tangle file for the source block at point."
@ -2198,28 +2146,13 @@ Actually this tangle the file and then go to the file. Maybe I would like to ign
(error "Cannot open tangle file %S" file)))))
#+end_src
*** Org-Babel Tangle File and Execute
#+begin_src emacs-lisp
(defun tdh-org-babel-execute-tangle-file ()
"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)
(process-send-string "*MATLAB*" (concat "run " file "\n"))
(error "Cannot open tangle file %S" file)))))
#+end_src
*** Map Functions
Map Functions
#+begin_src emacs-lisp
(after! org
(map! :map org-mode-map :n ",bF" 'tdh-org-babel-jump-to-tangle-file)
(map! :map org-mode-map :n ",bT" 'tdh-org-babel-tangle-subtree))
(map! :map org-mode-map
(:prefix (",b" . "Tangle")
:n "F" 'tdh-org-babel-jump-to-tangle-file
:n "T" 'tdh-org-babel-tangle-subtree)))
#+end_src
* LaTeX
@ -2916,6 +2849,7 @@ they are implemented.
(package! org-ref)
(package! org-ql)
(package! org-fancy-priorities)
(package! org-fragtog)
#+end_src
* Snippets