Compare commits

...

3 Commits

Author SHA1 Message Date
Fabio Scotto di Santolo
88f17ff438 Configuring Org Mode on Emacs 2025-12-27 14:19:57 +01:00
Fabio Scotto di Santolo
5948c1256a Added Emacs modes for JSON and Markdown 2025-12-27 14:11:16 +01:00
Fabio Scotto di Santolo
db4f52a064 Added snippets for Emacs 2025-12-27 13:53:55 +01:00
120 changed files with 878 additions and 3 deletions

View File

@@ -166,6 +166,9 @@ source "$OSH"/oh-my-bash.sh
# users are encouraged to define aliases within the OSH_CUSTOM folder.
# For a full list of active aliases, run `
# export EDITOR="emacs -nw"
# export VISUAL="emacs"
alias ls='ls --color=auto --group-directories-first'
# Replace grep command tool

View File

@@ -45,6 +45,9 @@
'lang/c
'lang/docker
'lang/golang
'lang/json
'lang/markdown
'lang/org
'lang/shell
'lang/yaml

View File

@@ -50,9 +50,6 @@
;; Enable line numbers in the configuration mode only
(add-hook 'conf-mode-hook 'display-line-numbers-mode)
;; Setting default directory for Org files
(setq org-directory "~/Remotes/pCloud/Org")
;; Highlight keywords to remember the activity when coding.
(use-package hl-todo
:ensure t

View File

@@ -0,0 +1,7 @@
;;; json.el -*- lexical-binding: t -*-
(use-package json-mode
:ensure t)
(provide 'json)
;;; json.el ends here

View File

@@ -0,0 +1,8 @@
;;; markdown.el -*- lexical-binding: t; -*-
(use-package markdown-mode
:ensure t
:mode ("README\\.md\\'" . gfm-mode)
:init (setq markdown-command "multimarkdown"))
(provide 'markdown)
;;; markdown.el ends here

View File

@@ -0,0 +1,46 @@
;;; org.el -*- lexical-binding: t; -*-
(use-package htmlize
:ensure t)
(use-package org
:init
(setq org-clock-mode-line-total 'today
org-fontify-quote-and-verse-blocks t
org-indent-mode t
org-return-follows-link t
org-startup-folded 'content
org-todo-keywords '((sequence "🆕(t)" "▶️(s)" "⏳(w)" "🔎(p)" "|" "✅(d)" "🗑(c)" "👨(g)")))
:config
(add-hook 'org-mode-hook 'org-indent-mode)
(add-hook 'org-mode-hook 'flyspell-mode))
(use-package org-bullets
:ensure t
:init
(setq org-bullets-bullet-list '("" "" "" "" ""))
:config
(add-hook 'org-mode-hook 'org-bullets-mode))
(use-package org-re-reveal
:ensure t
:init
(setq org-re-reveal-transition 'none
org-re-reveal-theme "dracula"))
(use-package ob-mermaid
:ensure t
:init
(setq ob-mermaid-cli-path "mmdc")
(org-babel-do-load-languages
'org-babel-load-languages
'((mermaid . t)
(scheme . t))))
;; Setting default directory for Org files
(setq org-directory "~/Remotes/pCloud/Org")
(provide 'org)
;;; org.el ends here

View File

@@ -27,6 +27,14 @@
:config
(setq flycheck-check-syntax-automatically '(save mode-enabled)))
;; Snippets
(use-package yasnippet
:ensure t
:config
(setq yas/root-directory
(list "~/.emacs.d/snippets") yas-indent-line 'fixed)
(yas-global-mode))
(provide 'completion)
;;; completion.el ends here

View File

@@ -0,0 +1,3 @@
func main() {
$0
}

View File

@@ -0,0 +1 @@
fmt.Printf("%v\n", $0)

View File

@@ -0,0 +1,23 @@
func Test$0 {
tests := []struct {
name string
req string
expected string
}{
{
name: "happy path",
req: "answer to life, the universe and everything"
expected: "42"
}
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
actual := foo(t, tt.req)
assertEquals(t, tt.want, expected)
})
}
}

View File

@@ -0,0 +1,3 @@
#name : author
# --
@author <a href="mailto:torstein@skybert.net">Torstein Krause Johansen</a>$0

View File

@@ -0,0 +1,6 @@
#name : debug
# --
if (mLogger.isDebugEnabled()) {
mLogger.debug(String.format("${1:result}=%s", ${2:result}));
}
$0

View File

@@ -0,0 +1,31 @@
#name : dwmain
# --
package ${1:net.skybert.dw};
import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.configuration.SubstitutingSourceProvider;
import io.dropwizard.jetty.ConnectorFactory;
import io.dropwizard.jetty.HttpConnectorFactory;
import io.dropwizard.lifecycle.Managed;
import io.dropwizard.server.DefaultServerFactory;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
/**
* Main
*/
public class Main extends Application<${2:SkybertConf}> {
public static void main(final String[] args) throws Exception {
new Main().run(args);
}
@Override
public void run(
final $2 pConfiguration,
final Environment pEnvironment)
throws Exception {
$0
}
}

View File

@@ -0,0 +1,5 @@
#name : new method/function
# --
${1:public} ${2:void} ${3:update}(final ${4:String} ${5:pName}) {
$0
}

View File

@@ -0,0 +1,5 @@
#name : for (...; ...; ...) { ... }
# --
for (${1:Object} ${downcase-word 1} ; ${2:list}) {
$0
}

View File

@@ -0,0 +1,5 @@
#name : for loop with index
# --
for (int ${1:i} = 0; $1 < ${2:args.length}; $1${3:++}) {
$0
}

View File

@@ -0,0 +1,13 @@
#name : get/set/member variable
# --
private ${1:String} ${2:name};
public void set${2:$(capitalize text)}(final $1 p${2:$(capitalize text)}) {
$2 = p${2:$(capitalize text)};
}
public $1 get${2:$(capitalize text)}() {
return $2;
}
$0

View File

@@ -0,0 +1,6 @@
#name : if
# --
if (${1:result} ${2:!=} ${3:null}) {
$0
}

View File

@@ -0,0 +1,4 @@
#name : static import of isBlank
# --
import static org.apache.commons.lang.StringUtils.isBlank;
$0

View File

@@ -0,0 +1,21 @@
#name : junitwrapperfns
# --
private void assertTrue(final String pMessage, final boolean pConditition) {
Assertions.assertTrue(pConditition, pMessage);
}
private void assertFalse(final String pMessage, final boolean pConditition) {
Assertions.assertFalse(pConditition, pMessage);
}
private void assertNotNull(final String pMessage, final Object pActual) {
Assertions.assertNotNull(pActual, pMessage);
}
private void assertNull(final String pMessage, final Object pActual) {
Assertions.assertNull(pActual, pMessage);
}
private void assertEquals(final String pMessage, final Object pExpected, final Object pActual) {
Assertions.assertEquals(pExpected, pActual, pMessage);
}

View File

@@ -0,0 +1,5 @@
#name : main
# --
public static void main(String[] args) {
$0
}

View File

@@ -0,0 +1,3 @@
#name : np
# --
// NOPMD

View File

@@ -0,0 +1,3 @@
#name : get ObjectLoader
# --
$0ObjectLoader objectLoader = IOAPI.getAPI().getObjectLoader();

View File

@@ -0,0 +1,6 @@
#name : req
# --
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create($0))
.timeout(Duration.ofMillis(getResponseTimeout()))
.build();

View File

@@ -0,0 +1,3 @@
#name : res
# --
HttpResponse<String> response = mHttpClient.send(request, ofString());$0

View File

@@ -0,0 +1,3 @@
#name : sf
# --
String.format("%s", $0)

View File

@@ -0,0 +1,3 @@
#name : System.out.println
# --
System.out.println($0);

View File

@@ -0,0 +1,4 @@
@Test
void ${1:can}() throws Exception {
$0
}

View File

@@ -0,0 +1,12 @@
#name : try, catch & finally
# --
try {
$0
}
catch (${1:Exception} ${2:e}) {
mLogger.error($2);
}
finally {
}

View File

@@ -0,0 +1,8 @@
#name : try & catch
# --
try {
$0
}
catch (${1:Exception} ${2:e}) {
mLogger.error($2);
}

View File

@@ -0,0 +1,4 @@
#name : new array
# --
var ${1:myArray} = new Array();
$0

View File

@@ -0,0 +1,6 @@
#name : function
# --
function ${1:test}(${2:pValue}) {
$0
}

View File

@@ -0,0 +1,5 @@
#name : for (...; ...; ...) { ... }
# --
for (var ${1:i} = 0; $1 < ${2:args.length}; $1${3:++}) {
$0
}

View File

@@ -0,0 +1,6 @@
#name : if
# --
if (${1:s} == ${2:undefined}) {
$0
}

View File

@@ -0,0 +1,3 @@
#name : log
# --
console.log("$0");

View File

@@ -0,0 +1,3 @@
#name : a
# --
[${1}](${2})${0}

View File

@@ -0,0 +1,9 @@
#name : img snippet
# --
<img
class="centered"
src="${1:foo.png}"
alt="${2:alt img text}"
/>
$0

View File

@@ -0,0 +1,3 @@
# name : me
# --
[@skybert](https://skybert.net) ${1:says:}$0

View File

@@ -0,0 +1,17 @@
#name : pelican article
# --
title: ${1:`(s-replace "-" " " (file-name-base (buffer-file-name)))`}
date: ${2:`(format-time-string "%Y-%m-%d" (current-time))`}
category: ${3:`(file-name-nondirectory
(substring
(file-name-directory (buffer-file-name))
0
(- (length (file-name-directory (buffer-file-name))) 1)
))`}
tags: ${4:`(file-name-nondirectory
(substring
(file-name-directory (buffer-file-name))
0
(- (length (file-name-directory (buffer-file-name))) 1)
))`}
$0

View File

@@ -0,0 +1,6 @@
#name : src code snippet
# --
\`\`\`${1:text}
$0
\`\`\`

View File

@@ -0,0 +1,4 @@
#name : strong element
# --
<strong>${1:text}</strong>$0

View File

@@ -0,0 +1,3 @@
#name: cdata
# --
<![CDATA[$0]]>

View File

@@ -0,0 +1,8 @@
#name : cha
# --
<chapter xml:id="t_${1:$(replace-regexp-in-string " " "_" (downcase text))}">
<title>${1:My Title}</title>
<para>
$0
</para>
</chapter>

View File

@@ -0,0 +1,7 @@
#name : dep
# --
<dependency>
<groupId>$1</groupId>
<artifactId>$2</artifactId>
<version>$0</version>
</dependency>

View File

@@ -0,0 +1,10 @@
#name : diary
# --
<!--#include virtual="/ssi/header.shtml" -->
<h1>$1</h1>
<div id="main">
<p>
$0
</p>
</div>
<!--#include virtual="/ssi/footer.shtml" -->

View File

@@ -0,0 +1,6 @@
#name : exclusion
# --
<exclusion>
<groupId>$1</groupId>
<artifactId>$2</artifactId>
</exclusion>$0

View File

@@ -0,0 +1,8 @@
#name : exclusions
# --
<exclusions>
<exclusion>
<groupId>$1</groupId>
<artifactId>$2</artifactId>
</exclusion>$0
</exclusions>

View File

@@ -0,0 +1,3 @@
#name : incvar
# --
<xi:include href="local-variables.ebk" xpointer="${1:l-product-um}"/>$0

View File

@@ -0,0 +1,10 @@
#name : list
# --
<itemizedlist>
<listitem>
<para>
$0
</para>
</listitem>
</itemizedlist>

View File

@@ -0,0 +1,4 @@
#name : listi
# --
<listitem><para>$0</para></listitem>

View File

@@ -0,0 +1,3 @@
#name : lit
# --
<literal>$0</literal>

View File

@@ -0,0 +1,5 @@
#name : ol with a li
# --
<ol>
<li>$0</li>
</ol>

View File

@@ -0,0 +1,5 @@
#name : para
# --
<para>
$0
</para>

View File

@@ -0,0 +1,4 @@
#name : prog
# --
<programlisting><![CDATA[$0
]]></programlisting>

View File

@@ -0,0 +1,5 @@
#name : insert a JS tag without src
# --
<script type="text/javascript">
$0
</script>

View File

@@ -0,0 +1,4 @@
#name : insert a JS tag with src
# --
<script type="text/javascript" src="${1:script.js}"></script>
$0

View File

@@ -0,0 +1,8 @@
#name : sec
# --
<section xml:id="t_${1:$(replace-regexp-in-string " " "_" (downcase text))}">
<title>${1:My Title}</title>
<para>
$0
</para>
</section>

View File

@@ -0,0 +1,5 @@
#name : ul with a li
# --
<ul>
<li>$0</li>
</ul>

View File

@@ -0,0 +1,3 @@
#name : varece
# --
<xi:include href="ece-global:global-variables.ebk" xpointer="g-engine" />

View File

@@ -0,0 +1,4 @@
#name : xlink
# --
<link xlink:href="${1:https://example.com}">$2</link>
$0

View File

@@ -0,0 +1,5 @@
#name : insert a Confluence code block
# --
{code}
$0
{code}

View File

@@ -0,0 +1,21 @@
#name: daily
# --
* Admin, training & maintenance
** DEVTR-1 Meetings, email, Slack++
** DEVTR-5 System Maintenance
** DEVTR-6 Software Delivery
** DEVTR-8 Training
* Coding
* Review
* Specification
* Support
** DEVTR-3 PSERV Assistance
** DEVTR-5 Helping out colleagues in R&D
* Report
#+BEGIN: clocktable :maxlevel 2
#+END:

View File

@@ -0,0 +1 @@
** TODO DEVTR-44 Review - $0

View File

@@ -0,0 +1,5 @@
#name : insert a quote
# --
#+begin_quote
$0
#+end_quote

View File

@@ -0,0 +1,5 @@
#name : insert a source (BASH) declaration
# --
#+begin_src markdown
$0
#+end_src

View File

@@ -0,0 +1 @@
#+title: $0

View File

@@ -0,0 +1,4 @@
#name : app
# --
app = $1(__name__)
$0

View File

@@ -0,0 +1,4 @@
#name : def
# --
def $1($2):
$0

View File

@@ -0,0 +1,4 @@
#name : im
# --
from $1 import $2
$0

View File

@@ -0,0 +1,6 @@
#name : imflask
# --
from flask import Flask
from flask import render_template
from requests import get
$0

View File

@@ -0,0 +1,4 @@
#name : main
# --
if __name__ == "__main__":
$0

View File

@@ -0,0 +1,6 @@
#name : Create @property function
# --
@property
def $1(self):
return self._$1
$0

View File

@@ -0,0 +1,4 @@
#name : pr
# --
print($1)
$0

View File

@@ -0,0 +1,4 @@
#name : prx
# --
print(etree.tostring($1, encoding='unicode'))
$0

View File

@@ -0,0 +1,3 @@
#name : render
# --
return render_template("$1", data=$2)

View File

@@ -0,0 +1,5 @@
#name : route
# --
@app.route("/<$1>$2")
def $3($1):
$0

View File

@@ -0,0 +1,5 @@
#name : route
# --
@app.route("/<$1>/<$2>$3")
def $4($1, $2):
$0

View File

@@ -0,0 +1 @@
package ${1:`(replace-regexp-in-string "/" "." (file-name-directory (buffer-file-name)))`}$0

View File

@@ -0,0 +1 @@
print("$1", $2)$0

View File

@@ -0,0 +1,44 @@
#key: args
# --
read_user_input() {
local opts=
opts=$(getopt \
-o hr:nv \
--long help \
--long version: \
--long dry-run \
--long verbose \
-n 'parse-options' \
-- "$@")
if [ $? != 0 ] ; then
echo "Failed parsing options." >&2
exit 1
fi
eval set -- "$opts"
while true; do
case "\$1" in
-h | --help)
print_help;
exit 0
break;;
-r | --version)
export version=\$2
shift 2;;
-n | --dry-run)
export dry_run=1
shift;;
-v | --verbose)
export verbose=1
shift;;
-- )
shift;
break ;;
* )
break ;;
esac
done
export rest_of_args=$*
}

View File

@@ -0,0 +1,3 @@
#name: aw
# --
awk '{print \$${1:1}\}'$0

View File

@@ -0,0 +1,18 @@
#name : cmd
# --
#! /usr/bin/env bash
## author: torstein, torstein@skybert.net
set -o errexit
set -o nounset
set -o pipefail
main() {
:
}
main "$@"

View File

@@ -0,0 +1,5 @@
#name: cwd
# --
local _cwd=
_cwd="$(cd "\$(dirname "\${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
$0

View File

@@ -0,0 +1,5 @@
#name : eof
# --
cat <<EOF
$0
EOF

View File

@@ -0,0 +1,5 @@
#name : fn
# --
${1:read_user_input}() {
$0
}

View File

@@ -0,0 +1,7 @@
assertEquals() {
test "\$1" = "\$2" || {
printf "Failed: Expected: [%s] Actual: [%s]\\n" "\${1}" "\${2}"
exit 1
}
}
$0

View File

@@ -0,0 +1,6 @@
#name : fo
# --
for ${1:el} in \$\{${2:list}\}; do
echo "\${$1}"
$0
done

View File

@@ -0,0 +1,19 @@
#name : help
# --
_show_help() {
cat <<EOF
NAME
$(basename "\$0")
SYNOPSIS
$(basename "\$0")
OPTIONS
--help Don't panic
AUTHORS
skybert wrote the initial version.
$0
EOF
}

View File

@@ -0,0 +1,5 @@
#name : if
# --
if [ ${1} ]; then
$0
fi

View File

@@ -0,0 +1,5 @@
#name : iif
# --
if [[ ${1} ]]; then
$0
fi

View File

@@ -0,0 +1,7 @@
#name : main
# --
main() {
$0
}
main "$@"

View File

@@ -0,0 +1,3 @@
#name : pr
# --
printf "%s\\\n" "\${$0}"

View File

@@ -0,0 +1,27 @@
#name : shunit
# --
#! /usr/bin/env bash
# by torstein@skybert.net
cwd="\$(cd "$(dirname "\${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
## @override shunit2
setUp() {
source "\${cwd}/../lib/$(basename "\$0" -test.sh)-lib.sh"
}
## @override shunit2
tearDown() {
:
}
main() {
test -d "\${cwd}"/shunit2 || {
git -C "\${cwd}" clone --quiet --depth 1 https://github.com/kward/shunit2.git
}
source "\${cwd}"/shunit2/shunit2
}
main "\$@"

View File

@@ -0,0 +1,21 @@
#name : test
# --
#! /usr/bin/env bash
## author: torstein, torstein@skybert.net
## @override shunit2
setUp() {
source "$(dirname "\$0")/../lib/$(basename "\$0" -test.sh).sh"
}
## @override shunit2
tearDown() {
:
}
main() {
. "$(dirname "\$0")"/shunit2/shunit2
}
main "$@"

View File

@@ -0,0 +1,8 @@
#name : tmpdir
# --
local ${1:tmp_dir}=
$1=\$(mktemp -d)
$0
rm -rf "\${$1\}"

View File

@@ -0,0 +1,3 @@
#name : v
# --
"\${$1}"$0

View File

@@ -0,0 +1,4 @@
#name : va
# --
local ${1:dir}=
$1=$($0)

View File

@@ -0,0 +1,3 @@
#name : vad
# --
local ${1:dir}=$0

View File

@@ -0,0 +1,6 @@
#name : wh
# --
while read -r ${1:f}; do
echo "\${$1}"
$0
done

View File

@@ -0,0 +1,5 @@
#name : a
# --
<a href="$1">
$0
</a>

Some files were not shown because too many files have changed in this diff Show More