Mostly change of indentation

This commit is contained in:
Thomas Dehaeze 2020-04-16 12:04:57 +02:00
parent bee11a1bec
commit 28efe7e8b6

View File

@ -595,10 +595,24 @@ Documentation:
;; Authorize BIND to set local variables
(setq org-export-allow-bind-keywords t)
;; Use doc instead of odt
(setq org-odt-preferred-output-format "doc")
)
#+end_src
*** Defaults
#+begin_src emacs-lisp
(after! org
(setq org-export-with-author t)
(setq org-export-with-creator nil)
(setq org-export-with-date t)
(setq org-export-with-toc t)
(setq org-export-with-drawers nil)
(setq org-export-with-sub-superscripts nil)
(setq org-export-with-todo-keywords nil)
)
#+end_src
*** Do not export headline with the =:ignore:= tag
#+begin_src emacs-lisp
;; Used to not export headings with :ignore: tag
@ -607,55 +621,49 @@ Documentation:
(ox-extras-activate '(ignore-headlines)))
#+end_src
*** Ox Latex Subfigure package
#+begin_src emacs-lisp
(use-package! ox-latex-subfigure
:after org
:config (require 'ox-latex-subfigure))
#+end_src
*** Clear page before heading
https://emacs.stackexchange.com/questions/30575/adding-latex-newpage-before-a-heading/30892
** HTML Export
*** HTML Defaults
#+begin_src emacs-lisp
(after! org
(defun org/get-headline-string-element (headline backend info)
(let ((prop-point (next-property-change 0 headline)))
(if prop-point (plist-get (text-properties-at prop-point headline) :parent))))
;; (setq org-html-head-extra (concat
;; "<link rel='stylesheet' href='../css/htmlize.css'>\n"
;; "<link rel='stylesheet' href='../css/readtheorg.css'>\n"
;; "<link rel='stylesheet' href='../css/zenburn.css'>\n"
;; "<link rel='text/javascript' href='../js/bootstrap.min.js'>\n"
;; "<link rel='text/javascript' href='../js/jquery.min.js'>\n"
;; "<link rel='text/javascript' href='../js/jquery.stickytableheaders.min.js'>\n"
;; "<link rel='text/javascript' href='../js/readtheorg.js'>\n"))
(defun org/ensure-latex-clearpage (headline backend info)
(when (org-export-derived-backend-p backend 'latex)
(let ((elmnt (org/get-headline-string-element headline backend info)))
(when (and elmnt (org-element-property :CLEARPAGE elmnt))
(concat "\\clearpage\n" headline)))))
;; cleans up anything that would have been in there.
(setq org-html-head nil)
(setq org-html-head-include-default-style nil)
(setq org-html-head-include-scripts nil)
(add-to-list 'org-export-filter-headline-functions
'org/ensure-latex-clearpage)
(setq org-html-viewport nil)
(setq org-html-html5-fancy t)
(setq org-html-doctype "xhtml-strict")
(setq org-html-wrap-src-lines nil)
;; Export with css class instead of inline css
(setq org-html-htmlize-output-type 'css)
)
#+end_src
*** HTML Export
**** MathJax
*** MathJax
#+begin_src emacs-lisp
(after! org
(setq org-html-mathjax-template
"<script>
MathJax = {
"<script>MathJax = {
tex: {
tags: 'ams',
macros: {
bm: [\"\\\\boldsymbol{#1}\",1],
}
macros: {bm: [\"\\\\boldsymbol{#1}\",1],}
}
};
</script>
<script type=\"text/javascript\"
src=\"%PATH\"></script>")
)
#+end_src
<script type=\"text/javascript\" src=\"%PATH\"></script>")
#+begin_src emacs-lisp
(after! org
(setq org-html-mathjax-options
'((path "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js")
(scale "100")
@ -670,37 +678,23 @@ https://emacs.stackexchange.com/questions/30575/adding-latex-newpage-before-a-he
)
#+end_src
**** Export with css class instead of inline css
#+begin_src emacs-lisp
(after! org
(setq org-html-htmlize-output-type 'css))
#+end_src
**** TODO MP4 movies
#+begin_src emacs-lisp :tangle no
(after! org
(setq org-html-html5-fancy t)
(setq org-html-doctype "xhtml-strict")
)
#+end_src
**** TODO Ensuring useful HTML Anchors
*** TODO Ensuring useful HTML Anchors
- [ ] https://github.com/alhassy/emacs.d
- [ ] https://github.com/alphapapa/unpackaged.el#export-to-html-with-useful-anchors
This is not working
#+begin_src emacs-lisp :tangle no
(define-minor-mode unpackaged/org-export-html-with-useful-ids-mode
(define-minor-mode unpackaged/org-export-html-with-useful-ids-mode
"Attempt to export Org as HTML with useful link IDs.
Instead of random IDs like \"#orga1b2c3\", use heading titles,
made unique when necessary."
Instead of random IDs like \"#orga1b2c3\", use heading titles,
made unique when necessary."
:global t
(if unpackaged/org-export-html-with-useful-ids-mode
(advice-add #'org-export-get-reference :override #'unpackaged/org-export-get-reference)
(advice-remove #'org-export-get-reference #'unpackaged/org-export-get-reference)))
(defun unpackaged/org-export-get-reference (datum info)
(defun unpackaged/org-export-get-reference (datum info)
"Like `org-export-get-reference', except uses heading titles instead of random numbers."
(let ((cache (plist-get info :internal-references)))
(or (car (rassq datum cache))
@ -745,7 +739,7 @@ made unique when necessary."
(plist-put info :internal-references cache)
reference-string))))
(defun unpackaged/org-export-new-title-reference (datum cache)
(defun unpackaged/org-export-new-title-reference (datum cache)
"Return new reference for DATUM that is unique in CACHE."
(cl-macrolet ((inc-suffixf (place)
`(progn
@ -778,28 +772,28 @@ made unique when necessary."
ref)))
#+end_src
**** TODO Folded Drawers
*** TODO Folded Drawers
Adapt this from https://github.com/alhassy/emacs.d to do something similar for source blocks.
#+begin_src emacs-lisp :tangle no
(defun my/org-drawer-format (name contents)
(defun my/org-drawer-format (name contents)
"Export to HTML the drawers named with prefix fold_, ignoring case.
The resulting drawer is a code-details and so appears folded;
the user clicks it to see the information therein.
Henceforth, these are called fold drawers.
The resulting drawer is a code-details and so appears folded;
the user clicks it to see the information therein.
Henceforth, these are called fold drawers.
Drawers without such a prefix may be nonetheless exported if their
body contains :export: t ---this switch does not appear in the output.
Thus, we are biased to generally not exporting non-fold drawers.
Drawers without such a prefix may be nonetheless exported if their
body contains :export: t ---this switch does not appear in the output.
Thus, we are biased to generally not exporting non-fold drawers.
One may suspend export of fold drawers by having :export: nil
in their body definition.
One may suspend export of fold drawers by having :export: nil
in their body definition.
Fold drawers naturally come with a title.
Either it is specfied in the drawer body by :title: ⋯’,
or otherwise the drawer's name is used with all underscores replaced
by spaces.
"
Fold drawers naturally come with a title.
Either it is specfied in the drawer body by :title: ⋯’,
or otherwise the drawer's name is used with all underscores replaced
by spaces.
"
(let* ((contents (replace-regexp-in-string ":export:.*\n?" "" contents))
(fold? (s-prefix? "fold_" name 'ignore-case))
(export? (string-match ":export:\s+t" contents))
@ -821,7 +815,7 @@ by spaces.
<font face=\"Courier\" size=\"3\" color=\"green\"> %s
</font> </strong> </summary> %s </details>" title))))))
(setq org-html-format-drawer-function 'my/org-drawer-format)
(setq org-html-format-drawer-function 'my/org-drawer-format)
#+end_src
** Org LaTeX
@ -829,7 +823,7 @@ by spaces.
#+begin_src emacs-lisp
(after! org
;; Highligh latex parts in org mode
(setq org-highlight-latex-and-related '(native))
(setq org-highlight-latex-and-related '(latex script entities))
;; Use F9 to globally generate all the latex fragments
(map! :map org-mode-map
@ -943,10 +937,36 @@ by spaces.
)
#+end_src
*** Ox Latex Subfigure package
#+begin_src emacs-lisp
(use-package! ox-latex-subfigure
:after org
:config (require 'ox-latex-subfigure))
#+end_src
*** Clear page before heading
https://emacs.stackexchange.com/questions/30575/adding-latex-newpage-before-a-heading/30892
#+begin_src emacs-lisp
(after! org
(defun org/get-headline-string-element (headline backend info)
(let ((prop-point (next-property-change 0 headline)))
(if prop-point (plist-get (text-properties-at prop-point headline) :parent))))
(defun org/ensure-latex-clearpage (headline backend info)
(when (org-export-derived-backend-p backend 'latex)
(let ((elmnt (org/get-headline-string-element headline backend info)))
(when (and elmnt (org-element-property :CLEARPAGE elmnt))
(concat "\\clearpage\n" headline)))))
(add-to-list 'org-export-filter-headline-functions
'org/ensure-latex-clearpage)
)
#+end_src
*** Default added packages
#+begin_src emacs-lisp
(after! org
;; Add packages by default
(add-to-list 'org-latex-packages-alist '("" "siunitx" t))
(add-to-list 'org-latex-packages-alist '("" "array" t))
(add-to-list 'org-latex-packages-alist '("" "tabularx" t))
@ -1150,165 +1170,6 @@ https://www.reddit.com/r/orgmode/comments/7u2n0h/tip_for_defining_latex_macros_f
#+end_src
** TODO View PDF in org mode
#+begin_src emacs-lisp :tangle no
(defun tdh-org-include-img-from-pdf (&rest _)
"Convert pdf files to image files in org-mode bracket links.
# ()convertfrompdf:t # This is a special comment; tells that the upcoming
# link points to the to-be-converted-to file.
# If you have a foo.pdf that you need to convert to foo.png, use the
# foo.png file name in the link.
[[./foo.png]]
"
(interactive)
(if (executable-find "convert")
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^[ \t]*#\\s-+()convertfrompdf\\s-*:\\s-*t"
nil :noerror)
;; Keep on going to the next line till it finds a line with bracketed
;; file link.
(while (progn
(forward-line 1)
(not (looking-at org-bracket-link-regexp))))
;; Get the sub-group 1 match, the link, from `org-bracket-link-regexp'
(let ((link (match-string-no-properties 1)))
(when (stringp link)
(let* ((imgfile (expand-file-name (file-name-sans-extension link)))
(pdffile (expand-file-name
(concat imgfile
"." "pdf")))
(cmd (concat "pdftocairo -png -transp -singlefile "
pdffile " " imgfile)))
(message "%s" imgfile)
(when (and (file-readable-p pdffile)
(file-newer-than-file-p pdffile imgfile))
;; This block is executed only if pdffile is newer than
;; imgfile or if imgfile does not exist.
(shell-command cmd)
(message "%s" cmd)))))))
(user-error "`convert' executable (part of Imagemagick) is not found")))
(add-hook 'org-export-before-processing-hook #'tdh-org-include-img-from-pdf)
#+end_src
#+begin_src emacs-lisp :tangle no
(add-to-list 'image-type-file-name-regexps '("\\.pdf\\'" . imagemagick))
(add-to-list 'image-file-name-extensions "pdf")
(setq imagemagick-types-inhibit (remove 'PDF imagemagick-types-inhibit))
#+end_src
#+begin_src emacs-lisp :tangle no
(defun tdh-latex-filter-nobreaks (text backend info)
"Ensure \" \" are properly handled in LaTeX export."
(when (org-export-derived-backend-p backend 'latex)
(replace-regexp-in-string " " "~" text)))
(add-to-list 'org-export-filter-plain-text-functions
'tdh-latex-filter-nobreaks)
#+end_src
#+begin_src emacs-lisp :tangle no
(setq image-file-name-extensions
(quote
("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm" "xpm" "pbm" "pgm" "ppm" "pnm" "svg" "pdf" "bmp")))
(setq org-imagemagick-display-command "convert -density 600 \"%s\" -thumbnail \"%sx%s>\" \"%s\"")
(defun org-display-inline-images (&optional include-linked refresh beg end)
"Display inline images.
Normally only links without a description part are inlined, because this
is how it will work for export. When INCLUDE-LINKED is set, also links
with a description part will be inlined. This
can be nice for a quick
look at those images, but it does not reflect what exported files will look
like.
When REFRESH is set, refresh existing images between BEG and END.
This will create new image displays only if necessary.
BEG and END default to the buffer boundaries."
(interactive "P")
(unless refresh
(org-remove-inline-images)
(if (fboundp 'clear-image-cache) (clear-image-cache)))
(save-excursion
(save-restriction
(widen)
(setq beg (or beg (point-min)) end (or end (point-max)))
(goto-char beg)
(let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([^]\n]+?"
(substring (org-image-file-name-regexp) 0 -2)
"\\)\\]" (if include-linked "" "\\]")))
old file ov img)
(while (re-search-forward re end t)
(setq old (get-char-property-and-overlay (match-beginning 1)
'org-image-overlay)
file (expand-file-name
(concat (or (match-string 3) "") (match-string 4))))
(when (file-exists-p file)
(let ((file-thumb (format "%s%s_thumb.png" (file-name-directory file) (file-name-base file))))
(if (file-exists-p file-thumb)
(let ((thumb-time (nth 5 (file-attributes file-thumb 'string)))
(file-time (nth 5 (file-attributes file 'string))))
(if (time-less-p thumb-time file-time)
(shell-command (format org-imagemagick-display-command
file org-image-actual-width org-image-actual-width file-thumb) nil nil)))
(shell-command (format org-imagemagick-display-command
file org-image-actual-width org-image-actual-width file-thumb) nil nil))
(if (and (car-safe old) refresh)
(image-refresh (overlay-get (cdr old) 'display))
(setq img (save-match-data (create-image file-thumb)))
(when img
(setq ov (make-overlay (match-beginning 0) (match-end 0)))
(overlay-put ov 'display img)
(overlay-put ov 'face 'default)
(overlay-put ov 'org-image-overlay t)
(overlay-put ov 'modification-hooks
(list 'org-display-inline-remove-overlay))
(push ov org-inline-image-overlays))))))))))
#+end_src
Two options:
- work with =.png= file extension and only replace with =.pdf= when exporting to LaTeX if the corresponding file exists
- work with =.pdf= file, add a special function to display =.pdf= files (using =convert= or =pdftocairo=). Change to =.png= when exporting to html
Let's try the first solution.
#+begin_src emacs-lisp :tangle no
(defun tdh-change-png-to-pdf (text backend info)
"Change png images to pdf images when existing"
(when (org-export-derived-backend-p backend 'latex)
(let ((text (replace-regexp-in-string "[^\\w]\\(:\\)[^\n\t\r]+\\(:\\)[^\\w]" "<mark>" text nil nil 1 nil)))
(replace-regexp-in-string "[^\\w]\\(<mark>\\)[^\n\t\r]+\\(:\\)[^\\w]" "</mark>" text nil nil 2 nil))))
(add-to-list 'org-export-filter-plain-text-fucntions 'tdh-html-mark-tag)
#+end_src
#+begin_src emacs-lisp :tangle no
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^[ \t]*#\\s-+()convertfrompdf\\s-*:\\s-*t"
nil :noerror)
;; Keep on going to the next line till it finds a line with bracketed
;; file link.
(while (progn
(forward-line 1)
(not (looking-at org-bracket-link-regexp))))
;; Get the sub-group 1 match, the link, from `org-bracket-link-regexp'
(let ((link (match-string-no-properties 1)))
(when (stringp link)
(let* ((imgfile (expand-file-name link))
(pdffile (expand-file-name
(concat (file-name-sans-extension imgfile)
"." "pdf")))
(cmd (concat "convert -density 96 -quality 85 "
pdffile " " imgfile)))
(when (and (file-readable-p pdffile)
(file-newer-than-file-p pdffile imgfile))
;; This block is executed only if pdffile is newer than
;; imgfile or if imgfile does not exist.
(shell-command cmd)
(message "%s" cmd)))))))
#+end_src
** Org Ref
Ressources:
- https://github.com/tmalsburg/helm-bibtex
@ -1430,8 +1291,8 @@ Nice Functions:
)
#+end_src
** Org Projects
#+begin_src emacs-lisp
** TODO Org Projects
#+begin_src emacs-lisp :tangle no
(setq org-publish-project-alist
'(("config"
:base-directory "~/.config/literate-dotfiles/dotfiles/"
@ -1465,7 +1326,7 @@ Nice Functions:
:recursive nil
:publishing-function org-html-publish-to-html
:auto-preamble t
:auto-sitemap nil
:auto-sitemap t
:html-link-up "index.html"
:html-link-home "index.html"
:with-todo-keywords nil
@ -1503,6 +1364,33 @@ Nice Functions:
:table-of-contents nil)))
#+end_src
** TODO Org big org-project
#+begin_src emacs-lisp
(setq org-publish-project-alist
'(("website"
:components ("nass-simscape" "nass-simscape-images"))
("nass-simscape"
:base-directory "~/Cloud/thesis/matlab/nass-simscape/org/"
:base-extension "org"
:publishing-directory "~/Cloud/website/nass-simscape/"
:publishing-function org-html-publish-to-html
:html-link-up "./index.html"
:html-link-home "~/Cloud/website/index.html"
:html-footnotes-section "<div id='footnotes'><!--%s-->%s</div>"
:recursive nil
:auto-sitemap nil
:language en)
("nass-simscape-images"
:base-directory "~/Cloud/thesis/matlab/nass-simscape/docs/figs/"
:base-extension "png"
:publishing-directory "~/Cloud/website/nass-simscape/figs/"
:publishing-function org-publish-attachment)
))
#+end_src
** Automatically run =startblock= when opening org-mode files
#+begin_src emacs-lisp
(after! org
@ -1581,7 +1469,7 @@ http://pragmaticemacs.com/emacs/a-workflow-to-quickly-add-photos-to-org-mode-not
(org-display-inline-images t t)))
#+end_src
** TODO Render Tables
** Render Tables
https://www.reddit.com/r/emacs/comments/d3a8or/pretty_org_tables_in_the_buffer_chapter_2_it/
#+begin_src emacs-lisp
@ -1639,11 +1527,6 @@ https://www.reddit.com/r/emacs/comments/d3a8or/pretty_org_tables_in_the_buffer_c
)
#+end_src
** Org Download
#+begin_src emacs-lisp
#+end_src
** Org Gcal
- https://cestlaz.github.io/posts/using-emacs-26-gcal/#.WIqBud9vGAk
@ -1746,6 +1629,16 @@ Take Screenshot and insert a link:
)
#+end_src
Insert link to next figure:
#+begin_src emacs-lisp
(defun tdh-insert-link-to-next-figure ()
(interactive)
(save-excursion
(re-search-forward "^#\\+name:\s*\\(fig:.*\\)" nil t 1))
(insert (concat "[[" (match-string 1) "]]"))
)
#+end_src
Map Keys
#+begin_src emacs-lisp
(after! org
@ -1756,6 +1649,7 @@ Map Keys
:n "f" 'tdh-insert-image-org-link
:n "F" 'tdh-insert-image-org-link-sxiv
:n "i" 'tdh-insert-phone-picture
:n "l" 'tdh-insert-link-to-next-figure
:n "s" 'tdh-insert-screenshot-org-link)))
#+end_src
@ -1806,11 +1700,11 @@ Map Keys
:n "F" 'tdh-automatic-latex-fragment-deactivate)))
#+end_src
*** Bibtex =,n=
*** Bibtex =,r=
#+begin_src emacs-lisp
(after! org
(map! :map org-mode-map
(:prefix (",b" . "BibTeX")
(:prefix (",r" . "References")
:n "b" 'helm-bibtex
:n "f" 'helm-bibtex-favorites
:n "r" 'helm-resume)))
@ -1886,23 +1780,6 @@ Use the current window for C-c ' source editing
(add-hook 'org-mode-hook #'tdh-org-prettify-symbols)
#+end_src
#+begin_src emacs-lisp
(after! org
(set-face-attribute 'org-block nil :background (face-background 'fringe))
(set-face-attribute 'org-block-begin-line nil :background (face-background 'fringe))
(set-face-attribute 'org-block-end-line nil :background (face-background 'fringe))
)
#+end_src
If required, it is possible to set custom colors for different source blocks
#+begin_src emacs-lisp
;; (after! org
;; (setq org-src-block-faces
;; '(("emacs-lisp" (:background (face-background 'org-block)))
;; ("matlab" (:background (face-background 'fringe)))))
;; )
#+end_src
** Indentation
#+begin_src emacs-lisp
(after! org
@ -1952,7 +1829,7 @@ Default options for Matlab code
(:cache . "no")
(:noweb . "no")
(:hlines . "no")
(:tangle . "no")
(:tangle . "yes")
(:mkdir . "yes")
(:eval . "no-export")))
)
@ -2015,7 +1892,6 @@ Org-Babel Tangle File and Execute with Matlab
(error "Cannot open tangle file %S" file)))))
#+end_src
Map Functions
#+begin_src emacs-lisp
(after! org
@ -2226,7 +2102,12 @@ Map Functions
- https://tex.stackexchange.com/questions/52179/what-is-your-favorite-emacs-and-or-auctex-command-trick
- https://tex.stackexchange.com/questions/20843/useful-shortcuts-or-key-bindings-or-predefined-commands-for-emacsauctex
** Basic LaTeX configuration
** Master file
#+begin_src emacs-lisp
(setq-default TeX-master nil)
#+end_src
** Clean Output Files
#+begin_src emacs-lisp
(defun latex/clean ()
"Clean LaTeX output using latexmk"
@ -2238,23 +2119,12 @@ Map Functions
" &"
))
(map! :map LaTeX-mode-map :n ",C" 'latex/clean)
(map! :map LaTeX-mode-map
:n ",C" 'latex/clean)
(add-hook 'TeX-mode-hook #'TeX-fold-mode)
#+end_src
** Face Attributes
#+begin_src emacs-lisp
(with-eval-after-load 'font-latex
(set-face-attribute 'font-latex-math-face nil :foreground (face-foreground 'org-meta-line))
)
#+end_src
** Master file
#+begin_src emacs-lisp
(setq-default TeX-master nil)
#+end_src
** PDF Viewer
#+begin_src emacs-lisp
(setq TeX-view-program-selection '((output-pdf "Zathura")))
@ -2374,7 +2244,6 @@ Map Functions
** Open pdf externally
#+begin_src emacs-lisp
;; Action to open the pdf with Zathura
(defun tdehaeze/open-pdf-externally (key)
(call-process "zathura" nil 0 nil (nth 0 (-cons-to-list (bibtex-completion-find-pdf key)))))
#+end_src
@ -2389,7 +2258,7 @@ Map Functions
** List all element of the bibliography without pdf associated
#+begin_src emacs-lisp
(defun list-bib-without-pdf-associated ()
(defun tdh-list-bib-without-pdf-associated ()
(interactive)
(bibtex-completion-init)
(setq candidates (bibtex-completion-candidates))
@ -2409,9 +2278,8 @@ Map Functions
)
#+end_src
* TODO Matlab
- https://github.com/yuhonglin/matlab-mode
- https://github.com/pronobis/matlab-mode
* Matlab
- https://sourceforge.net/projects/matlab-emacs/
** Setup Matlab Mode
#+begin_src emacs-lisp
@ -2420,7 +2288,7 @@ Map Functions
(setq mlint-programs '("mlint" "/home/thomas/.local/bin/mlint"))
#+end_src
** Setup Flycheck
** Setup Flycheck to work with =mlint=
#+begin_src emacs-lisp
(defvar mlint-executable "/home/thomas/.local/bin/mlint")
@ -2437,30 +2305,25 @@ Map Functions
(add-hook 'matlab-mode-hook 'flycheck-mode)
#+end_src
#+begin_src emacs-lisp :tangle no
(defadvice org-edit-src-code (around set-buffer-file-name activate compile)
(let ((file-name (buffer-file-name))) ;; (1)
ad-do-it ;; (2)
(setq buffer-file-name file-name))) ;; (3)
#+end_src
** TODO Setup Company - not working
#+begin_src emacs-lisp
;; (add-to-list 'company-backends 'company-matlab)
#+end_src
** Completion in the Matlab Shell
#+begin_src emacs-lisp
(map! :map matlab-shell-mode-map :i "<tab>" 'matlab-shell-tab)
(map! :map matlab-shell-mode-map
:i "<tab>" 'matlab-shell-tab)
#+end_src
** TODO Beautify code
** Beautify code
#+begin_src emacs-lisp
(defun matlab-beautify-buffer ()
"Beautify Current Buffer"
(defun tdh-matlab-beautify-buffer ()
"Beautify Current Matlab Buffer"
(interactive)
;; First verifies is the current file is a Matlab file
(if (string= (file-name-extension (buffer-file-name)) "m")
(progn
(save-buffer)
(matlab-shell-run-command (concat "MBeautify.formatFile(\"" (buffer-file-name) "\")"))
(matlab-shell-run-command (concat "MBeautify.formatFileNoEditor(\"" (buffer-file-name) "\", \"" (buffer-file-name) "\")"))
(revert-buffer :ignore-auto :noconfirm))
(message "Current buffer is not a matlab file")
)
)
#+end_src
@ -2469,15 +2332,19 @@ Map Functions
(defun matlab-add-breakpoint ()
(interactive)
(matlab-shell-run-command (concat "dbstop in " (buffer-name) " at " (number-to-string (line-number-at-pos nil)))))
(defun matlab-remove-breakpoint ()
(interactive)
(matlab-shell-run-command (concat "dbclear in " (buffer-name) " at " (number-to-string (line-number-at-pos nil)))))
(defun matlab-list-breakpoints ()
(interactive)
(matlab-shell-run-command (concat "dbstatus " (buffer-name))))
(defun matlab-clear-breakpoints ()
(interactive)
(matlab-shell-run-command (concat "dbclear in " (buffer-name))))
(defun matlab-go-to-file-directory ()
(interactive)
(matlab-shell-run-command (concat "cd " (file-name-directory buffer-file-name))))
@ -2496,23 +2363,6 @@ Map Functions
:n ",dq" 'gud-finish)
#+end_src
** Wrong highlight of comments
#+begin_src emacs-lisp :tangle no
(add-hook 'matlab-mode-hook
;; `highlight-numbers-mode' breaks MATLAB comment coloring --
;; `highlight-numbers-mode' is mostly redundant with
;; `rainbow-identifiers-mode' anyway
(lambda ()
(highlight-numbers-mode -1))
;; We must append the above *after* `spacemacs/run-prog-mode-hooks'
;; in `matlab-mode-hook', since the former hook enables
;; `highlight-numbers-mode'. Note that
;; `spacemacs/run-prog-mode-hooks' is manually added to
;; `matlab-mode-hook' by Spacemacs since the upstream `matlab-mode'
;; package does not derive `matlab-mode' from `prog-mode' (oddly --
;; IIRC the author refused to do so for compatibility with XEmacs).
'append)
#+end_src
* Mu4e
** Ressources
@ -2720,77 +2570,6 @@ Choose account label to feed msmtp -a option based on From header in Message buf
(yas-global-mode 1)
#+end_src
* Proxy
#+begin_src emacs-lisp :tangle no
(setq url-proxy-services
'(("http" . "proxy.esrf.fr:3128")
("https" . "proxy.esrf.fr:3128")
("no_proxy" . "^.*esrf.fr")))
#+end_src
* TODO Neomutt connection
https://mentat.za.net/blog/2018/10/31/using-org-mode-with-neomutt/
#+begin_src emacs-lisp :tangle no
(require 'org-protocol)
;; Call this function, which spawns neomutt, whenever org-mode
;; tries to open a link of the form mutt:message-id+goes_here@mail.gmail.com
(defun tdh-mutt-open-message (message-id)
"In neomutt, open the email with the the given Message-ID"
(let*
((message-id (replace-regexp-in-string "^/*" "" message-id))
(mail-file
(replace-regexp-in-string
"\n$" "" (shell-command-to-string
(format "mu find -n 1 -f l i:%s" message-id))))
(mail-dir (replace-regexp-in-string "/\\(cur\\|new\\|tmp\\)/$" ""
(file-name-directory mail-file)))
(message-id-escaped (regexp-quote message-id))
(mutt-keystrokes
(format "L~i %s\n\n" (shell-quote-argument message-id-escaped)))
(mutt-command (list "neomutt" "-R" "-f" mail-dir
"-e" (format "push '%s'" mutt-keystrokes))))
(message "Launching neomutt for message %s" message-id)
(call-process "setsid" nil nil
"-f" "termite" "-e"
(concat "neomutt -R -f " mail-dir " -e \"" (format "push '%s a l'\"" mutt-keystrokes)))))
;; Hook up `message:...` style URLs
(org-add-link-type "message" 'tdh-mutt-open-message)
#+end_src
* Abbreviations
Type the abbreviation and use =C-x a -= to create a new abbreviation.
#+begin_src emacs-lisp
(setq-default abbrev-mode t)
;; save abbreviations upon exiting xemacs
(setq save-abbrevs t)
;; set the file storing the abbreviations
(setq abbrev-file-name "~/.config/doom/my-abbreviations.el")
;; reads the abbreviations file on startup
(quietly-read-abbrev-file)
#+end_src
* Other
Here are some additional functions/macros that could help you configure Doom:
- `load!' for loading external *.el files relative to this one
- `use-package' for configuring packages
- `after!' for running code after a package has loaded
- `add-load-path!' for adding directories to the `load-path', where Emacs
looks when you load packages with `require' or `use-package'.
- `map!' for binding new keys
To get information about any of these functions/macros, move the cursor over
the highlighted symbol at press 'K' (non-evil users must press 'C-c g k').
This will open documentation for it, including demos of how they are used.
You can also try 'gd' (or 'C-c g d') to jump to their definition and see how
they are implemented.
* Doom =init.el=
:PROPERTIES:
:header-args: :tangle ~/.config/doom/init.el
@ -2877,7 +2656,8 @@ they are implemented.
:config
literate
(default +bindings +smartparens))
(default +bindings)
)
#+end_src
* Doom =packages.el=
@ -3187,14 +2967,14 @@ $0
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
#name :Matlab-Figure
# --
#+header: :tangle no :exports results :results none :noweb yes
,#+begin_src matlab :var filepath="${2:figs}/$1.pdf" :var figsize="${3:full-tall}" :post pdf2svg(file=*this*, ext="png")
<<plt-matlab>>$0
,#+begin_src matlab :tangle no :exports results :results file replace
exportFig('figs/${1:filename}.pdf', 'width', '${2:full}', 'height', '${3:full}')
,#+end_src
#+name: fig:$1
#+caption: ${4:caption}${5: ([[./figs/$1.png][png]], [[./figs/$1.pdf][pdf]])}
[[file:$2/$1.png]]
,#+name: fig:$1
,#+caption: $0
,#+RESULTS:
[[file:figs/$1.png]]
#+end_src
*** Mfunction