Add snippets into spacemacs.org
This commit is contained in:
parent
a2e13cc27a
commit
eb68213e5d
@ -1469,3 +1469,459 @@ https://mentat.za.net/blog/2018/10/31/using-org-mode-with-neomutt/
|
|||||||
;; Hook up `message:...` style URLs
|
;; Hook up `message:...` style URLs
|
||||||
(org-add-link-type "message" 'tdehaeze/mutt-open-message)
|
(org-add-link-type "message" 'tdehaeze/mutt-open-message)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
* Snippets
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args:conf+: :comments none
|
||||||
|
:header-args:conf+: :mkdirp yes
|
||||||
|
:END:
|
||||||
|
** LaTeX
|
||||||
|
*** Coordinate
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/latex/coordinate
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :coordinate
|
||||||
|
# --
|
||||||
|
\coordinate[${1:->}] (${2:name}) at (${3:pointcoordinate});
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Draw
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/latex/draw
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :draw
|
||||||
|
# --
|
||||||
|
\draw[${1:->}] (${2:point1}) -- (${3:point2});
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Node
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/latex/node
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :node
|
||||||
|
# --
|
||||||
|
node[${1:below right}] (${2:name}) {${3:label}};
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Path
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/latex/path
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :path
|
||||||
|
# --
|
||||||
|
\path[${1}] (${2:point1}) -- (${3:point2});
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Matlab
|
||||||
|
*** Clear
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/matlab/clear
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :clear and close all
|
||||||
|
# --
|
||||||
|
clear; close all; clc;
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Function
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/matlab/function
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :function
|
||||||
|
# --
|
||||||
|
function [${4:outputs}] = ${1:functionName}(${2:inputs}, ${3:opts_param})
|
||||||
|
% $1 - Description
|
||||||
|
%
|
||||||
|
% Syntax: $1($2, $3)
|
||||||
|
%
|
||||||
|
% Inputs:
|
||||||
|
% - $2 -
|
||||||
|
% - $3 - Optionals parameters: structure with the following fields:
|
||||||
|
% -
|
||||||
|
%
|
||||||
|
% Outputs:
|
||||||
|
% - $4 -
|
||||||
|
|
||||||
|
%% Default value for opts
|
||||||
|
opts = struct(...
|
||||||
|
'${5:outputs}', ${6:default_value} ...
|
||||||
|
);
|
||||||
|
|
||||||
|
if exist('opts_param','var')
|
||||||
|
for opt = fieldnames($3)'
|
||||||
|
if sum(strcmp(fieldnames(opts), opt{1})) == 1
|
||||||
|
opts.(opt{1}) = $3.(opt{1});
|
||||||
|
else
|
||||||
|
warning(sprintf('%s is not a valid option.', opt{1}));
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Org Mode
|
||||||
|
*** Begin
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/begin
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :LaTeX Environment
|
||||||
|
# --
|
||||||
|
\begin{${1:equation}}
|
||||||
|
$0
|
||||||
|
\end{$1}
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Custom Box
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/cbox
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Custom Box
|
||||||
|
# --
|
||||||
|
#+attr_latex: :options [$1]{${2:blue}}{${3:ams nodisplayskip}}
|
||||||
|
#+begin_cbox
|
||||||
|
$0
|
||||||
|
#+end_cbox
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Code
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/code
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Code
|
||||||
|
# --
|
||||||
|
#+caption: ${1:Listing Caption}
|
||||||
|
#+label: lst:${2:listing_name}
|
||||||
|
,#+begin_src ${3:listing_language}
|
||||||
|
$0
|
||||||
|
,#+end_src
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Equation
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/equation
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Equation
|
||||||
|
# --
|
||||||
|
#+name: eq:${1:equation_name}
|
||||||
|
\begin{equation}
|
||||||
|
$0
|
||||||
|
\end{equation}
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Figure
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/figure
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Figure
|
||||||
|
# --
|
||||||
|
#+name: fig:${1:figure_name}
|
||||||
|
#+caption: ${2:Figure caption}
|
||||||
|
#+attr_latex: :${3:scale 1}
|
||||||
|
[[file:${4:figs/}$1.${5:pdf}]]
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Frac
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/frac
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :LaTeX Fraction
|
||||||
|
# --
|
||||||
|
\frac{$1}{$2} $0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Left
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/left
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Left Right mathematical delimitations
|
||||||
|
# --
|
||||||
|
\left$1 $0 \right$2
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Mconfig
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/mconfig
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Matlab-Configuration-Header
|
||||||
|
# --
|
||||||
|
#+PROPERTY: header-args:matlab :session *MATLAB*
|
||||||
|
#+PROPERTY: header-args:matlab+ :tangle ${1:filename}.m
|
||||||
|
#+PROPERTY: header-args:matlab+ :comments org
|
||||||
|
#+PROPERTY: header-args:matlab+ :exports both
|
||||||
|
#+PROPERTY: header-args:matlab+ :results none
|
||||||
|
#+PROPERTY: header-args:matlab+ :eval no-export
|
||||||
|
#+PROPERTY: header-args:matlab+ :noweb yes
|
||||||
|
#+PROPERTY: header-args:matlab+ :mkdirp yes
|
||||||
|
#+PROPERTY: header-args:matlab+ :output-dir ${2:figs}
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Mdescription
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/mdescription
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Measurement-Description
|
||||||
|
# --
|
||||||
|
,* Measurement description
|
||||||
|
,** Setup :ignore:
|
||||||
|
*Setup*:
|
||||||
|
|
||||||
|
,** Goal :ignore:
|
||||||
|
*Goal*:
|
||||||
|
|
||||||
|
,** Measurements :ignore:
|
||||||
|
*Measurements*:
|
||||||
|
|
||||||
|
Three measurements are done:
|
||||||
|
| Measurement File | Description |
|
||||||
|
|-------------------------+------------------------------|
|
||||||
|
| =mat/data_${1:001}.mat= | $2 |
|
||||||
|
|
||||||
|
Each of the measurement =mat= file contains one =data= array with 3 columns:
|
||||||
|
| Column number | Description |
|
||||||
|
|---------------+-------------------|
|
||||||
|
| 1 | $3 |
|
||||||
|
| 2 | $4 |
|
||||||
|
| 3 | Time |
|
||||||
|
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Mfigure
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/mfigure
|
||||||
|
#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
|
||||||
|
,#+end_src
|
||||||
|
|
||||||
|
#+NAME: fig:$1
|
||||||
|
#+CAPTION: ${4:caption}${5: ([[./figs/$1.png][png]], [[./figs/$1.pdf][pdf]])}
|
||||||
|
[[file:$2/$1.png]]
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Mfunction
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/mfunction
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Matlab-Function
|
||||||
|
# --
|
||||||
|
,* ${1:Function Name}
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args:matlab+: :tangle src/${2:matlab_file_name}.m
|
||||||
|
:header-args:matlab+: :comments org :mkdirp yes
|
||||||
|
:header-args:matlab+: :eval no :results none
|
||||||
|
:END:
|
||||||
|
<<sec:$2>>
|
||||||
|
|
||||||
|
This Matlab function is accessible [[file:src/$2.m][here]].
|
||||||
|
|
||||||
|
,#+begin_src matlab
|
||||||
|
function [${4:in_data}] = $2(${3:in_data})
|
||||||
|
% $2 - $0
|
||||||
|
%
|
||||||
|
% Syntax: [$4] = voltageToVelocityL22($3)
|
||||||
|
%
|
||||||
|
% Inputs:
|
||||||
|
% - $3 -
|
||||||
|
%
|
||||||
|
% Outputs:
|
||||||
|
% - $4 -
|
||||||
|
|
||||||
|
end
|
||||||
|
,#+end_src
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Mheader
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/mheader
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Matlab-Header
|
||||||
|
# --
|
||||||
|
,* ${1:Heading Name}
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args:matlab+: :tangle matlab/${2:matlab_file_name}.m
|
||||||
|
:header-args:matlab+: :comments org :mkdirp yes
|
||||||
|
:END:
|
||||||
|
<<sec:$2>>
|
||||||
|
|
||||||
|
,** ZIP file containing the data and matlab files :ignore:
|
||||||
|
,#+begin_src bash :exports none :results none
|
||||||
|
if [ matlab/$2.m -nt data/$2.zip ]; then
|
||||||
|
cp matlab/$2.m $2.m;
|
||||||
|
zip data/$2 \
|
||||||
|
mat/data.mat \
|
||||||
|
$2.m
|
||||||
|
rm $2.m;
|
||||||
|
fi
|
||||||
|
,#+end_src
|
||||||
|
|
||||||
|
,#+begin_note
|
||||||
|
All the files (data and Matlab scripts) are accessible [[file:data/$2.zip][here]].
|
||||||
|
,#+end_note
|
||||||
|
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Minipage
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/minipage
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :minipage
|
||||||
|
# --
|
||||||
|
#+BEGIN_EXPORT latex
|
||||||
|
\begin{figure}[htbp]
|
||||||
|
\centering
|
||||||
|
\begin{minipage}[t]{0.49\linewidth}
|
||||||
|
#+END_EXPORT
|
||||||
|
#+attr_latex: :float nil :width 0.95\linewidth
|
||||||
|
$0
|
||||||
|
#+BEGIN_EXPORT latex
|
||||||
|
\end{minipage}%
|
||||||
|
\hfill%
|
||||||
|
\begin{minipage}[t]{0.49\linewidth}
|
||||||
|
#+END_EXPORT
|
||||||
|
#+attr_latex: :float nil :width 0.95\linewidth
|
||||||
|
|
||||||
|
#+BEGIN_EXPORT latex
|
||||||
|
\end{minipage}
|
||||||
|
\end{figure}
|
||||||
|
#+END_EXPORT
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Minit
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/minit
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Matlab-Init
|
||||||
|
# --
|
||||||
|
,** Matlab Init :noexport:ignore:
|
||||||
|
,#+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name)
|
||||||
|
<<matlab-dir>>
|
||||||
|
,#+end_src
|
||||||
|
|
||||||
|
,#+begin_src matlab :exports none :results silent :noweb yes
|
||||||
|
<<matlab-init>>
|
||||||
|
,#+end_src
|
||||||
|
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Mtable
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/mtable
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Matlab-Table
|
||||||
|
# --
|
||||||
|
,#+begin_src matlab :exports results :results value table replace :tangle no :post addhdr(*this*)
|
||||||
|
data2orgtable(${1:data}, {${2:'rowlabel'}}, {${3:'collabel'}}, ' %.1f ');
|
||||||
|
,#+end_src
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Multicolumn
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/multicolumn
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Multcolumn
|
||||||
|
# --
|
||||||
|
#+attr_latex: :float multicolumn
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Subfigure
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/subfigure
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Subfigure
|
||||||
|
# --
|
||||||
|
#+name: fig:${1:figure_name}
|
||||||
|
#+caption: ${2:figure caption}
|
||||||
|
#+attr_latex: :environment subfigure :width 0.49\linewidth :align c
|
||||||
|
| file:${3:sub_fig_name}.${4:pdf} | file:${5:sub_fig_name}.${6:pdf} |
|
||||||
|
| <<fig:$3>> ${7:sub figure caption} | <<fig:$5>> ${8:sub figure caption} |
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Table
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/table
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Table
|
||||||
|
# --
|
||||||
|
#+name: tab:${1:table_name}
|
||||||
|
#+caption: ${2:Table caption}
|
||||||
|
#+attr_latex: :environment tabularx :width ${3:\linewidth} :align ${4:lXX}
|
||||||
|
#+attr_latex: :float ${5:t} :placement [!htpb]
|
||||||
|
| $0 | | |
|
||||||
|
|---+---+---|
|
||||||
|
| | | |
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Tikz
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/tikz
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Tikz figure
|
||||||
|
# --
|
||||||
|
,#+begin_src latex :file ${1:figure_name}.pdf :post pdf2svg(file=*this*, ext="png") :exports both
|
||||||
|
\begin{tikzpicture}
|
||||||
|
$0
|
||||||
|
\end{tikzpicture}
|
||||||
|
,#+end_src
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Tikzfig
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/tikzfig
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Tikz Figure
|
||||||
|
# --
|
||||||
|
#+NAME: fig:${1:figure_name}
|
||||||
|
#+HEADER: :headers '("\\\\usepackage{tikz}" "\\\\usepackage{import}" "\\\\import{$HOME/MEGA/These/LaTeX/}{config.tex}")
|
||||||
|
#+HEADER: :imagemagick t :fit yes :iminoptions -scale 100% -density 150 :imoutoptions -quality 100
|
||||||
|
#+HEADER: :results raw replace :buffer no :eval no-export :exports both :mkdirp yes
|
||||||
|
#+HEADER: :output-dir ${2:figs}
|
||||||
|
,#+begin_src latex :file $1.pdf :post pdf2svg(file=*this*, ext="png") :exports both
|
||||||
|
\begin{tikzpicture}
|
||||||
|
$0
|
||||||
|
\end{tikzpicture}
|
||||||
|
,#+end_src
|
||||||
|
|
||||||
|
#+NAME: fig:$1
|
||||||
|
#+CAPTION: ${3:Caption}
|
||||||
|
#+RESULTS: fig:$1
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Tikzheader
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/tikzheader
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Tikz Header
|
||||||
|
# --
|
||||||
|
,* ${1:Title/Description of the figure}
|
||||||
|
The Tikz figure can be downloaded in the following formats: [[./figs/$2.png][png]], [[./figs/$2.pdf][pdf]] and [[./figs/$2.tex][tex]].
|
||||||
|
|
||||||
|
,#+begin_src latex :file ${2:figure_name}.pdf :tangle figs/$2.tex :exports ${3:both}
|
||||||
|
\begin{tikzpicture}
|
||||||
|
$0
|
||||||
|
\end{tikzpicture}
|
||||||
|
,#+end_src
|
||||||
|
|
||||||
|
#+name: fig:$2
|
||||||
|
#+caption: $1 ([[./figs/$2.png][png]], [[./figs/$2.pdf][pdf]], [[./figs/$2.tex][tex]]).
|
||||||
|
#+RESULTS:
|
||||||
|
[[file:./figs/$2.png]]
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** User-config
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/user-config
|
||||||
|
# -*- mode: snippet -*-
|
||||||
|
# name: user-config
|
||||||
|
# key: uc
|
||||||
|
# --
|
||||||
|
,#+begin_src emacs-lisp :tangle user-config.el
|
||||||
|
$1
|
||||||
|
,#+end_src
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** User-init
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/user-init
|
||||||
|
# -*- mode: snippet -*-
|
||||||
|
# name: user-init
|
||||||
|
# key: ui
|
||||||
|
# --
|
||||||
|
,#+begin_src emacs-lisp :tangle user-init.el
|
||||||
|
$1
|
||||||
|
,#+end_src
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Wrap
|
||||||
|
#+begin_src conf :tangle ~/.spacemacs.d/snippets/org-mode/wrap
|
||||||
|
#contributor : Thomas Dehaeze <dehaeze.thomas@gmail.com>
|
||||||
|
#name :Wrap
|
||||||
|
# --
|
||||||
|
#+attr_latex: :float wrap
|
||||||
|
$0
|
||||||
|
#+end_src
|
||||||
|
Loading…
Reference in New Issue
Block a user