├── personal-libs ├── ts-repl │ ├── README.org │ ├── Eldev │ └── ts-repl.el ├── lang-scripts │ ├── README.org │ ├── Eldev │ ├── test │ │ └── lang-scripts-test.el │ └── lang-scripts.el ├── make-scripts │ ├── README.org │ ├── Eldev │ ├── test │ │ └── make-scripts-test.el │ └── make-scripts.el ├── functional │ ├── Eldev │ ├── readme.org │ ├── test │ │ ├── buttercup-helpers.elc │ │ └── functional-test.el │ ├── functional-autoloads.el │ └── functional.el ├── json-utils │ ├── Eldev │ └── json-utils.el ├── laurisp-core │ ├── l-general.el │ ├── l-misc.el │ ├── l-shell.el │ ├── l-string.el │ ├── laurisp-core.el │ └── laurisp-core.elc ├── buttercup-helpers │ ├── buttercup-helpers.el │ └── buttercup-helpers.elc ├── ramda-docs │ └── ramda-docs.el ├── spotilau │ └── spotilau.el ├── launguage-server-protocol │ └── launguage-server-protocol.el ├── laurg │ └── laurg.el ├── sqlau │ └── sqlau.el ├── npm-scripts │ └── npm-scripts.el └── lautex │ └── lautex.el ├── snippets ├── org-mode │ └── .yas-parents ├── typescript-mode │ ├── .yas-parents │ └── class.snippet ├── emacs-lisp-mode │ ├── .yas-parents │ ├── autoload.snippet │ ├── expect.snippet │ ├── spy-on.snippet │ ├── before-each.snippet │ ├── test-suite.snippet │ ├── comment.snippet │ ├── it-should.snippet │ ├── .yas-setup.el │ ├── context.snippet │ ├── micro-state │ ├── new-package │ └── laurisp-package.snippet ├── web-mode │ └── .yas-parents ├── latex-mode │ └── chapter.snippet └── rjsx-mode │ ├── expect.snippet │ ├── after.snippet │ ├── before.snippet │ ├── it.snippet │ ├── context.snippet │ ├── after-all.snippet │ ├── test.snippet │ ├── after-each.snippet │ ├── async-after.snippet │ ├── before-all.snippet │ ├── describe.snippet │ ├── async-before.snippet │ ├── async-it.snippet │ ├── before-each.snippet │ ├── async-after-all.snippet │ ├── async-test.snippet │ ├── async-after-each.snippet │ ├── async-before-all.snippet │ ├── test-each.snippet │ ├── async-before-each.snippet │ ├── describe-each.snippet │ ├── async-test-each.snippet │ └── async-describe-each.snippet ├── .gitignore ├── Cask ├── config ├── l-sql.el ├── l-slack.el ├── l-neotree.el ├── l-haskell.el ├── l-spotify.el ├── l-paredit.el ├── l-prettify-symbols.el ├── l-lazy-loading.el ├── l-projectile.el ├── org-mode-extra-configs.org ├── l-files.el ├── l-js-ts.el ├── l-global.el └── l-org-latex-pdf.el ├── external ├── emacs-grammarly │ ├── push.scpt │ ├── pull.scpt │ ├── emacs-grammarly.el │ └── emacs-grammarly.elc └── hs-lint │ ├── hs-lint.el │ └── hs-lint.elc ├── test ├── core │ ├── test-general.el │ ├── test-shell.el │ └── test-string.el └── buttercup-helpers.elc ├── lazy-files ├── org-headers-skeletons.el ├── org-headers-skeletons.elc └── custom-icons-definitions.el ├── laurisp.el └── README.org /personal-libs/ts-repl/README.org: -------------------------------------------------------------------------------- 1 | * ts-repl -------------------------------------------------------------------------------- /snippets/org-mode/.yas-parents: -------------------------------------------------------------------------------- 1 | latex-mode -------------------------------------------------------------------------------- /snippets/typescript-mode/.yas-parents: -------------------------------------------------------------------------------- 1 | rjsx-mode -------------------------------------------------------------------------------- /personal-libs/lang-scripts/README.org: -------------------------------------------------------------------------------- 1 | * lang-scripts -------------------------------------------------------------------------------- /personal-libs/make-scripts/README.org: -------------------------------------------------------------------------------- 1 | * make-scripts -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/.yas-parents: -------------------------------------------------------------------------------- 1 | prog-mode 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/**/.DS_Store 2 | **/.cask/* 3 | **/.eldev/* -------------------------------------------------------------------------------- /snippets/web-mode/.yas-parents: -------------------------------------------------------------------------------- 1 | rjsx-mode 2 | prog-mode 3 | js-mode -------------------------------------------------------------------------------- /personal-libs/functional/Eldev: -------------------------------------------------------------------------------- 1 | (eldev-use-package-archive 'melpa) 2 | -------------------------------------------------------------------------------- /personal-libs/ts-repl/Eldev: -------------------------------------------------------------------------------- 1 | (eldev-use-package-archive 'melpa) 2 | ;(eldev-use-local-dependency "") -------------------------------------------------------------------------------- /personal-libs/lang-scripts/Eldev: -------------------------------------------------------------------------------- 1 | (eldev-use-package-archive 'melpa) 2 | ;(eldev-use-local-dependency "") -------------------------------------------------------------------------------- /personal-libs/make-scripts/Eldev: -------------------------------------------------------------------------------- 1 | (eldev-use-package-archive 'melpa) 2 | ;(eldev-use-local-dependency "") -------------------------------------------------------------------------------- /personal-libs/json-utils/Eldev: -------------------------------------------------------------------------------- 1 | (eldev-use-package-archive 'melpa) 2 | (eldev-use-local-dependency "../laurisp-core") -------------------------------------------------------------------------------- /personal-libs/lang-scripts/test/lang-scripts-test.el: -------------------------------------------------------------------------------- 1 | ;;; lang-scripts-test.el --- test suite -*- lexical-binding: t -*- -------------------------------------------------------------------------------- /personal-libs/make-scripts/test/make-scripts-test.el: -------------------------------------------------------------------------------- 1 | ;;; make-scripts-test.el --- test suite -*- lexical-binding: t -*- -------------------------------------------------------------------------------- /snippets/latex-mode/chapter.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: latex -*- 2 | # name: chapter 3 | # key: ch 4 | # -- 5 | \chapter{$1} -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/autoload.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: emacs-lisp-mode -*- 2 | # name: autoload 3 | # key: auto 4 | # -- 5 | 6 | ;;;###autoload -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/expect.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: emacs-lisp-mode -*- 2 | # name: expect block 3 | # key: ex 4 | # -- 5 | 6 | (expect $0) -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/spy-on.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: emacs-lisp-mode -*- 2 | # name: spy on block 3 | # key: spy 4 | # -- 5 | 6 | (spy-on $0) -------------------------------------------------------------------------------- /Cask: -------------------------------------------------------------------------------- 1 | (source gnu) 2 | (source melpa) 3 | 4 | (development 5 | (depends-on "projectile") 6 | (depends-on "helm") 7 | (depends-on "buttercup")) 8 | -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/before-each.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: emacs-lisp-mode -*- 2 | # name: before-each block 3 | # key: bee 4 | # -- 5 | 6 | (before-each $0) -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/test-suite.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: emacs-lisp-mode -*- 2 | # name: test suite 3 | # key: sui 4 | # -- 5 | 6 | (test-suite "${1:#}$2" 7 | $0) -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/comment.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: emacs-lisp-mode -*- 2 | # name: Comment 3 | # key: com 4 | # -- 5 | 6 | ;; 7 | ;; $1 8 | ;; 9 | $0 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/expect.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: expect 3 | # key: ex 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | expect($1).$0 -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/it-should.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: emacs-lisp-mode -*- 2 | # name: it should block 3 | # key: it 4 | # -- 5 | 6 | (it-should "$1" 7 | (expect $0)) -------------------------------------------------------------------------------- /snippets/rjsx-mode/after.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: after block 3 | # key: aft 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | after(() => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/before.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: before block 3 | # key: bef 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | before(() => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/it.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: it block 3 | # key: it 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | it('should $1', () => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/context.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: context block 3 | # key: con 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | context('when $1', () => { 8 | $0 9 | }) -------------------------------------------------------------------------------- /snippets/rjsx-mode/after-all.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: afterAll block 3 | # key: afa 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | afterAll(() => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/test.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: test block 3 | # key: tes 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | test('should $1', () => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/after-each.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: afterEach block 3 | # key: afe 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | afterEach(() => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/async-after.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: async after block 3 | # key: aaft 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | after(async () => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/before-all.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: beforeAll block 3 | # key: bea 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | beforeAll(() => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/describe.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: describe block 3 | # key: des 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | describe('${1:when} $2', () => { 8 | $0 9 | }) -------------------------------------------------------------------------------- /snippets/rjsx-mode/async-before.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: async before block 3 | # key: abef 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | before(async () => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/async-it.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: async it block 3 | # key: ait 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | it('should $1', async () => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/before-each.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: beforeEach block 3 | # key: bee 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | beforeEach(() => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/.yas-setup.el: -------------------------------------------------------------------------------- 1 | (defun spacemacs/get-parent-dir () 2 | (car (cdr ; Last item 3 | (reverse 4 | (split-string 5 | (file-name-sans-extension (buffer-file-name)) 6 | "/"))))) 7 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/async-after-all.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: async afterAll block 3 | # key: aafa 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | afterAll(async () => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/async-test.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: async test block 3 | # key: ates 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | test('should $1', async () => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/async-after-each.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: async afterEach block 3 | # key: aafe 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | afterEach(async () => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/async-before-all.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: async beforeAll block 3 | # key: abea 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | beforeAll(async () => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /snippets/rjsx-mode/test-each.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: test.each block 3 | # key: tee 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | test.each([$3])('${1:when} $2', ($4) => { 8 | $0 9 | }) -------------------------------------------------------------------------------- /snippets/rjsx-mode/async-before-each.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: async beforeEach block 3 | # key: abee 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | beforeEach(async () => { 8 | $0 9 | }) 10 | -------------------------------------------------------------------------------- /config/l-sql.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; sql related functions 9 | ;; 10 | 11 | (with-eval-after-load "sql" 12 | (load-lib 'sqlau) 13 | (load-lib 'sql-private)) 14 | -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/context.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: emacs-lisp-mode -*- 2 | # name: context block 3 | # key: con 4 | # -- 5 | 6 | (context "$1" 7 | ${2::var (($3))}${4:(before-each $5)}$6(it-should "$7" 8 | (expect ${8:($9)} :$10 $11)$12))$0 -------------------------------------------------------------------------------- /snippets/rjsx-mode/describe-each.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: describe.each block 3 | # key: dee 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | describe.each([$3])('${1:when} $2', ($4) => { 8 | $0 9 | }) -------------------------------------------------------------------------------- /snippets/rjsx-mode/async-test-each.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: async test.each block 3 | # key: atee 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | test.each([$3])('${1:when} $2', async ($4) => { 8 | $0 9 | }) -------------------------------------------------------------------------------- /snippets/rjsx-mode/async-describe-each.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: async describe.each block 3 | # key: adee 4 | # group: Test 5 | # author: Laura Viglioni 6 | # -- 7 | describe.each([$3])('${1:when} $2', async ($4) => { 8 | $0 9 | }) -------------------------------------------------------------------------------- /config/l-slack.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; slack related functions 9 | ;; 10 | 11 | (with-eval-after-load "slack" 12 | (add-hook 'slack-mode-hook 'emojify-mode) 13 | (load-lib 'slack-private)) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /external/emacs-grammarly/push.scpt: -------------------------------------------------------------------------------- 1 | tell application "System Events" 2 | tell process "Grammarly" 3 | set visible to true 4 | set frontmost to true 5 | click menu item "Paste" of menu "Edit" of menu bar 1 6 | display notification "" with title "Emacs Grammarly" subtitle "Pull" sound name "Pop" 7 | end tell 8 | end tell 9 | delay 0.1 -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/micro-state: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet; require-final-newline: nil -*- 2 | # name: micro-state 3 | # key: micro 4 | # binding: direct-keybinding 5 | # -- 6 | (spacemacs|define-micro-state ${1:micro-state-name} 7 | ${2::doc (spacemacs//$1-ms-documentation)} 8 | ${3::use-minibuffer t} 9 | ${4::evil-leader "${5:Leader-key}"} 10 | :bindings 11 | ${} 12 | ) -------------------------------------------------------------------------------- /config/l-neotree.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020~2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; neotree related functions 9 | ;; 10 | 11 | 12 | (with-eval-after-load "neotree" 13 | (setq neo-theme 'icons) 14 | (setq neo-window-fixed-size nil)) 15 | 16 | (with-eval-after-load "all-the-icons" 17 | (load-lib 'custom-icons-definitions) 18 | (setq all-the-icons-icon-alist custom-icons)) 19 | 20 | 21 | -------------------------------------------------------------------------------- /snippets/typescript-mode/class.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: rjsx-mode -*- 2 | # name: class 3 | # key: cla 4 | # group: OOP 5 | # author: Laura Viglioni 6 | # -- 7 | 8 | ${1:export }class ${2:ClassName} ${3:extends/implements Something$$(yas-choose-value '(" " "extends " "implements ")) }{ 9 | ${4:public constructor($5) { 10 | ${6:super($7)} 11 | $8 12 | \}} 13 | $0 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /config/l-haskell.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; haskell related functions 9 | ;; 10 | 11 | (with-eval-after-load "haskell" 12 | (message "running exec path from shell...") 13 | (exec-path-from-shell-initialize) 14 | ;; (load-lib 'hs-lint) 15 | ;; (defun my-haskell-mode-hook () 16 | ;; (local-set-key "\C-cl" 'hs-lint)) 17 | ;; (add-hook 'haskell-mode-hook 'my-haskell-mode-hook) 18 | ) 19 | -------------------------------------------------------------------------------- /test/core/test-general.el: -------------------------------------------------------------------------------- 1 | ;; -*- lexical-binding: t -*- 2 | (load "./tests/buttercup-helpers.elc") 3 | (load "./src/l-general") 4 | 5 | 6 | (test-suite "#throw-if" 7 | (context "condition is truthy" 8 | (it-should "throw error with correct message" 9 | (expect (throw-if t "message") :to-throw 'error '("message")) 10 | (expect (throw-if t) :to-throw 'error '("")))) 11 | (context "condition is falsey" 12 | (it-should "not throw error" 13 | (expect (throw-if nil) :not :to-throw)))) 14 | -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/new-package: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet; require-final-newline: nil -*- 2 | # contributor: Diego Berrocal (cestdiego 4t gm4il d0t com) 3 | # name: new-package 4 | # key: newp 5 | # binding: direct-keybinding 6 | # -- 7 | (defun `(spacemacs/get-parent-dir)`/init-${2:package-name} () 8 | ${3:(use-package $2 9 | ${4::defer t 10 | }${5::init 11 | ${;; This block executes before the package has been loaded} 12 | }${:config 13 | ${;; This block executes after the package has been loaded} 14 | })}) 15 | $0 -------------------------------------------------------------------------------- /personal-libs/laurisp-core/l-general.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; general related functions 9 | ;; 10 | 11 | ;;;###autoload 12 | (defmacro throw-if (condition &optional error-description) 13 | "if condition is true, thrown an error" 14 | `(if ,condition (error (or ,error-description "")))) 15 | 16 | (defmacro throw-unless (condition &optional error-description) 17 | "if condition is true, thrown an error" 18 | `(unless ,condition (error (or ,error-description "")))) 19 | 20 | -------------------------------------------------------------------------------- /external/emacs-grammarly/pull.scpt: -------------------------------------------------------------------------------- 1 | tell application "System Events" 2 | tell process "Grammarly" 3 | set visible to true 4 | set frontmost to true 5 | 6 | click menu item "Select All" of menu "Edit" of menu bar 1 7 | click menu item "Cut" of menu "Edit" of menu bar 1 8 | display notification "" with title "Emacs Grammarly" subtitle "Pull" sound name "Pop" 9 | end tell 10 | end tell 11 | 12 | tell application "System Events" 13 | tell process "Emacs" 14 | set frontmost to true 15 | end tell 16 | end tell 17 | delay 0.1 -------------------------------------------------------------------------------- /config/l-spotify.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; spotify related functions 9 | ;; 10 | 11 | 12 | (bind-lazy-function 'spotify-menu-bar 'spotify-helper 'spotilau) 13 | (bind-lazy-function 'spotify-menu 'spotify-status 'spotilau) 14 | 15 | (spacemacs/set-leader-keys 16 | "a m s m" 'spotify-menu-bar 17 | "a m s a" 'spotify-menu) 18 | 19 | ;; set alias keybindings 20 | (which-key-add-key-based-replacements "M-p" "Spotify") 21 | 22 | (global-set-key (kbd "M-p M-p") 'spotify-menu-bar) 23 | (global-set-key (kbd "M-p p") 'spotify-menu) 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /personal-libs/laurisp-core/l-misc.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; misc related functions 9 | ;; 10 | 11 | ;;(require 'functional) 12 | 13 | ;;;###autoload 14 | (defun compile-laurisp-core () 15 | (interactive) 16 | (let* ((filename "laurisp-core.el") 17 | (files (directory-files "." t "^l-[a-z\\-].*\\.el$")) 18 | (content (fp/pipe files 19 | ((mapcar 'get-string-from-file) 20 | (string-join))))) 21 | (with-temp-buffer 22 | (insert content) 23 | (insert "\n\n(provide 'laurisp-core)\n") 24 | (write-file filename)) 25 | (byte-compile-file filename))) 26 | 27 | 28 | -------------------------------------------------------------------------------- /config/l-paredit.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | 8 | ;; 9 | ;; paredit related functions 10 | ;; 11 | 12 | 13 | (add-hook 'emacs-lisp-mode-hook 'enable-paredit-mode) 14 | (add-hook 'eval-expression-minibuffer-setup-hook 'enable-paredit-mode) 15 | (add-hook 'ielm-mode-hook 'enable-paredit-mode) 16 | (add-hook 'lisp-mode-hook 'enable-paredit-mode) 17 | (add-hook 'lisp-interaction-mode-hook 'enable-paredit-mode) 18 | (add-hook 'scheme-mode-hook 'enable-paredit-mode) 19 | (add-hook 'clojure-mode-hook 'enable-paredit-mode) 20 | 21 | 22 | (eval-after-load "smartparens" 23 | (lambda () 24 | ;; other modules 25 | (sp-use-paredit-bindings))) 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /personal-libs/functional/readme.org: -------------------------------------------------------------------------------- 1 | * Functional 2 | A functional lib for emacs. 3 | To run tests and compiling this project uses [[https://github.com/doublep/eldev][eldev]]. 4 | 5 | * Testing 6 | To run tests we use [[https://github.com/jorgenschaefer/emacs-buttercup/][buttercup]] and some macros defined in ~~/test/buttercup-helpers~, check out [[https://github.com/Viglioni/laurisp/tree/main/personal-libs/buttercup-helpers][buttercup-helpers repo]]. 7 | 8 | *** To run tests 9 | In the root of this project: 10 | #+begin_src shell 11 | $ eldev test 12 | #+end_src 13 | * Compiling 14 | *** To compile 15 | In the root of this project: 16 | #+begin_src shell 17 | $ eldev compile 18 | #+end_src 19 | 20 | -------------------------------------------------------------------------------- /config/l-prettify-symbols.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; prettify-symbols related functions 9 | ;; 10 | 11 | ;; set to run globally 12 | 13 | 14 | ;; symbols do be used in any mode 15 | (setq generic-symbols 16 | '(("->" . ?→) 17 | ("=>" . ?⇒) 18 | ("/=" . ?≠) 19 | ("!==" . ?≠) 20 | ("<=" . ?≤) 21 | (">=" . ?≥) 22 | )) 23 | 24 | 25 | (with-eval-after-load "prog-mode" 26 | 27 | (defun add-symbols-to-mode (&optional symbols) 28 | (dolist (symbol symbols) 29 | (if (not-contains? prettify-symbols-alist symbol) 30 | (push symbol prettify-symbols-alist)))) 31 | 32 | (global-prettify-symbols-mode +1) 33 | 34 | ;; applying to all modes 35 | (add-hook 'prog-mode-hook 36 | (lambda () (add-symbols-to-mode generic-symbols)))) 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /external/emacs-grammarly/emacs-grammarly.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; code from 3 | ;; https://github.com/mmagnus/emacs-grammarly/blob/master/emacs-grammarly.el 4 | ;; GPL-3.0 5 | ;; 6 | 7 | 8 | ;;; emacs-grammarly.el --- a simple plugin to sent text to Grammarly 9 | ;;; Commentary: 10 | ;; URL: https://github.com/mmagnus/emacs-grammarly 11 | ;;; Code: 12 | ;;;###autoload 13 | (defun grammarly-push () 14 | "Save region to a tempfile and run Grammarly on it." 15 | (interactive) 16 | (kill-region (region-beginning) (region-end)) 17 | ;;(insert "<>") 18 | (call-process-shell-command "osascript ~/laurisp/external/emacs-grammarly/push.scpt") 19 | ) 20 | ;;;###autoload 21 | (defun grammarly-pull() 22 | "Save region to a tempfile and run Grammarly on it." 23 | (interactive) 24 | (call-process-shell-command "osascript ~/laurisp/external/emacs-grammarly/pull.scpt") 25 | (yank) 26 | ) 27 | 28 | (global-set-key (kbd "C-c C-g h") 'grammarly-push) 29 | (global-set-key (kbd "C-c C-g l") 'grammarly-pull) 30 | 31 | (provide 'emacs-grammarly) 32 | ;;; emacs-grammarly.el ends here 33 | -------------------------------------------------------------------------------- /personal-libs/buttercup-helpers/buttercup-helpers.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | (message "loading buttercup-helpers...") 8 | 9 | ;;;###autoload 10 | (defun load-test-file (file-name) 11 | "search for file and loads it" 12 | (mapcar 'load 13 | (directory-files-recursively "." (concat file-name ".el")))) 14 | 15 | ;;;###autoload 16 | (defmacro test-suite (description &rest body) 17 | "the same as describe, but with defun indentation" 18 | (declare (indent defun)) 19 | `(describe ,description 20 | ,@body)) 21 | 22 | ;;;###autoload 23 | (defmacro context (description &rest body) 24 | "the same as describe, but more idiomatic and with defun indentation" 25 | (declare (indent defun)) 26 | `(describe (concat "when " ,description) 27 | ,@body)) 28 | 29 | ;;;###autoload 30 | (defmacro it-should (description &rest body) 31 | "the same as it, but with defun indentation" 32 | (declare (indent defun)) 33 | `(it (concat "should " ,description) 34 | ,@body)) 35 | 36 | (provide 'buttercup-helpers) 37 | -------------------------------------------------------------------------------- /external/emacs-grammarly/emacs-grammarly.elc: -------------------------------------------------------------------------------- 1 | ;ELC 2 | ;;; Compiled 3 | ;;; in Emacs version 27.2.50 4 | ;;; with all optimizations. 5 | 6 | ;;; This file uses dynamic docstrings, first added in Emacs 19.29. 7 | 8 | ;;; This file does not contain utf-8 non-ASCII characters, 9 | ;;; and so can be loaded in Emacs versions earlier than 23. 10 | 11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 13 | 14 | 15 | #@52 Save region to a tempfile and run Grammarly on it. 16 | (defalias 'grammarly-push #[nil "\300\301 \302 \"\210\303\304!\207" [kill-region region-beginning region-end call-process-shell-command "osascript ~/laurisp/external/emacs-grammarly/push.scpt"] 3 (#$ . 411) nil]) 17 | #@52 Save region to a tempfile and run Grammarly on it. 18 | (defalias 'grammarly-pull #[nil "\300\301!\210\302 \207" [call-process-shell-command "osascript ~/laurisp/external/emacs-grammarly/pull.scpt" yank] 2 (#$ . 681) nil]) 19 | (byte-code "\300\301\302\"\210\300\303\304\"\210\305\306!\207" [global-set-key "h" grammarly-push "l" grammarly-pull provide emacs-grammarly] 3) 20 | -------------------------------------------------------------------------------- /config/l-lazy-loading.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; This file contains calls to functions that are not 9 | ;; yet loaded by default (see laurisp.el) 10 | ;; all these functions will be overwritten by the loaded ones 11 | ;; 12 | 13 | 14 | ;; 15 | ;; Load essential libs for coding 16 | ;; 17 | ;;;###autoload 18 | (defun prepare-ide () 19 | (interactive) 20 | (message "loading flycheck...") 21 | (global-flycheck-mode) 22 | (message "loading company...") 23 | (global-company-mode) 24 | (message "loading yasnippets...") 25 | (add-to-list 'yas-snippet-dirs "~/laurisp/snippets") 26 | (yas-global-mode 1) 27 | (message "running exec path from shell...") 28 | (exec-path-from-shell-initialize) 29 | (load-lib 'launguage-server-protocol) 30 | (load-lib 'sqlau) 31 | (message "emacs IDE is ready")) 32 | 33 | (spacemacs/set-leader-keys 34 | "@" 'prepare-ide) 35 | 36 | 37 | 38 | ;; 39 | ;; laurg 40 | ;; 41 | 42 | ;;;###autoload 43 | (bind-lazy-function 'org-jira-copy-current-issue-url 'laurg-jira-copy-current-issue-url 'laurg) 44 | 45 | ;; 46 | ;; ramda docs 47 | ;; 48 | 49 | ;;;###autoload 50 | (defun open-ramda-docs () 51 | (interactive) 52 | (call-lazy-function 'open-ramda-docs 'ramda-docs)) 53 | 54 | 55 | ;; 56 | ;; spotilau 57 | ;; 58 | 59 | (defun spotify-status () 60 | (interactive) 61 | (call-lazy-function 'spotify-status 'spotilau)) 62 | 63 | (defun spotify-helper () 64 | (interactive) 65 | (call-lazy-function 'spotify-helper 'spotilau)) 66 | 67 | -------------------------------------------------------------------------------- /test/buttercup-helpers.elc: -------------------------------------------------------------------------------- 1 | ;ELC 2 | ;;; Compiled 3 | ;;; in Emacs version 27.1 4 | ;;; with all optimizations. 5 | 6 | ;;; This file uses dynamic docstrings, first added in Emacs 19.29. 7 | 8 | ;;; This file does not contain utf-8 non-ASCII characters, 9 | ;;; and so can be loaded in Emacs versions earlier than 23. 10 | 11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 13 | 14 | 15 | #@30 search for file and loads it 16 | (defalias 'load-test-file #[(file-name) "\301\302\303\304\305P\"\"\207" [file-name mapcar load directory-files-recursively "." ".el"] 6 (#$ . 408)]) 17 | #@50 the same as describe, but with defun indentation 18 | (defalias 'test-suite '(macro . #[(description &rest body) "\302 BB\207" [description body describe] 3 (#$ . 593)])) 19 | (byte-code "\300\301\302\303#\300\207" [function-put test-suite lisp-indent-function defun] 4) 20 | #@69 the same as describe, but more idiomatic and with defun indentation 21 | (defalias 'context '(macro . #[(description &rest body) "\302\303\304E BB\207" [description body describe concat "when "] 4 (#$ . 861)])) 22 | (byte-code "\300\301\302\303#\300\207" [function-put context lisp-indent-function defun] 4) 23 | #@44 the same as it, but with defun indentation 24 | (defalias 'it-should '(macro . #[(description &rest body) "\302\303\304E BB\207" [description body it concat "should "] 4 (#$ . 1166)])) 25 | (byte-code "\300\301\302\303#\304\305!\207" [function-put it-should lisp-indent-function defun provide buttercup-helpers] 4) 26 | -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/laurisp-package.snippet: -------------------------------------------------------------------------------- 1 | # -*- mode: emacs-lisp-mode -*- 2 | # name: New laurisp package 3 | # key: laurisp-package 4 | # -- 5 | 6 | 7 | ;;; `(setq this-file-name (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`.el --- ${1:`(setq this-package-name (capitalize (replace-regexp-in-string "-" " " this-file-name)))`} -*- lexical-binding: t; -*- 8 | 9 | ;; Copyright (C) ${20:2021} ${21:Laura Viglioni} 10 | 11 | ;; Author: ${30:Laura Viglioni} <${31:viglionilaura@gmail.com}> 12 | ;; Maintainer: ${40:Laura Viglioni} <${41:viglionilaura@gmail.com}> 13 | ;; Created: ${50:`(format-time-string "%d %b %Y")`} 14 | ;; Keywords: ${60:keywods} 15 | ;; URL: ${70:`(concat "https://github.com/Viglioni/laurisp/tree/main/personal-libs/" this-file-name)`} 16 | ;; Version: ${80: 0.0.1} 17 | ;; Package-Requires: ((emacs "24.1")) 18 | 19 | ;; This file is not part of GNU Emacs. 20 | 21 | ;; This file is free software; you can redistribute it and/or modify 22 | ;; it under the terms of the GNU General Public License as published by 23 | ;; the Free Software Foundation; either version 3, or (at your option) 24 | ;; any later version. 25 | ;; 26 | ;; This program is distributed in the hope that it will be useful, 27 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29 | ;; GNU General Public License for more details. 30 | ;; 31 | 32 | ;;; Commentary: 33 | ;; ${90: comentary} 34 | 35 | ;;; Code: 36 | 37 | $0 38 | 39 | (provide '`this-file-name`) 40 | ;;; `this-file-name`.el ends here 41 | 42 | -------------------------------------------------------------------------------- /personal-libs/functional/test/buttercup-helpers.elc: -------------------------------------------------------------------------------- 1 | ;ELC 2 | ;;; Compiled 3 | ;;; in Emacs version 27.1 4 | ;;; with all optimizations. 5 | 6 | ;;; This file uses dynamic docstrings, first added in Emacs 19.29. 7 | 8 | ;;; This file does not contain utf-8 non-ASCII characters, 9 | ;;; and so can be loaded in Emacs versions earlier than 23. 10 | 11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 13 | 14 | 15 | #@30 search for file and loads it 16 | (defalias 'load-test-file #[(file-name) "\301\302\303\304\305P\"\"\207" [file-name mapcar load directory-files-recursively "." ".el"] 6 (#$ . 408)]) 17 | #@50 the same as describe, but with defun indentation 18 | (defalias 'test-suite '(macro . #[(description &rest body) "\302 BB\207" [description body describe] 3 (#$ . 593)])) 19 | (byte-code "\300\301\302\303#\300\207" [function-put test-suite lisp-indent-function defun] 4) 20 | #@69 the same as describe, but more idiomatic and with defun indentation 21 | (defalias 'context '(macro . #[(description &rest body) "\302\303\304E BB\207" [description body describe concat "when "] 4 (#$ . 861)])) 22 | (byte-code "\300\301\302\303#\300\207" [function-put context lisp-indent-function defun] 4) 23 | #@44 the same as it, but with defun indentation 24 | (defalias 'it-should '(macro . #[(description &rest body) "\302\303\304E BB\207" [description body it concat "should "] 4 (#$ . 1166)])) 25 | (byte-code "\300\301\302\303#\304\305!\207" [function-put it-should lisp-indent-function defun provide buttercup-helpers] 4) 26 | -------------------------------------------------------------------------------- /config/l-projectile.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; projectile related functions 9 | ;; 10 | 11 | (eval-after-load "projectile" 12 | (lambda () 13 | (progn 14 | 15 | (setq projectile-globally-ignored-directories 16 | '( 17 | ".cask" 18 | ".eldev" 19 | ".git" 20 | ".log" 21 | ".next" 22 | ".nyc_output" 23 | ".pub-cache" 24 | ".rush" 25 | ".svn" 26 | ".vscode" 27 | "android" 28 | "bundle*" 29 | "coverage" 30 | "dist" 31 | "dist-*" 32 | "ios" 33 | "node_modules" 34 | "out" 35 | "repl" 36 | "rush" 37 | "target" 38 | "temp" 39 | "venv" 40 | "webnext/common" 41 | )) 42 | 43 | (setq projectile-globally-ignored-files 44 | '( 45 | "*-lock.json" 46 | "*.chunk.*" 47 | "*.gz" 48 | "*.jar" 49 | "*.log" 50 | "*.png" 51 | "*.pyc" 52 | "*.tar.gz" 53 | "*.tgz" 54 | "*.zip" 55 | ".DS_Store" 56 | ".lein-repl-history" 57 | ".packages" 58 | )) 59 | 60 | (setq projectile-project-search-path 61 | '("~/Loft/" "~/Personal/" "~/Loft/webnext/apps")) 62 | 63 | ))) 64 | 65 | -------------------------------------------------------------------------------- /personal-libs/buttercup-helpers/buttercup-helpers.elc: -------------------------------------------------------------------------------- 1 | ;ELC 2 | ;;; Compiled 3 | ;;; in Emacs version 27.2.50 4 | ;;; with all optimizations. 5 | 6 | ;;; This file uses dynamic docstrings, first added in Emacs 19.29. 7 | 8 | ;;; This file does not contain utf-8 non-ASCII characters, 9 | ;;; and so can be loaded in Emacs versions earlier than 23. 10 | 11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 13 | 14 | 15 | (message "loading buttercup-helpers...") 16 | #@30 search for file and loads it 17 | (defalias 'load-test-file #[(file-name) "\301\302\303\304\305P\"\"\207" [file-name mapcar load directory-files-recursively "." ".el"] 6 (#$ . 452)]) 18 | #@50 the same as describe, but with defun indentation 19 | (defalias 'test-suite '(macro . #[(description &rest body) "\302 BB\207" [description body describe] 3 (#$ . 637)])) 20 | (byte-code "\300\301\302\303#\300\207" [function-put test-suite lisp-indent-function defun] 4) 21 | #@69 the same as describe, but more idiomatic and with defun indentation 22 | (defalias 'context '(macro . #[(description &rest body) "\302\303\304E BB\207" [description body describe concat "when "] 4 (#$ . 905)])) 23 | (byte-code "\300\301\302\303#\300\207" [function-put context lisp-indent-function defun] 4) 24 | #@44 the same as it, but with defun indentation 25 | (defalias 'it-should '(macro . #[(description &rest body) "\302\303\304E BB\207" [description body it concat "should "] 4 (#$ . 1210)])) 26 | (byte-code "\300\301\302\303#\304\305!\207" [function-put it-should lisp-indent-function defun provide buttercup-helpers] 4) 27 | -------------------------------------------------------------------------------- /lazy-files/org-headers-skeletons.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; Headers for org-mode 9 | ;; 10 | 11 | ;;;###autoload 12 | (defmacro create-skeleton (skeleton-name doc &rest body) 13 | (declare (indent defun)) 14 | `(let ((formated-lines (quote ,(seq-map (lambda (line) (concat line "\n")) body)))) 15 | (eval (seq-concatenate 'list 16 | '(define-skeleton ,skeleton-name ,doc "") 17 | formated-lines)))) 18 | 19 | 20 | ;;;###autoload 21 | (create-skeleton org-haskell-notebook-header 22 | "header for haskell notebooks" 23 | "#+Title:" 24 | "#+startup: fold") 25 | 26 | (create-skeleton org-clojure-notebook-header 27 | "header for clojure notebooks" 28 | "#+Title:" 29 | "#+startup: fold") 30 | 31 | 32 | (create-skeleton org-beamer-presentations-header 33 | "header for beamer presentations" 34 | "#+title:" 35 | "#+date:" 36 | "#+author:" 37 | "#+email:" 38 | "#+language:" 39 | "#+select_tags: export" 40 | "#+exclude_tags: noexport" 41 | "#+startup: beamer" 42 | "#+LaTeX_CLASS: beamer" 43 | "#+LaTeX_CLASS_OPTIONS: [bigger]" 44 | "#+beamer_theme: metropolis" 45 | "#+options: tex:t toc:nil H:2") 46 | 47 | (create-skeleton org-latex-article-header 48 | "header for articles" 49 | "#+title:" 50 | "#+author:" 51 | "#+date:" 52 | "#+language: en" 53 | "#+latex_compiler:" 54 | "#+OPTIONS: tex:t toc:nil todo:nil" 55 | "#+STARTUP: nolatexpreview fold" 56 | "#+EXCLUDE_TAGS: noexport" 57 | "#+latex_class: article" 58 | "#+latex_class_options: [a4paper,12pt]") 59 | 60 | 61 | 62 | (provide 'org-headers-skeletons) 63 | 64 | ;; 65 | ;; warnings 66 | ;; 67 | 68 | ;; org-headers-skeletons.el:30:1:Error: Wrong type argument: sequencep, %s 69 | 70 | -------------------------------------------------------------------------------- /lazy-files/org-headers-skeletons.elc: -------------------------------------------------------------------------------- 1 | ;ELC 2 | ;;; Compiled 3 | ;;; in Emacs version 27.2.50 4 | ;;; with all optimizations. 5 | 6 | ;;; This file uses dynamic docstrings, first added in Emacs 19.29. 7 | 8 | ;;; This file does not contain utf-8 non-ASCII characters, 9 | ;;; and so can be loaded in Emacs versions earlier than 23. 10 | 11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 13 | 14 | 15 | (defalias 'create-skeleton '(macro . #[(skeleton-name doc &rest body) "\303\304\305\306\307\"DDC\310\311\312\305\313 \n\314BBBD\315BBBDE\207" [body skeleton-name doc let formated-lines quote seq-map #[(line) "\301P\207" [line "\n"] 2] eval seq-concatenate 'list define-skeleton ("") (formated-lines)] 10])) 16 | (byte-code "\301\302\303\304#\305\306\307\310\311#!\210)\312\306\307\310\313#!\210)\314\306\307\310\315#!\210)\316\306\307\310\317#!\210)\320\321!\207" [formated-lines function-put create-skeleton lisp-indent-function defun ("#+Title:\n" "#+startup: fold\n") eval seq-concatenate list (define-skeleton org-haskell-notebook-header "header for haskell notebooks" . #1=("")) ("#+Title:\n" "#+startup: fold\n") (define-skeleton org-clojure-notebook-header "header for clojure notebooks" . #1#) ("#+title:\n" "#+date:\n" "#+author:\n" "#+email:\n" "#+language:\n" "#+select_tags: export\n" "#+exclude_tags: noexport\n" "#+startup: beamer\n" "#+LaTeX_CLASS: beamer\n" "#+LaTeX_CLASS_OPTIONS: [bigger]\n" "#+beamer_theme: metropolis\n" "#+options: tex:t toc:nil H:2\n") (define-skeleton org-beamer-presentations-header "header for beamer presentations" . #1#) ("#+title:\n" "#+author:\n" "#+date:\n" "#+language: en\n" "#+latex_compiler:\n" "#+OPTIONS: tex:t toc:nil todo:nil\n" "#+STARTUP: nolatexpreview fold\n" "#+EXCLUDE_TAGS: noexport\n" "#+latex_class: article\n" "#+latex_class_options: [a4paper,12pt]\n") (define-skeleton org-latex-article-header "header for articles" . #1#) provide org-headers-skeletons] 6) 17 | -------------------------------------------------------------------------------- /config/org-mode-extra-configs.org: -------------------------------------------------------------------------------- 1 | #+title: Some org extra configs 2 | #+author: Laura Viglioni 3 | 4 | 5 | *This file is GPL-3.0* 6 | 7 | 8 | * About 9 | This file must be initialized with ~org-babel-lob-ingest~. Check [[./l-org-latex-pdf.el][this config file]]. 10 | 11 | * Org-babel 12 | ** Post execution formatters 13 | Executes these functions using ~:post~ to format the output of codeblocks. 14 | *** Haskell 15 | #+name: org-babel-haskell-formatter 16 | #+begin_src emacs-lisp :var strr="" :exports code 17 | (format "%s" (replace-regexp-in-string 18 | (rx line-start 19 | (and (* (| alphanumeric "|" ">" blank)) 20 | (and (* blank) (+ alphanumeric) (| "|" ">")))) 21 | "" (format "%s" strr))) 22 | #+end_src 23 | 24 | #+RESULTS: org-babel-haskell-formatter 25 | 26 | **** testing 27 | #+begin_src emacs-lisp :exports both :post org-babel-haskell-formatter(*this*) 28 | "Prelude> Prelude| Prelude| Prelude| Prelude| Prelude| Prelude| Prelude| Prelude| Prelude| Prelude| Prelude| Prelude> Prelude> 1.0 + 2.0i" 29 | #+end_src 30 | 31 | #+RESULTS: 32 | : 1.0 + 2.0i 33 | 34 | #+begin_src emacs-lisp :exports both :post org-babel-haskell-formatter(*this*) 35 | "Prelude> 1.0 - 2.0i" 36 | #+end_src 37 | 38 | #+RESULTS: 39 | : 1.0 - 2.0i 40 | 41 | #+begin_src emacs-lisp :exports both :post org-babel-haskell-formatter(*this*) 42 | "Prelude| Prelude| Prelude| Prelude| Prelude| Prelude| [1.0 + 0.0i,0.5 + 0.0i,0.5 + 0.5i]" 43 | #+end_src 44 | 45 | #+RESULTS: 46 | : [1.0 + 0.0i,0.5 + 0.0i,0.5 + 0.5i] 47 | 48 | *** Clojure 49 | #+name: org-babel-clojure-formatter 50 | #+begin_src emacs-lisp :var strr="" :exports code 51 | (format "%s" (replace-regexp-in-string 52 | (rx line-start (+ (| alphanumeric "." blank)) (and ">" (+ blank))) 53 | "" (format "%s" strr))) 54 | #+end_src 55 | 56 | #+RESULTS: org-babel-clojure-formatter 57 | 58 | -------------------------------------------------------------------------------- /personal-libs/make-scripts/make-scripts.el: -------------------------------------------------------------------------------- 1 | ;;; make-scripts.el --- Make Scripts -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2021 Laura Viglioni 4 | 5 | ;; Author: Laura Viglioni 6 | ;; Maintainer: Laura Viglioni 7 | ;; Created: 28 Aug 2021 8 | ;; Keywords: keywods 9 | ;; URL: https://github.com/Viglioni/laurisp/tree/main/personal-libs/make-scripts 10 | ;; Version: 0.0.1 11 | ;; Package-Requires: ((emacs "24.1")) 12 | 13 | ;; This file is not part of GNU Emacs. 14 | 15 | ;; This file is free software; you can redistribute it and/or modify 16 | ;; it under the terms of the GNU General Public License as published by 17 | ;; the Free Software Foundation; either version 3, or (at your option) 18 | ;; any later version. 19 | ;; 20 | ;; This program is distributed in the hope that it will be useful, 21 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | ;; GNU General Public License for more details. 24 | ;; 25 | 26 | ;;; Commentary: 27 | ;; comentary 28 | 29 | ;;; Code: 30 | 31 | (load-lib 'laurisp-core) 32 | (load-lib 'functional) 33 | (load-lib 'lang-scripts) 34 | (require 'helm) 35 | (require 'helm-make) 36 | 37 | (defun MS--makefile-path (&optional local) 38 | (join-path (if local "." (projectile-project-root)) "Makefile")) 39 | 40 | ;;;###autoload 41 | (defun MS--has-makefile? (&optional local) 42 | "Returns if there is a makefile in the project root dir 43 | if local is t, it will check on local dir 44 | (bool) -> bool" 45 | (file-exists-p (MS--makefile-path local))) 46 | 47 | 48 | (defun MS--candidates (&optional local) 49 | (helm--make-target-list-qp (MS--makefile-path local))) 50 | 51 | 52 | 53 | ;;;###autoload 54 | (defun make-scripts:run-command (&optional local) 55 | (interactive) 56 | (throw-unless (MS--has-makefile? local) "No makefile was found") 57 | (helm 58 | :prompt "Choose command to exec: " 59 | :sources (helm-build-sync-source "Avaliable scripts from your makefile" 60 | :candidates (MS--candidates) 61 | :action (lambda (cmd) (lang-scripts:run-script 62 | (concat "make " cmd) 63 | (when local ".")))))) 64 | 65 | 66 | (provide 'make-scripts) 67 | ;;; make-scripts.el ends here 68 | 69 | -------------------------------------------------------------------------------- /laurisp.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | 8 | ;; 9 | ;; Constants 10 | ;; 11 | (setq personal-lib-dir "~/laurisp/personal-libs/") 12 | (setq external-libs-dir "~/laurisp/external") 13 | (setq laurisp-config-dir "~/laurisp/config") 14 | (setq private-files-dir "~/private-files/emacs-files") 15 | (setq lazy-files-dir "~/laurisp/lazy-files") 16 | 17 | ;; 18 | ;; add lib dirs to load path 19 | ;; 20 | 21 | (let ((default-directory personal-lib-dir)) 22 | (normal-top-level-add-subdirs-to-load-path)) 23 | 24 | (let ((default-directory external-libs-dir)) 25 | (normal-top-level-add-subdirs-to-load-path)) 26 | 27 | (add-to-list 'load-path private-files-dir) 28 | (add-to-list 'load-path lazy-files-dir) 29 | 30 | ;; 31 | ;; requires 32 | ;; 33 | 34 | (require 'functional) 35 | (require 'laurisp-core) 36 | 37 | 38 | 39 | ;; 40 | ;; import files functions 41 | ;; 42 | 43 | ;;;###autoload 44 | (defun import-laurisp-files (dir) 45 | "import all laurisp files from a dir" 46 | (let* ((path (concat "~/laurisp/" dir)) 47 | (all-files (directory-files path t "^l-[a-z\\-].*\\.el$")) 48 | (loaded-files (mapcar (lambda (laurisp-file) 49 | (load laurisp-file nil nil)) 50 | all-files))) 51 | (if (seq-reduce (lambda (acc val) (and acc val)) loaded-files t) 52 | "laurisp files loaded!" 53 | "an error has ocurred"))) 54 | 55 | ;;;###autoload 56 | (defmacro load-lib (lib-name) 57 | "requires a lib in external or personal lib dir. Usage example: 58 | (load-lib 'emacs-grammarly)" 59 | `(require ,lib-name)) 60 | 61 | ;;;###autoloading 62 | (defmacro bind-lazy-function (func-name lib-func-name package-name) 63 | "Creates an interactive of a lib that is not imported by default 64 | that loads it when is called 65 | Usage example: 66 | (bind-lazy-function 'spotify-func 'spotify-status 'spotilau) 67 | (global-set-key (kbd \"M-p M-p\") 'spotify-func)" 68 | `(defun ,(eval func-name) () 69 | (interactive) 70 | (load-lib ,package-name) 71 | (call-interactively ,lib-func-name))) 72 | 73 | 74 | ;;;###autoload 75 | (defmacro call-lazy-function (func-name package-name) 76 | "Calls a function from a lib that is not imported by default" 77 | `(progn 78 | (load-lib ,package-name) 79 | (call-interactively ,func-name))) 80 | 81 | 82 | ;; 83 | ;; Importing files 84 | ;; 85 | 86 | (import-laurisp-files "config") 87 | 88 | (provide 'laurisp) 89 | 90 | -------------------------------------------------------------------------------- /personal-libs/laurisp-core/l-shell.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020 4 | ;; GNU Public License 3.0 5 | ;; 6 | ;;(require 'functional) 7 | ;; (require 'l-string) 8 | ;; (require 'l-general) 9 | 10 | ;; 11 | ;; bash related functions 12 | ;; 13 | 14 | ;;;###autoload 15 | (defun gen-uuid-to-clipboard () 16 | "generates uuid and copies it to clipboard" 17 | (interactive) 18 | (let ((uuid (uuidgen-4))) 19 | (kill-new uuid) 20 | (message (format "copied %s to clipboard" uuid)) 21 | uuid)) 22 | 23 | ;;;###autoload 24 | (defun insert-uuid () 25 | "inserts random uuid" 26 | (interactive) 27 | (insert (uuidgen-4))) 28 | 29 | ;;;###autoload 30 | (defun lpwd (&optional dir) 31 | "returns only the pwd path" 32 | (expand-file-name (or dir "."))) 33 | 34 | ;;;###autoload 35 | (defun ls (&optional dir) 36 | "list files in directory" 37 | (throw-if (and dir (not (file-directory-p dir))) (concat dir " does not exist!")) 38 | (directory-files (or dir "."))) 39 | 40 | ;;;###autoload 41 | (defun touch (filename &optional dir) 42 | "Creates a empty file if it does not exists, returns the file or nil" 43 | (throw-if (any-nil? filename) "filename is nil") 44 | (let* ((path (lpwd dir)) 45 | (file (join-path path filename))) 46 | (if (file-exists-p file) 47 | (progn (print "file already exists") nil) 48 | (progn (write-region "" "" file) file)))) 49 | 50 | ;;;###autoload 51 | (defun echo-into (filename text) 52 | "echoes text into file" 53 | (throw-if (any-nil? filename text) "filename or text is nil") 54 | (throw-if (not (file-exists-p filename)) "filename does not exist!") 55 | (write-region text "" filename) t) 56 | 57 | ;;;###autoload 58 | (defun count-non-empty-lines (file) 59 | (throw-if (any-nil? file) "file is nil") 60 | (fp/pipe file 61 | ((get-string-from-file) 62 | (funcall (lambda (string) (split-string string "\n"))) 63 | (seq-filter (lambda (line) (not (equal 0 (string-match-p "^ *$" line))))) 64 | (length)))) 65 | 66 | ;;;###autoload 67 | (defun count-all-laurisp-lines () 68 | (interactive) 69 | (let* ((files-regexp (rx (| (and line-start 70 | (| "l" "test") 71 | (+ (any "-" letter)) 72 | ".el" 73 | line-end) 74 | (and line-start 75 | (+ (any "-" letter)) 76 | ".snippet" 77 | line-end)))) 78 | (files (directory-files-recursively "~/laurisp" files-regexp t)) 79 | (lines (mapcar 'count-non-empty-lines files))) 80 | (print (apply '+ lines)))) 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /personal-libs/json-utils/json-utils.el: -------------------------------------------------------------------------------- 1 | ;;; json-utils.el --- Json Helpers -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2010-2021 Your Name 4 | 5 | ;; Author: Your Name 6 | ;; Maintainer: Someone Else 7 | ;; Created: 14 Jul 2010 8 | ;; Keywords: languages 9 | ;; URL: https://example.com/foo 10 | ;; Version: 0.0.1 11 | ;; Package-Requires: ((emacs "24.1") (json "1.4") (projectile "2.4.0-snapshot")) 12 | 13 | ;; This file is not part of GNU Emacs. 14 | 15 | ;; This file is free software 16 | 17 | 18 | ;;; Commentary: 19 | ;; This package. 20 | 21 | ;;; Code: 22 | 23 | (require 'json) 24 | (require 'projectile) 25 | (require 'laurisp-core) 26 | 27 | (message "loading json-utils...") 28 | 29 | ;;;###autoload 30 | (defun json-utils-get-package-json () 31 | "Gets package.json on the root of the project." 32 | (let ((json-file (join-path (or (projectile-project-root) ".") "package.json"))) 33 | (throw-unless (file-exists-p json-file) "package.json not found!") 34 | json-file)) 35 | 36 | (setq asdasd "'{\"createLeadResponse\":{\"status\":\"duplicated\",\"offerType\":\"NO_OFFER\",\"cdpId\":null,\"duplicatedLeads\":[{\"addTime\":\"29/05/2020 11:00:21\",\"contactName\":\"Vinicius\",\"contactType\":\"owner\",\"crmId\":null,\"organizationName\":null}]},\"contactType\":\"affiliated-agent\"}'") 37 | 38 | 39 | (defun json-utils--text-width (text) 40 | "get the size of the biggest line" 41 | (fp/pipe text 42 | ((fp/split "\n") 43 | (mapcar 'length) 44 | (apply 'max)))) 45 | 46 | ;TODO: create buffer-window-utils!! 47 | ;;;###autoload 48 | (defun json-utils--set-window-width (text current-win) 49 | "(str window) -> bool 50 | Set window width the size of the largest line plus 5" 51 | (let ((width (+ 5 (json-utils--text-width text)))) 52 | (window-resize current-win (- width (window-width current-win)) t))) 53 | 54 | (defvar json-utils--buffer-name "*prettified-json*") 55 | 56 | 57 | ;;;###autoload 58 | (defun json-utils-print-from-selection () 59 | "Prints a prettified json selected" 60 | (interactive) 61 | (throw-unless (use-region-p) "No region selected!") 62 | (let* ((selected-text (buffer-substring-no-properties (region-beginning) (region-end))) 63 | (parsed-json (shell-command-to-string (concat "jq <<< '" selected-text "'"))) 64 | (buff (get-buffer-create json-utils--buffer-name)) 65 | (win (display-buffer-in-side-window buff '((side . right) 66 | (display-buffer-mark-dedicated . t))))) 67 | (json-utils--set-window-width parsed-json win) 68 | (with-current-buffer json-utils--buffer-name 69 | (erase-buffer) 70 | (insert parsed-json) 71 | (funcall 'json-mode)))) 72 | 73 | (provide 'json-utils) 74 | ;;; json-utils.el ends here 75 | 76 | 77 | -------------------------------------------------------------------------------- /personal-libs/ramda-docs/ramda-docs.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | 8 | (require 'request) 9 | (message "loading ramda-docs...") 10 | 11 | ;; 12 | ;; ramda-docs related functions 13 | ;; 14 | 15 | (defvar ramda-html nil) 16 | (setq ramda-docs-url "https://ramdajs.com/docs/") 17 | 18 | ;;;###autoload 19 | (defun download-ramda-html () 20 | (message "fetching ramda data...") 21 | (unless ramda-html 22 | (request ramda-docs-url 23 | :sync t 24 | :success (cl-function 25 | (lambda (&key data &allow-other-keys) (setq ramda-html data))) 26 | :error (cl-function 27 | (lambda (&key error-thrown &allow-other-keys&rest _) 28 | (error "Got error: %S" error-thrown)))))) 29 | 30 | ;;;###autoload 31 | (defun function-info (html-line) 32 | (let* ((filtered-string 33 | (fp/pipe html-line 34 | ((replace-regexp-in-string 35 | (rx (or "data-name" "data-category" "=" "\"" ">")) 36 | "") 37 | ((lambda (str) (split-string str " ")))))) 38 | (fn-name (head filtered-string)) 39 | (fn-category (nth 1 filtered-string))) 40 | (cons (format "(%s) %s" fn-category fn-name) fn-name))) 41 | 42 | ;;;###autoload 43 | (defun parse-funcs-html (html) 44 | (regex-matches "data-name=\"[[:alpha:]_]*\" data-category=\"[[:alpha:]]*\"" html)) 45 | 46 | ;;;###autoload 47 | (defun helm-ramda-candidates () 48 | (throw-if (any-nil? ramda-html) "ramda's page wasn't downloaded!") 49 | (fp/pipe ramda-html 50 | ((parse-funcs-html) 51 | (mapcar 'function-info) 52 | (alist-sort-by-cdr-ci)))) 53 | 54 | ;;;###autoload 55 | (defun open-ramda-doc-url (fn-name) 56 | (browse-url (concat ramda-docs-url "#" fn-name))) 57 | 58 | 59 | ;;;###autoload 60 | (defun open-ramda-docs () 61 | (interactive) 62 | (download-ramda-html) 63 | (helm :prompt "Choose function: " 64 | :sources (helm-build-sync-source "ramda functions" 65 | :candidates 'helm-ramda-candidates 66 | :action 'open-ramda-doc-url))) 67 | 68 | 69 | (provide 'ramda-docs) 70 | 71 | ;; 72 | ;; warnings 73 | ;; 74 | 75 | ;; Entering directory ‘/Users/laura.viglioni/laurisp/personal-libs/ramda-docs/’ 76 | ;; ramda-docs.el:16:7:Warning: assignment to free variable ‘ramda-docs-url’ 77 | 78 | ;; In download-ramda-html: 79 | ;; ramda-docs.el:21:14:Warning: reference to free variable ‘ramda-docs-url’ 80 | 81 | ;; In function-info: 82 | ;; ramda-docs.el:36:23:Warning: function ‘reduce’ from cl package called at 83 | ;; runtime 84 | 85 | ;; In helm-ramda-candidates: 86 | ;; ramda-docs.el:47:23:Warning: function ‘reduce’ from cl package called at 87 | ;; runtime 88 | 89 | ;; In open-ramda-doc-url: 90 | ;; ramda-docs.el:55:23:Warning: reference to free variable ‘ramda-docs-url’ 91 | 92 | 93 | -------------------------------------------------------------------------------- /config/l-files.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; files related functions 9 | ;; 10 | 11 | (load-lib 'org-headers-skeletons) 12 | 13 | ;; 14 | ;; opening files 15 | ;; 16 | 17 | ;;;###autoload 18 | (defun open-spacemacs-config () 19 | "opens .spacemacs file" 20 | (interactive) 21 | (find-file "~/.spacemacs")) 22 | 23 | ;;;###autoload 24 | (defun open-skhd-config () 25 | "opens .skhdrc file" 26 | (interactive) 27 | (find-file "~/.skhdrc")) 28 | 29 | ;;;###autoload 30 | (defun open-yabai-config () 31 | "opens .yabairc file" 32 | (interactive) 33 | (find-file "~/.yabairc")) 34 | 35 | ;;;###autoload 36 | (defun open-zsh-config () 37 | "opens .zshrc file" 38 | (interactive) 39 | (find-file "~/.zshrc")) 40 | 41 | ;;;###autoload 42 | (defun open-laurisp () 43 | "opens laurisp.el file" 44 | (interactive) 45 | (find-file "~/laurisp/laurisp.el")) 46 | 47 | ;; 48 | ;; creating files 49 | ;; 50 | 51 | ;;;###autoload 52 | (defun new-laurisp-file (name dir) 53 | "create laurisp file" 54 | (interactive "sInsert filename: \nDWhere? ") 55 | (let* ((filename (concat "l-" name ".el")) 56 | (file (touch filename dir))) 57 | (echo-into file (format ";;\n;; @author Laura Viglioni\n;; 2021\n;; GNU Public License 3.0\n;;\n\n;;\n;; %s related functions\n;;\n\n" name)) 58 | (find-file file))) 59 | 60 | 61 | (create-skeleton lib-readme 62 | " To run tests and compiling this project uses [[https://github.com/doublep/eldev][eldev]]." 63 | "" 64 | "* Testing" 65 | "To run tests we use [[https://github.com/jorgenschaefer/emacs-buttercup/][buttercup]] and some macros defined in ~~/test/buttercup-helpers~, check out [[https://github.com/Viglioni/laurisp/tree/main/personal-libs/buttercup-helpers][buttercup-helpers repo]]." 66 | "*** To run tests" 67 | " In the root of this project:" 68 | " #+begin_src shell" 69 | " $ eldev test" 70 | " #+end_src" 71 | "* Compiling" 72 | "*** To compile" 73 | " In the root of this project:" 74 | " #+begin_src shell" 75 | " $ eldev compile" 76 | " #+end_src") 77 | 78 | 79 | ;;;###autoload 80 | (defun new-laurisp-lib (lib-name) 81 | (interactive "sInsert lib name: ") 82 | (let* ((dir (join-path personal-lib-dir lib-name)) 83 | (test-dir (join-path dir "test"))) 84 | (make-directory dir) 85 | (make-directory test-dir) 86 | (let ((file-name (touch (concat lib-name ".el") dir)) 87 | (readme (touch "README.org" dir)) 88 | (eldev (touch "Eldev" dir)) 89 | (test-file (touch (concat lib-name "-test.el") test-dir))) 90 | (echo-into file-name "laurisp-package") 91 | (echo-into readme (concat "* " lib-name)) 92 | (echo-into eldev "(eldev-use-package-archive 'melpa)\n;(eldev-use-local-dependency \"\")") 93 | (echo-into test-file (format ";;; %s-test.el --- test suite -*- lexical-binding: t -*-" lib-name)) 94 | (find-file file-name) 95 | (end-of-line) 96 | (yas-expand)))) 97 | 98 | 99 | -------------------------------------------------------------------------------- /personal-libs/laurisp-core/l-string.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; string related functions 9 | ;; 10 | 11 | ;;(require 'functional) 12 | ;;(require 'l-general) 13 | 14 | ;;;###autoload 15 | (defun join-path (path filename) 16 | "concat path and file. Adds '/' to the end of the path if necessary" 17 | (throw-if (any-nil? path filename) "path or filename is nil") 18 | (concat path (if (string-match-p "/$" path) "" "/") filename)) 19 | 20 | ;;;###autoload 21 | (defun file-extension (filename extension) 22 | "returns filename.extension" 23 | (throw-if (any-nil? filename extension) "filename or extension is nil") 24 | (concat filename "." extension)) 25 | 26 | ;;;###autoload 27 | (defun regex-matches (regexp string &optional pos matches) 28 | "Returns a list of matches" 29 | (throw-if (any-nil? regexp string) "regexp or string is nil") 30 | (save-match-data 31 | (let ((pos 0) 32 | matches) 33 | (while (string-match regexp string pos) 34 | (push (match-string 0 string) matches) 35 | (setq pos (match-end 0))) 36 | matches))) 37 | 38 | 39 | ;;;###autoload 40 | (defun get-string-from-file (filepath) 41 | "Return filepath's file content in a string" 42 | (throw-if (any-nil? filepath) "filepath is nil") 43 | (throw-if (not (file-exists-p filepath)) "file does not exists") 44 | (with-temp-buffer 45 | (insert-file-contents filepath) 46 | (buffer-string))) 47 | 48 | ;;;###autoload 49 | (defun remove-suffix (file-name) 50 | "remove suffix of file-name" 51 | (throw-if (any-nil? file-name) "file-name is nil") 52 | (replace-regexp-in-string "\\.[a-z]*$" "" file-name)) 53 | 54 | ;;;###autoload 55 | (defun go-to-fst-empty-line () 56 | "search the first empty line in buffer and go to it" 57 | (beginning-of-buffer) ;; TODO use ‘(goto-char (point-min))’ instead. 58 | (search-forward-regexp "^$")) 59 | 60 | ;;;###autoload 61 | (defun insert-on-fst-empty-line (text current-pos) 62 | "inserts text on the first empty line of the buffer and 63 | return the cursor to its position" 64 | (throw-if (any-nil? text current-pos) "text or current-pos is nil") 65 | (let* ((empty-line-pos (progn (go-to-fst-empty-line) (point))) 66 | (is-after? (> current-pos empty-line-pos)) 67 | (return-pos (if is-after? 68 | (+ current-pos (length text)) 69 | current-pos))) 70 | (insert text) 71 | (goto-char return-pos) 72 | t)) 73 | 74 | (defun fp/insert-on-fst-empty-line (text) 75 | "inserts text on the first empty line of the buffer and 76 | return the cursor to its position" 77 | (throw-unless (bool text) "text is nil") 78 | (save-excursion 79 | (go-to-fst-empty-line) 80 | (insert (concat text "\n")))) 81 | 82 | 83 | ;;;###autoload 84 | (defun fp/split (separator text) 85 | "(str str) -> [str] 86 | Split a string using the given separator" 87 | (split-string text separator)) 88 | 89 | ;;;###autoload 90 | (defun fp/is-empty? (obj) 91 | "returns if list or string is empty 92 | (list | str) -> bool" 93 | (or (equal "" obj) (equal nil obj))) 94 | 95 | -------------------------------------------------------------------------------- /personal-libs/spotilau/spotilau.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; lazy-spotify related functions 9 | ;; 10 | 11 | (message "loading spotilau...") 12 | 13 | ;;;###autoload 14 | (defun spotify-share-song () 15 | (let* ((cmd-ret (shell-command-to-string "spotify share url")) 16 | (url (replace-regexp-in-string "Spotify URL: " "" cmd-ret))) 17 | (kill-new url) 18 | (print "Url is copied into your clipboard"))) 19 | 20 | ;;;###autoload 21 | (defun kill-spotify-buffer (buffer-name) 22 | (if (get-buffer buffer-name) (kill-buffer buffer-name))) 23 | 24 | ;;;###autoload 25 | (defun get-spotify-status () 26 | (shell-command-to-string "spotify status")) 27 | 28 | ;;;###autoload 29 | (defun get-spotify-vol () 30 | (shell-command-to-string "spotify vol")) 31 | 32 | ;;;###autoload 33 | (defun spotify-volume-down () 34 | (shell-command-to-string "spotify vol down")) 35 | 36 | ;;;###autoload 37 | (defun spotify-volume-up () 38 | (shell-command-to-string "spotify vol up")) 39 | 40 | ;;;###autoload 41 | (defun insert-spotify-buffer-content (buffer-name status vol) 42 | (let ((inhibit-read-only t) 43 | (status-formatted (compose-and-call 44 | ((replace-regexp-in-string "Artist" "\nArtist") 45 | (replace-regexp-in-string "Position: .*\n" "")) 46 | status))) 47 | (with-current-buffer 48 | buffer-name 49 | (erase-buffer) 50 | (insert (concat status-formatted "\n" vol))))) 51 | 52 | ;;;###autoload 53 | (defun spotify-helper (x) 54 | (interactive "k(t) Play/Pause; (n) Next; (p) Previous; (/) Search; (s) Share; (u) Vol Up; (d) Vol Down; (any) Quit helper" ) 55 | (if (cond 56 | ((equal x "u") (spotify-volume-up)) 57 | ((equal x "d") (spotify-volume-down)) 58 | ((equal x "t") (spotify-playpause)) 59 | ((equal x "n") (spotify-next)) 60 | ((equal x "p") (spotify-previous)) 61 | ((equal x "/") (helm-spotify-plus)) 62 | ((equal x "s") (spotify-share-song) nil)) 63 | (if (get-buffer "spotify-status") 64 | (call-interactively 'spotify-status) 65 | (call-interactively 'spotify-helper)) 66 | (kill-spotify-buffer "spotify-status"))) 67 | 68 | ;;;###autoload 69 | (defun show-spotify-status () 70 | (message "getting spotify info...") 71 | (let* ((buffer-name "spotify-status") 72 | (status (get-spotify-status)) 73 | (vol (get-spotify-vol))) 74 | (if (not (get-buffer buffer-name)) (get-buffer-create buffer-name)) 75 | (display-buffer-in-side-window (get-buffer buffer-name) display-buffer-alist) 76 | (select-window (get-buffer-window buffer-name)) 77 | (insert-spotify-buffer-content buffer-name status vol) 78 | (toggle-read-only))) 79 | 80 | ;;;###autoload 81 | (defun spotify-status () 82 | (interactive) 83 | (show-spotify-status) 84 | (call-interactively 'spotify-helper)) 85 | 86 | (provide 'spotilau) 87 | 88 | 89 | ;; 90 | ;; warnings 91 | ;; 92 | 93 | ;; In insert-spotify-buffer-content: 94 | ;; spotilau.el:40:28:Warning: function ‘reduce’ from cl package called at runtime 95 | 96 | ;; In show-spotify-status: 97 | ;; spotilau.el:75:6:Warning: ‘toggle-read-only’ is an obsolete function (as of 24.3); use ‘read-only-mode’ instead. 98 | 99 | 100 | -------------------------------------------------------------------------------- /config/l-js-ts.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | 8 | ;; 9 | ;; js/ts related functions 10 | ;; 11 | 12 | 13 | ;; 14 | ;; Definitions 15 | ;; 16 | 17 | (setq js-indent-level 2) 18 | (setq typescript-indent-level 2) 19 | 20 | (bind-lazy-function 'rename-this-file 'lsp-ts-rename-file 'launguage-server-protocol) 21 | (bind-lazy-function 'explain-error-at-point 'lsp-explain-error-at-point 'launguage-server-protocol) 22 | (bind-lazy-function 'find-ramda-docs 'open-ramda-docs 'ramda-docs) 23 | 24 | ;; 25 | ;; rjsx extra configs 26 | ;; 27 | 28 | (add-to-list 'auto-mode-alist '("\\.js.*$" . rjsx-mode)) 29 | (add-to-list 'auto-mode-alist '("\\.json$" . json-mode)) 30 | 31 | ;; 32 | ;; web-mode 33 | ;; 34 | 35 | (with-eval-after-load "web-mode" 36 | ;;New prefixes for commands 37 | (spacemacs/declare-prefix-for-mode 'typescript-tsx-mode "me" "errors") 38 | (spacemacs/declare-prefix-for-mode 'typescript-tsx-mode "mf" "format") 39 | (spacemacs/declare-prefix-for-mode 'typescript-tsx-mode "mi" "HTML tags") 40 | (spacemacs/declare-prefix-for-mode 'typescript-tsx-mode "mb" "Fold/Unfold tags") 41 | (spacemacs/declare-prefix-for-mode 'typescript-tsx-mode "mn" "npm scripts") 42 | (spacemacs/set-leader-keys-for-major-mode 'typescript-tsx-mode 43 | ;;web mode feats 44 | "ii" 'web-mode-element-insert-at-point 45 | "iv" 'web-mode-element-vanish 46 | "ik" 'web-mode-element-kill 47 | "is" 'web-mode-element-select 48 | "iw" 'web-mode-element-wrap 49 | "ir" 'web-mode-element-rename 50 | "ic" 'web-mode-element-clone 51 | "i/" 'web-mode-element-close 52 | "ib" 'web-mode-element-beginning 53 | "ie" 'web-mode-element-end 54 | "bf" 'web-mode-fold-or-unfold 55 | "bc" 'web-mode-element-children-fold-or-unfold 56 | "." 'spacemacs/web-transient-state/body 57 | ;;format 58 | "fo" 'lsp-organize-imports 59 | "f=" 'lsp-format-buffer 60 | "==" 'lsp-format-buffer 61 | ;;rename 62 | "rf" 'rename-this-file 63 | ;;errors 64 | "ep" 'explain-error-at-point 65 | "en" 'flycheck-next-error 66 | ;;docs 67 | "dr" 'find-ramda-docs 68 | ;; npm 69 | ;; "nr" npm-choose-and-run 70 | ;; "no" npm-open-active-buffer 71 | ;; "nh" npm-hide-buffer 72 | )) 73 | 74 | ;; 75 | ;;typescript-mode 76 | ;; 77 | 78 | 79 | (with-eval-after-load "typescript-mode" 80 | (load-lib 'ts-repl) 81 | ;;New prefixes for commands 82 | (spacemacs/declare-prefix-for-mode 'typescript-mode "me" "errors") 83 | (spacemacs/declare-prefix-for-mode 'typescript-mode "mf" "format") 84 | (spacemacs/declare-prefix-for-mode 'typescript-mode "mn" "npm scripts") 85 | (spacemacs/declare-prefix-for-mode 'typescript-mode "ms" "repl") 86 | (spacemacs/set-leader-keys-for-major-mode 'typescript-mode 87 | ;;format 88 | "fo" 'lsp-organize-imports 89 | "f=" 'lsp-format-buffer 90 | "==" 'lsp-format-buffer 91 | ;;rename 92 | "rf" 'rename-this-file 93 | ;;errors 94 | "ep" 'explain-error-at-point 95 | "en" 'flycheck-next-error 96 | ;; docs 97 | "dr" 'find-ramda-docs 98 | ;; npm 99 | ;; "nr" npm-choose-and-run 100 | ;; "no" npm-open-active-buffer 101 | ;; "nh" npm-hide-buffer 102 | ;; repl 103 | ;; "sc" 'run-ts 104 | ;; "se" 'ts-send-last-sexp 105 | ;; "sb" 'ts-send-buffer 106 | "sb" 'ts-repl-exec-ts-buffer 107 | "se" 'ts-repl-send-last-sexp 108 | "C-x C-e" 'ts-repl-send-last-sexp 109 | )) 110 | -------------------------------------------------------------------------------- /personal-libs/functional/functional-autoloads.el: -------------------------------------------------------------------------------- 1 | ;;; functional-autoloads.el --- automatically extracted autoloads 2 | ;; 3 | ;;; Code: 4 | 5 | (add-to-list 'load-path (directory-file-name 6 | (or (file-name-directory #$) (car load-path)))) 7 | 8 | 9 | ;;;### (autoloads nil "functional" "functional.el" (0 0 0 0)) 10 | ;;; Generated autoloads from functional.el 11 | 12 | (autoload 'fp/curry "functional" "\ 13 | Returns the curried function. 14 | ((* -> x) arg1, ..., argN) -> ((argN+1, ..., argM) -> x) 15 | e.g.: 16 | (fp/curry + 1 2 3) -> (lambda (argN ... argM) (+ 1 2 3 argN ... argM)) 17 | 18 | \(fn FN &rest INITIAL-ARGS)" nil t) 19 | 20 | (autoload 'fp/pipe "functional" "\ 21 | Pipe an argument into composed functions from left to right. 22 | a -> ((a -> b) (b -> c) ... (n -> m)) -> m 23 | e.g.: 24 | (fp/pipe 5 ((+ 1) (* 2))) -> 12 25 | 26 | \(fn ARG FN-LIST)" nil t) 27 | 28 | (function-put 'fp/pipe 'lisp-indent-function 'defun) 29 | 30 | (autoload 'compose-and-call "functional" "\ 31 | Since compose returns a function, this helper receives a list of 32 | functions and args and apply them to composed funcs 33 | (a ... n) -> ((y -> z) ... (m -> o) ((a ... n) -> m) ) -> z 34 | e.g.: 35 | (compose-and-call ((+ 1) (* 2)) 2 3) -> 13 36 | 37 | \(fn FN-LIST &rest ARGS)" nil t) 38 | 39 | (autoload 'bool "functional" "\ 40 | returns t if element is truthy, nil if its falsey 41 | a -> bool 42 | 43 | \(fn X)" nil nil) 44 | 45 | (autoload 'n-and "functional" "\ 46 | Not and. 47 | * -> bool 48 | 49 | \(fn &rest ARGS)" nil nil) 50 | 51 | (autoload 'n-or "functional" "\ 52 | Not or. 53 | * -> bool 54 | 55 | \(fn &rest ARGS)" nil nil) 56 | 57 | (autoload 'all "functional" "\ 58 | Returns t if all elements in list are truthy 59 | [a] → Boolean 60 | 61 | \(fn LST)" nil nil) 62 | 63 | (autoload 'any "functional" "\ 64 | Returns t if at least one element in list is truthy 65 | [a] → Boolean 66 | 67 | \(fn LST)" nil nil) 68 | 69 | (autoload 'contains\? "functional" "\ 70 | Returns t/nil if element is in list 71 | ([a] a) -> bool 72 | 73 | \(fn LIST ELEMENT)" nil nil) 74 | 75 | (autoload 'head "functional" "\ 76 | Returns the first element of a list 77 | [a] -> a | nil 78 | 79 | \(fn LIST)" nil nil) 80 | 81 | (autoload 'not-contains\? "functional" "\ 82 | Returns t/nil if element is not in list 83 | ([a] a) -> bool 84 | 85 | \(fn LIST ELEMENT)" nil nil) 86 | 87 | (autoload 'tail "functional" "\ 88 | Returns the list but its first element 89 | [a] -> [a] | nil 90 | 91 | \(fn LIST)" nil nil) 92 | 93 | (autoload 'unzip "functional" "\ 94 | unzip n lists 95 | [[a]] -> [[a]] 96 | e.g.: 97 | (unzip '((1 2 ... n) (1 2 ... n))) -> 98 | '((1 1 ... 1) (2 2 .... 2) ... (n n ... n) 99 | 100 | \(fn ZIPPED-LIST)" nil nil) 101 | 102 | (autoload 'zip "functional" "\ 103 | zips n lists 104 | [[a]] -> [[a]] 105 | e.g.: 106 | (zip '(1 1) '(2 2) '(3 3)) -> '((1 2 3) (1 2 3)) 107 | 108 | \(fn &rest LISTS)" nil nil) 109 | 110 | (autoload 'inc "functional" "\ 111 | Returns the increment of n 112 | Number -> Number 113 | 114 | \(fn N)" nil nil) 115 | 116 | (autoload 'all-nil\? "functional" "\ 117 | return if all args are nil 118 | (* ... *) -> boolean 119 | e.g (all-nil? nil nil) -> t 120 | 121 | \(fn &rest ARGS)" nil nil) 122 | 123 | (autoload 'fp/alist-sort-by-car "functional" "\ 124 | 125 | 126 | \(fn ALIST)" nil nil) 127 | 128 | (autoload 'alist-sort-by-cdr-ci "functional" "\ 129 | sort alist by cdr. case insensitive 130 | 131 | \(fn ALIST)" nil nil) 132 | 133 | (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "functional" '("any-nil?" "compose" "curry-expr" "identity"))) 134 | 135 | ;;;*** 136 | 137 | ;; Local Variables: 138 | ;; version-control: never 139 | ;; no-byte-compile: t 140 | ;; no-update-autoloads: t 141 | ;; coding: utf-8 142 | ;; End: 143 | ;;; functional-autoloads.el ends here 144 | -------------------------------------------------------------------------------- /personal-libs/launguage-server-protocol/launguage-server-protocol.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | (message "loading launguage-server-protocol...") 8 | 9 | ;; 10 | ;; explain error at point 11 | ;; 12 | 13 | (setq LauSP--error-buffer "LauSP-error-at-point") 14 | 15 | ;;;###autoload 16 | (defun LauSP--kill-error-buffer (key) 17 | (interactive "k") 18 | (if (get-buffer LauSP--error-buffer) 19 | (kill-buffer LauSP--error-buffer))) 20 | 21 | ;;;###autoload 22 | (defun LauSP--config-error-buffer (msg) 23 | (let* ((max-text-width 100) 24 | (total-margin (- (window-text-width) max-text-width)) 25 | (margin-lateral (/ total-margin 2)) 26 | (min-lines (+ 4 (ceiling (/ (length msg) (min max-text-width (window-text-width)))))) 27 | (actual-height (window-body-height))) 28 | (if (> total-margin 0) 29 | (progn (setq left-margin-width margin-lateral) 30 | (setq right-margin-width margin-lateral) 31 | (set-window-buffer (selected-window) (current-buffer)))) 32 | (enlarge-window (- min-lines actual-height)) 33 | (read-only-mode) 34 | (visual-line-mode))) 35 | 36 | ;;;###autoload 37 | (defun lsp-explain-error-at-point () 38 | (interactive) 39 | (let ((err (flycheck-overlay-errors-at (point)))) 40 | (if err 41 | (let* ((msg (head (mapcar 'flycheck-error-message err))) 42 | (buff-name (get-buffer-create LauSP--error-buffer)) 43 | (error-buff (get-buffer buff-name))) 44 | (display-buffer-in-side-window error-buff '((side . bottom))) 45 | (switch-to-buffer-other-window error-buff) 46 | (erase-buffer) 47 | (insert (concat "\n" msg)) 48 | (LauSP--config-error-buffer msg) 49 | (call-interactively 'LauSP--kill-error-buffer))) 50 | (error "No error at point"))) 51 | 52 | 53 | ;; 54 | ;; Typescript/Javascript 55 | ;; 56 | 57 | ;;;###autoload 58 | (defun lsp-ts-rename-file () 59 | "Rename current file and all it's references in other files." 60 | (interactive) 61 | (let* ((name (buffer-name)) 62 | (old (buffer-file-name)) 63 | (basename (file-name-nondirectory old))) 64 | (unless (and old (file-exists-p old)) 65 | (error "Buffer '%s' is not visiting a file." name)) 66 | (let ((new (read-file-name "New name: " (file-name-directory old) basename nil basename))) 67 | (when (get-file-buffer new) 68 | (error "A buffer named '%s' already exists." new)) 69 | (when (file-exists-p new) 70 | (error "A file named '%s' already exists." new)) 71 | (lsp--send-execute-command 72 | "_typescript.applyRenameFile" 73 | (vector (list :sourceUri (lsp--buffer-uri) 74 | :targetUri (lsp--path-to-uri new)))) 75 | (mkdir (file-name-directory new) t) 76 | (rename-file old new) 77 | (rename-buffer new) 78 | (set-visited-file-name new) 79 | (set-buffer-modified-p nil) 80 | (lsp-disconnect) 81 | (setq-local lsp-buffer-uri nil) 82 | (lsp) 83 | (lsp--info "Renamed '%s' to '%s'." name (file-name-nondirectory new))))) 84 | 85 | 86 | (provide 'launguage-server-protocol) 87 | 88 | 89 | ;; 90 | ;; compilation warnings 91 | ;; 92 | 93 | 94 | ;; launguage-server-protocol.el:14:7:Warning: assignment to free variable 95 | ;; ‘LauSP--error-buffer’ 96 | 97 | ;; In LauSP--kill-error-buffer: 98 | ;; launguage-server-protocol.el:19:19:Warning: reference to free variable 99 | ;; ‘LauSP--error-buffer’ 100 | 101 | ;; In lsp-explain-error-at-point: 102 | ;; launguage-server-protocol.el:43:46:Warning: reference to free variable 103 | ;; ‘LauSP--error-buffer’ 104 | 105 | ;; In lsp-ts-rename-file: 106 | ;; launguage-server-protocol.el:82:19:Warning: assignment to free variable 107 | ;; ‘lsp-buffer-uri’ 108 | 109 | ;; In end of data: 110 | ;; launguage-server-protocol.el:88:1:Warning: the following functions are not known to be defined: 111 | ;; lsp--send-execute-command, lsp--buffer-uri, lsp--path-to-uri, 112 | ;; lsp-disconnect, lsp--info 113 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | * About 2 | These are all my elisp files, functions and config, except for the [[https://github.com/Viglioni/spacemacs/blob/master/.spacemacs][.spacemacs]] file. 3 | More general config instructions about how to use my spacemacs repo, which this repo is a submodule of, you can find at [[https://github.com/Viglioni/spacemacs/blob/master/README.md][here]]. 4 | 5 | |----------------+-----------------------------------------------------------| 6 | | Files and dirs | brief description | 7 | |----------------+-----------------------------------------------------------| 8 | | configs/ | Has all the main config I use, bindings, hooks etc | 9 | | external/ | External libs I installed manually | 10 | | laurisp.el | Loads all my files, all of them have the form ~l-*.el~ | 11 | | lazy-files/ | These files here are loaded only when they are necessary | 12 | | personal-libs/ | My own libs | 13 | | snippets/ | All the snippets and snippets hierarchy I created/defined | 14 | | test/ | Well this one is easy, right? | 15 | |----------------+-----------------------------------------------------------| 16 | 17 | External libs: 18 | |---------------------------+--------------------------------------------------------------| 19 | | Lib name | Brief description | 20 | |---------------------------+--------------------------------------------------------------| 21 | | buttercup-helpers | Some macros to use in elisp tests | 22 | | functional | A lib with some common FP functions, like comopse etc | 23 | | json-utils | Functions related to json handling | 24 | | lang-scripts | Base lib to run scripts on dedicated buff (e.g. npm-scripts) | 25 | | launguage-server-protocol | Functions about LSP | 26 | | laurg | Functions related to org-mode | 27 | | laurisp-core | My core functions that I use in my other libs | 28 | | lautex | Functions related to LaTeX (and org-mode) | 29 | | npm-scripts | Functions to run scripts defined in the package.json | 30 | | ramda-docs | Fetches ramda functions by name and link docs | 31 | | spotilau | Shows a menu with some spotify info | 32 | | sqlau | SQL related functions | 33 | | ts-repl | A "repl" for typescript | 34 | |---------------------------+--------------------------------------------------------------| 35 | 36 | Only ~functional~, ~core~ and ~config~ are loaded at start. All the other libs will be loaded as they are needed. 37 | 38 | The ~config~ files assume the existence of three private files not shown in this repo: 39 | #+begin_src shell :exports both 40 | ~/private-files/emacs-files/env-private.el 41 | ~/private-files/emacs-files/sql-private.el 42 | ~/private-files/emacs-files/slack-private.el 43 | 44 | #+end_src 45 | * Testing 46 | To run tests we use [[https://github.com/jorgenschaefer/emacs-buttercup/][buttercup]] and [[https://github.com/cask/cask][cask]]. 47 | 48 | In the root of this project: 49 | 50 | *** To install buttercup dependencies 51 | #+begin_src shell 52 | $ cask install 53 | #+end_src 54 | 55 | *** To run tests 56 | #+begin_src shell 57 | $ cask exec buttercup 58 | #+end_src 59 | 60 | *** Important 61 | - The test files and way it is being tested are being changed, some tests are not working right now 62 | - This commands runs only the tests in ~test/~ dir, the personal libs tests have their own 63 | * Licence 64 | This project is free and it will always be. 65 | 66 | [[https://www.gnu.org/licenses/gpl-3.0.en.html][GPL-3]] 67 | 68 | -------------------------------------------------------------------------------- /personal-libs/laurg/laurg.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; org related functions 9 | ;; 10 | 11 | (require 'helm) 12 | (message "loading laurg...") 13 | 14 | ;; 15 | ;; Insert custom headers 16 | ;; 17 | 18 | 19 | ;;;###autoload 20 | (defun laurg--insert-custom-header (header-func) 21 | (save-excursion 22 | (beginning-of-buffer) 23 | (funcall (eval header-func)))) 24 | 25 | (setq laurg--helm-insert-custom-headers-srcs 26 | (helm-build-sync-source "Avaliable headers:" 27 | :candidates '(("haskell notebook" . 'org-haskell-notebook-header) 28 | ("beamer presentation" . 'org-beamer-presentations-header) 29 | ("latex articles" . 'org-latex-article-header)) 30 | :action 'laurg--insert-custom-header)) 31 | 32 | ;;;###autoload 33 | (defun laurg-insert-custom-headers () 34 | (interactive) 35 | (throw-unless (derived-mode-p 'org-mode) "Not in org-mode!") 36 | (load-lib 'org-headers-skeletons) 37 | (helm :prompt "Choose a header: " 38 | :sources laurg--helm-insert-custom-headers-srcs)) 39 | 40 | 41 | ;; 42 | ;; Insert source on org-mode 43 | ;; 44 | 45 | ;;;###autoload 46 | (defun laurg--insert-src-with-post (src-name &optional post-func) 47 | (let ((post (if post-func (concat ":post " post-func "(*this*)") ""))) 48 | (insert (concat "#+begin_src " src-name " :exports both :results output" post 49 | "\n\n" 50 | "#+end_src")))) 51 | 52 | ;;;###autoload 53 | (defun laurg--insert-src (src-name) 54 | (cond 55 | ((string= "haskell" src-name) (laurg--insert-src-with-post src-name "org-babel-haskell-formatter")) 56 | ((string= "clojure" src-name) (laurg--insert-src-with-post src-name "org-babel-clojure-formatter")) 57 | (t (laurg--insert-src-with-post src-name)))) 58 | 59 | (setq laurg--helm-lang-sources 60 | (helm-build-sync-source "Language name" 61 | :candidates '(lambda () (mapcar 'car org-babel-load-languages)) 62 | :action 'laurg--insert-src)) 63 | 64 | (setq laurg--helm-lang-sources-fallback 65 | (helm-build-dummy-source "Language name" 66 | :action 'laurg--insert-src)) 67 | 68 | ;;;###autoload 69 | (defun laurg-insert-org-source () 70 | (interactive) 71 | (if (eq 'org-mode major-mode) 72 | (progn 73 | (helm 74 | :history t 75 | :volatile nil 76 | :sources '(laurg--helm-lang-sources laurg--helm-lang-sources-fallback)) 77 | (org-edit-special) 78 | (previous-line) 79 | (spacemacs/indent-region-or-buffer)))) 80 | 81 | ;; 82 | ;; org jira 83 | ;; 84 | 85 | ;;;###autoload 86 | (defun laurg-jira-copy-current-issue-url () 87 | (interactive) 88 | (let* ((issue-key (org-jira-get-from-org 'issue 'key)) 89 | (issue-url (concat jiralib-url "/browse/" issue-key))) 90 | (kill-new issue-url) 91 | (message (concat "copied " issue-url)) 92 | issue-url)) 93 | 94 | 95 | (provide 'laurg) 96 | 97 | ;; 98 | ;; warnings 99 | ;; 100 | 101 | ;; In insert-custom-header: 102 | ;; laurg.el:23:30:Warning: ‘beginning-of-buffer’ is for interactive use only; use 103 | ;; ‘(goto-char (point-min))’ instead. 104 | ;; laurg.el:28:7:Warning: assignment to free variable 105 | ;; ‘laurg--helm-insert-custom-headers-srcs’ 106 | 107 | ;; In org-insert-custom-headers: 108 | ;; laurg.el:41:18:Warning: reference to free variable 109 | ;; ‘laurg--helm-insert-custom-headers-srcs’ 110 | ;; laurg.el:60:7:Warning: assignment to free variable ‘laurg--helm-lang-sources’ 111 | ;; laurg.el:65:7:Warning: assignment to free variable ‘laurg--helm-lang-sources-fallback’ 112 | 113 | ;; In insert-org-source: 114 | ;; laurg.el:78:10:Warning: ‘previous-line’ is for interactive use only; use 115 | ;; ‘forward-line’ with negative argument instead. 116 | 117 | ;; In define-org-cmd: 118 | ;; laurg.el:110:27:Warning: function ‘oddp’ from cl package called at runtime 119 | 120 | ;; In end of data: 121 | ;; laurg.el:118:1:Warning: the following functions are not known to be defined: org-edit-special, 122 | ;; org-jira-get-from-org 123 | -------------------------------------------------------------------------------- /config/l-global.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; global related functions 9 | ;; 10 | 11 | 12 | ;; 13 | ;; LSP 14 | ;; 15 | 16 | (setq lsp-idle-delay 0.5) 17 | (setq gc-cons-threshold 200000000) 18 | (setq lsp-auto-guess-root t) 19 | 20 | ;; (advice-add 'lsp :before (lambda (&rest _args) (eval '(setf (lsp-session-server-id->folders (lsp-session)) (ht))))) 21 | 22 | ;; (advice-remove #'lsp #'(lambda (&rest _args) (eval '(setf (lsp-session-server-id->folders (lsp-session)) (ht))))) 23 | ;; (advice--p (advice--symbol-function 'lsp)) 24 | 25 | 26 | ;; 27 | ;; flycheck 28 | ;; 29 | (with-eval-after-load "flycheck" 30 | (global-flycheck-mode)) 31 | ;;(add-hook 'after-init-hook #'global-flycheck-mode) 32 | 33 | ;; 34 | ;; company-mode 35 | ;; 36 | (with-eval-after-load "company" 37 | (global-company-mode)) 38 | 39 | ;; 40 | ;; shell 41 | ;; 42 | 43 | (load-lib 'env-private) 44 | (setq sh-indentation 2) 45 | 46 | ;; open dotfiles with sh-mode 47 | (add-to-list 'auto-mode-alist '("/\\.[a-zA-Z0-09]*rc$" . sh-mode)) 48 | (add-to-list 'auto-mode-alist '("/\[a-zA-Z0-09]*rc$" . sh-mode)) 49 | 50 | ;; 51 | ;; yasnippets 52 | ;; 53 | (with-eval-after-load "yasnippet" 54 | (add-to-list 'yas-snippet-dirs "~/laurisp/snippets") 55 | (yas-global-mode 1)) 56 | 57 | 58 | ;; 59 | ;; helm set jeys 60 | ;; 61 | 62 | (global-set-key (kbd " ") 'helm-M-x) 63 | 64 | ;; 65 | ;; code-block set keys 66 | ;; 67 | 68 | (with-eval-after-load "hideshow" 69 | (which-key-add-key-based-replacements "C-c b" "code-blocks") 70 | (global-set-key (kbd "C-c b t") 'hs-toggle-hiding) 71 | (global-set-key (kbd "C-c b l") 'hs-hide-level) 72 | (global-set-key (kbd "C-c b H") 'hs-hide-all) 73 | (global-set-key (kbd "C-c b S") 'hs-show-all) 74 | (global-set-key (kbd "C-c b s") 'hs-show-block) 75 | (global-set-key (kbd "C-c b h") 'hs-hide-block)) 76 | 77 | ;; 78 | ;; window set keys 79 | ;; 80 | 81 | ;; walk through windows 82 | (global-set-key (kbd "C-x ") 'evil-window-up) 83 | (global-set-key (kbd "C-x ") 'evil-window-down) 84 | (global-set-key (kbd "C-x ") 'evil-window-left) 85 | (global-set-key (kbd "C-x ") 'evil-window-right) 86 | 87 | ;; resize windows 88 | (global-set-key (kbd "C-c C-") 'enlarge-window-horizontally) 89 | (global-set-key (kbd "C-c C-") 'shrink-window-horizontally) 90 | (global-set-key (kbd "C-c C-") 'enlarge-window) 91 | (global-set-key (kbd "C-c C-") 'shrink-window) 92 | 93 | 94 | 95 | 96 | ;; 97 | ;; language scripts 98 | ;; 99 | 100 | (bind-lazy-function 'npm-choose-and-run 'npm-scripts:choose-and-run 'npm-scripts) 101 | (bind-lazy-function 'hide-script-buffer 'lang-scripts:hide-buffer 'lang-scripts) 102 | (bind-lazy-function 'open-script-buffer 'lang-scripts:open-active-buffer 'lang-scripts) 103 | (bind-lazy-function 'go-to-script-buffer 'lang-scripts:go-to-buffer 'lang-scripts) 104 | (bind-lazy-function 'import-default-lib 'npm-scripts:import-default-lib 'npm-scripts) 105 | (bind-lazy-function 'npm-install-lib 'npm-scripts:install 'npm-scripts) 106 | (bind-lazy-function 'npm-install-dev-lib 'npm-scripts:install-dev 'npm-scripts) 107 | (bind-lazy-function 'run-make-cmd 'make-scripts:run-command 'make-scripts) 108 | 109 | (which-key-add-key-based-replacements " " "language scripts") 110 | ;; Common commands 111 | (which-key-add-key-based-replacements " " "common commands") 112 | (global-set-key (kbd " h") 'hide-script-buffer) 113 | (global-set-key (kbd " o") 'open-script-buffer) 114 | (global-set-key (kbd " g") 'go-to-script-buffer) 115 | ;; NPM scripts 116 | (which-key-add-key-based-replacements " n" "npm scripts") 117 | (global-set-key (kbd " n r") 'npm-choose-and-run) 118 | (global-set-key (kbd " n i") 'import-default-lib) 119 | (global-set-key (kbd " n l") 'npm-install-lib) 120 | (global-set-key (kbd " n d") 'npm-install-dev-lib) 121 | ;; MAKE scripts 122 | (which-key-add-key-based-replacements " m" "makefile scripts") 123 | (global-set-key (kbd " m r") 'run-make-cmd) 124 | 125 | -------------------------------------------------------------------------------- /test/core/test-shell.el: -------------------------------------------------------------------------------- 1 | ;; -*- lexical-binding: t -*- 2 | (load "./tests/buttercup-helpers.elc") 3 | (load "./src/l-shell") 4 | (add-to-list 'load-path "../") 5 | 6 | (test-suite "#lpwd" 7 | (before-each (spy-on 'expand-file-name)) 8 | (context "dir is passed" 9 | (it-should "return its path" 10 | (lpwd "some dir") 11 | (expect 'expand-file-name :to-have-been-called-with "some dir"))) 12 | (context "dir is not passed" 13 | (it-should "return . path" 14 | (lpwd) 15 | (expect 'expand-file-name :to-have-been-called-with ".")))) 16 | 17 | 18 | (test-suite "#ls" 19 | (before-each 20 | (spy-on 'directory-files)) 21 | (context "a valid dir is passed" 22 | (before-each (spy-on 'file-directory-p :and-return-value t)) 23 | (it-should "return its path" 24 | (ls "some dir") 25 | (expect 'directory-files :to-have-been-called-with "some dir"))) 26 | (context "an invalid dir is passed" 27 | (before-each (spy-on 'file-directory-p :and-return-value nil)) 28 | (it-should "return its path" 29 | (expect (ls "some dir") :to-throw))) 30 | (context "dir is not passed" 31 | (it-should "return . path" 32 | (ls) 33 | (expect 'directory-files :to-have-been-called-with ".")))) 34 | 35 | (test-suite "#touch" 36 | (context "filename is nil" 37 | (it-should "throw error" 38 | (expect (touch) :to-throw))) 39 | (context "file exists" 40 | (before-each 41 | (spy-on 'print) 42 | (spy-on 'file-exists-p :and-return-value t)) 43 | (it-should "print message and return nil" 44 | (expect (touch "existent-file") :to-be nil) 45 | (expect 'print :to-have-been-called-with "file already exists"))) 46 | (context "file does not exist" 47 | :var ((expected "path/file")) 48 | (before-each 49 | (spy-on 'lpwd :and-return-value "path/") 50 | (spy-on 'write-region) 51 | (spy-on 'file-exists-p :and-return-value nil)) 52 | (it-should "create file and return filepath" 53 | (expect (touch "file") :to-equal expected) 54 | (expect 'write-region :to-have-been-called-with "" "" expected)))) 55 | 56 | (test-suite "#echo-into" 57 | (context "filename or text is nil" 58 | (it-should "throw error" 59 | (expect (filename) :to-throw) 60 | (expect (filename nil "text") :to-throw) 61 | (expect (filename "file" nil) :to-throw))) 62 | (context "file does not exist" 63 | (before-each (spy-on 'file-exists-p :and-return-value nil)) 64 | (it-should "throw" 65 | (expect (echo-into) :to-throw ))) 66 | (context "file exists" 67 | :var ((filename "filename") 68 | (text "text")) 69 | (before-each (spy-on 'file-exists-p :and-return-value t) 70 | (spy-on 'write-region)) 71 | (it-should "write on file and return t" 72 | (expect (echo-into filename text) :to-be t ) 73 | (expect 'write-region :to-have-been-called-with text "" filename)))) 74 | 75 | (test-suite "#count-non-empty-lines" 76 | (context "file is nil" 77 | (it-should "throw error" 78 | (expect (count-non-empty-lines) :to-throw ))) 79 | (context "file exists" 80 | (before-each 81 | (spy-on 'get-string-from-file 82 | :and-return-value "line1\n\nline2\nline3\n \nline4\n\n\n\n")) 83 | (it-should "return the correct number of non-empty lines" 84 | (expect (count-non-empty-lines "file") :to-be 4)))) 85 | 86 | (test-suite "#count-all-laurisp-lines" 87 | :var ((files-regexp (rx (| (and line-start 88 | (| "l" "test") 89 | (+ (any "-" letter)) 90 | ".el" 91 | line-end) 92 | (and line-start 93 | (+ (any "-" letter)) 94 | ".snippet" 95 | line-end))))) 96 | (before-each (spy-on 'directory-files-recursively :and-return-value '(1 2 3 4)) 97 | (spy-on 'count-non-empty-lines :and-call-fake 'identity)) 98 | (it-should "count the number of non-empty line of this project" 99 | (expect (count-all-laurisp-lines) :to-be 10) 100 | (expect 'directory-files-recursively 101 | :to-have-been-called-with "~/laurisp" files-regexp t))) 102 | -------------------------------------------------------------------------------- /personal-libs/sqlau/sqlau.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | (message "loading sqlau...") 8 | 9 | ;; 10 | ;; add postgres/mysql dbs to lsp and emacs 11 | ;; 12 | 13 | ;; Variables related to sql configs 14 | (setq lsp-sqls-connections nil) 15 | (setq sql-connection-alist nil) 16 | 17 | ;;;###autoload 18 | (defun format-postgres-sqls (host port user password db) 19 | (format "host=%s port=%s user=%s password=%s dbname=%s" 20 | host port user password db)) 21 | 22 | ;;;###autoload 23 | (defun format-mysql-sqls (host port user password db) 24 | (format "%s:%s@tcp(%s:%s)/%s" user password host port db)) 25 | 26 | ;;;###autoload 27 | (defun format-postgres-uri (host port user password db) 28 | (format "postgresql://%s:%s@%s:%s/%s" user password host port db)) 29 | 30 | 31 | ;;;###autoload 32 | (defun add-to-sqls-connections (db-type data-src-name) 33 | (add-to-list 'lsp-sqls-connections 34 | (list (cons 'driver db-type) 35 | (cons 'dataSourceName data-src-name)))) 36 | 37 | ;;;###autoload 38 | (defmacro add-to-sql-conection-alist (db-type name host port user password db) 39 | `(add-to-list 'sql-connection-alist 40 | (list (quote ,name) 41 | (list 'sql-product (quote ,db-type)) 42 | (list 'sql-user ,user) 43 | (list 'sql-server ,host) 44 | (list 'sql-port ,port) 45 | (list 'sql-password ,password) 46 | (list 'sql-database ,db)))) 47 | 48 | ;;;###autoload 49 | (defmacro sql-add-postgres-db (name &rest db-info) 50 | "Adds a mysql database to emacs and lsp 51 | This macro expects a name to the database and a p-list of parameters 52 | :port, :user, :password, :database, :host 53 | The only optional is :port, its default value is 5432 54 | e.g.: 55 | (sql-add-postgres-db 56 | my-db-name ;; notice that there are no quotes here 57 | :port 1234 58 | :user \"username\" 59 | :host \"my-host\" 60 | :database \"my-db\" 61 | :password \"mypassword\")" 62 | `(let ((port (or ,(plist-get db-info :port) 5432)) 63 | (user ,(plist-get db-info :user)) 64 | (password ,(plist-get db-info :password)) 65 | (host ,(plist-get db-info :host)) 66 | (db ,(plist-get db-info :database))) 67 | (throw-if (any-nil? user password host db (quote ,name)) "there are info missing!") 68 | (let ((full-uri (format-postgres-uri host port user password db)) 69 | (data-src-name (format-postgres-sqls host port user password db))) 70 | (add-to-sqls-connections "postgresql" data-src-name) 71 | (add-to-sql-conection-alist 'postgres ,name host port user password full-uri)))) 72 | 73 | ;;;###autoload 74 | (defmacro sql-add-mysql-db (name &rest db-info) 75 | "Adds a mysql database to emacs and lsp 76 | This macro expects a name to the database and a p-list of parameters 77 | :port, :user, :password, :database, :host 78 | The only optional is :port, its default value is 3306 79 | e.g.: 80 | (sql-add-mysql-db 81 | my-db-name ;; notice that there are no quotes here 82 | :port 1234 83 | :user \"username\" 84 | :host \"my-host\" 85 | :database \"my-db\" 86 | :password \"mypassword\")" 87 | `(let ((port (or ,(plist-get db-info :port) 3306)) 88 | (user ,(plist-get db-info :user)) 89 | (password ,(plist-get db-info :password)) 90 | (host ,(plist-get db-info :host)) 91 | (db ,(plist-get db-info :database))) 92 | (throw-if (any-nil? user password host db (quote ,name)) "there are info missing!") 93 | (add-to-sqls-connections "mysql" (format-mysql-sqls host port user password db)) 94 | (add-to-sql-conection-alist 'mysql ,name host port user password db))) 95 | 96 | (provide 'sqlau) 97 | 98 | ;; 99 | ;; warnings 100 | ;; 101 | 102 | ;; sqlau.el:16:7:Warning: assignment to free variable ‘lsp-sqls-connections’ 103 | ;; sqlau.el:17:7:Warning: assignment to free variable ‘sql-connection-alist’ 104 | 105 | ;; In add-to-sqls-connections: 106 | ;; sqlau.el:35:17:Warning: reference to free variable ‘lsp-sqls-connections’ 107 | ;; sqlau.el:35:17:Warning: assignment to free variable ‘lsp-sqls-connections’ 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /external/hs-lint/hs-lint.el: -------------------------------------------------------------------------------- 1 | ;;; hs-lint.el --- minor mode for HLint code checking 2 | 3 | ;; Copyright 2009 (C) Alex Ott 4 | ;; 5 | ;; Author: Alex Ott 6 | ;; Keywords: haskell, lint, HLint 7 | ;; Requirements: 8 | ;; Status: distributed under terms of GPL2 or above 9 | 10 | ;; Typical message from HLint looks like: 11 | ;; 12 | ;; /Users/ott/projects/lang-exp/haskell/test.hs:52:1: Eta reduce 13 | ;; Found: 14 | ;; count1 p l = length (filter p l) 15 | ;; Perhaps: 16 | ;; count1 p = length . filter p 17 | 18 | 19 | (require 'compile) 20 | 21 | (defgroup hs-lint nil 22 | "Run HLint as inferior of Emacs, parse error messages." 23 | :group 'tools 24 | :group 'haskell) 25 | 26 | (defcustom hs-lint-command "hlint" 27 | "The default hs-lint command for \\[hlint]." 28 | :type 'string 29 | :group 'hs-lint) 30 | 31 | (defcustom hs-lint-save-files t 32 | "Save modified files when run HLint or no (ask user)" 33 | :type 'boolean 34 | :group 'hs-lint) 35 | 36 | (defcustom hs-lint-replace-with-suggestions nil 37 | "Replace user's code with suggested replacements" 38 | :type 'boolean 39 | :group 'hs-lint) 40 | 41 | (defcustom hs-lint-replace-without-ask nil 42 | "Replace user's code with suggested replacements automatically" 43 | :type 'boolean 44 | :group 'hs-lint) 45 | 46 | (defun hs-lint-process-setup () 47 | "Setup compilation variables and buffer for `hlint'." 48 | (run-hooks 'hs-lint-setup-hook)) 49 | 50 | ;; regex for replace suggestions 51 | ;; 52 | ;; ^\(.*?\):\([0-9]+\):\([0-9]+\): .* 53 | ;; Found: 54 | ;; \s +\(.*\) 55 | ;; Perhaps: 56 | ;; \s +\(.*\) 57 | 58 | (defvar hs-lint-regex 59 | "^\\(.*?\\):\\([0-9]+\\):\\([0-9]+\\): .*[\n\C-m]Found:[\n\C-m]\\s +\\(.*\\)[\n\C-m]Perhaps:[\n\C-m]\\s +\\(.*\\)[\n\C-m]" 60 | "Regex for HLint messages") 61 | 62 | (defun make-short-string (str maxlen) 63 | (if (< (length str) maxlen) 64 | str 65 | (concat (substring str 0 (- maxlen 3)) "..."))) 66 | 67 | (defun hs-lint-replace-suggestions () 68 | "Perform actual replacement of suggestions" 69 | (goto-char (point-min)) 70 | (while (re-search-forward hs-lint-regex nil t) 71 | (let* ((fname (match-string 1)) 72 | (fline (string-to-number (match-string 2))) 73 | (old-code (match-string 4)) 74 | (new-code (match-string 5)) 75 | (msg (concat "Replace '" (make-short-string old-code 30) 76 | "' with '" (make-short-string new-code 30) "'")) 77 | (bline 0) 78 | (eline 0) 79 | (spos 0) 80 | (new-old-code "")) 81 | (save-excursion 82 | (switch-to-buffer (get-file-buffer fname)) 83 | (goto-line fline) 84 | (beginning-of-line) 85 | (setf bline (point)) 86 | (when (or hs-lint-replace-without-ask 87 | (yes-or-no-p msg)) 88 | (end-of-line) 89 | (setf eline (point)) 90 | (beginning-of-line) 91 | (setf old-code (regexp-quote old-code)) 92 | (while (string-match "\\\\ " old-code spos) 93 | (setf new-old-code (concat new-old-code 94 | (substring old-code spos (match-beginning 0)) 95 | "\\ *")) 96 | (setf spos (match-end 0))) 97 | (setf new-old-code (concat new-old-code (substring old-code spos))) 98 | (remove-text-properties bline eline '(composition nil)) 99 | (when (re-search-forward new-old-code eline t) 100 | (replace-match new-code nil t))))))) 101 | 102 | (defun hs-lint-finish-hook (buf msg) 103 | "Function, that is executed at the end of HLint execution" 104 | (if hs-lint-replace-with-suggestions 105 | (hs-lint-replace-suggestions) 106 | (next-error 1 t))) 107 | 108 | (define-compilation-mode hs-lint-mode "HLint" 109 | "Mode for check Haskell source code." 110 | (set (make-local-variable 'compilation-process-setup-function) 111 | 'hs-lint-process-setup) 112 | (set (make-local-variable 'compilation-disable-input) t) 113 | (set (make-local-variable 'compilation-scroll-output) nil) 114 | (set (make-local-variable 'compilation-finish-functions) 115 | (list 'hs-lint-finish-hook)) 116 | ) 117 | 118 | (defun hs-lint () 119 | "Run HLint for current buffer with haskell source" 120 | (interactive) 121 | (save-some-buffers hs-lint-save-files) 122 | (compilation-start (concat hs-lint-command " \"" buffer-file-name "\"") 123 | 'hs-lint-mode)) 124 | 125 | (provide 'hs-lint) 126 | ;;; hs-lint.el ends here 127 | -------------------------------------------------------------------------------- /personal-libs/lang-scripts/lang-scripts.el: -------------------------------------------------------------------------------- 1 | ;;; lang-scripts.el --- Lang Scripts -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2021 Laura Viglioni 4 | 5 | ;; Author: Laura Viglioni 6 | ;; Maintainer: Laura Viglioni 7 | ;; Created: 28 Aug 2021 8 | ;; Keywords: 9 | ;; URL: https://github.com/Viglioni/laurisp/tree/main/personal-libs/lang-scripts 10 | ;; Version: 0.0.1 11 | ;; Package-Requires: ((emacs "24.1")) 12 | 13 | ;; This file is not part of GNU Emacs. 14 | 15 | ;; This file is free software; you can redistribute it and/or modify 16 | ;; it under the terms of the GNU General Public License as published by 17 | ;; the Free Software Foundation; either version 3, or (at your option) 18 | ;; any later version. 19 | ;; 20 | ;; This program is distributed in the hope that it will be useful, 21 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | ;; GNU General Public License for more details. 24 | ;; 25 | 26 | ;;; Commentary: 27 | ;; Base lib for opening a buffer to run scripts related to languages, for instance npm run dev 28 | 29 | ;;; Code: 30 | 31 | (message "loading lang-scripts") 32 | 33 | ;;;###autoload 34 | (defun lang-scripts--open-buffer (buff) 35 | "Opens a buffer. 36 | (buff) -> ()" 37 | (display-buffer-in-side-window buff '((side . bottom)))) 38 | 39 | 40 | ;;;###autoload 41 | (defun lang-scripts--is-npm-buff? (buff-or-buff-name) 42 | "Checks if a buffer name matches the regex of this lib created buffers 43 | (string | buffer) -> bool" 44 | (let ((buff-name (if (stringp buff-or-buff-name) buff-or-buff-name 45 | (buffer-name buff-or-buff-name)))) 46 | (bool (regex-matches (rx (and "*:" (+ (or alphanumeric "-")) "::" (+ (or alphanumeric "-")) ":*")) buff-name)))) 47 | 48 | ;;;###autoload 49 | (defun lang-scripts--get-buffer () 50 | "Gets language script buffer, if any, throws otherwise 51 | () -> buffer | error" 52 | (let* ((bottom-window (purpose-get-bottom-window)) 53 | (buff-name (and bottom-window (buffer-name (window-buffer bottom-window)))) 54 | (is-npm-buff? buff-name)) 55 | (throw-unless is-npm-buff? "no language script buffer is found") 56 | (get-buffer buff-name))) 57 | 58 | 59 | ;;;###autoload 60 | (defun NS--active-buffers-alist () 61 | "returns an alist (buffer-name . buffer) 62 | () -> alist string buffer" 63 | (fp/pipe (buffer-list) 64 | ((seq-filter 'lang-scripts--is-npm-buff? ) 65 | (mapcar (lambda (buff) (cons (buffer-name buff) buff)))))) 66 | 67 | (defun lang-scripts--helm-buffer-source () 68 | (helm-build-sync-source "Active npm buffers: " 69 | :volatile t 70 | :multiline nil 71 | :candidates (NS--active-buffers-alist) 72 | :action 'lang-scripts--open-buffer)) 73 | 74 | ;; 75 | ;; API 76 | ;; 77 | 78 | ;;;###autoload 79 | (defun lang-scripts:hide-buffer () 80 | "Hides a buffer with a npm command running. 81 | It will hide only if it is on the bottom window and matches the regex 82 | () -> () | error" 83 | (interactive) 84 | (lang-scripts--get-buffer) 85 | (purpose-delete-window-at-bottom)) 86 | 87 | ;;;###autoload 88 | (defun lang-scripts:go-to-buffer () 89 | "Focus on buffer or throws if no buffer is found 90 | () -> () | error" 91 | (interactive) 92 | (fp/pipe (lang-scripts--get-buffer) 93 | ((get-buffer-window) 94 | (select-window))) 95 | (goto-char (point-max))) 96 | 97 | (defun lang-scripts:open-active-buffer () 98 | "Lists all active npm buffers and opens the selected one" 99 | (interactive) 100 | (helm :promp "Choose a buffer to open: " 101 | :buffer "*helm active npm buffers*" 102 | :sources (lang-scripts--helm-buffer-source))) 103 | 104 | ;;;###autoload 105 | (defun lang-scripts:run-script (script-cmd &optional dir) 106 | "@param (string) a npm command e.g. \"npm run dev\" 107 | @return void 108 | Runs this script in a dedicated async shell buffer. It will run on project root if dir is not specified." 109 | (let* ((cmd-name (replace-regexp-in-string " " "-" script-cmd)) 110 | (full-cmd (concat script-cmd "&& echo \"\n\nFinished!\n\" || echo \"\n\nFinished with errors.\n\"")) 111 | (buff-name (concat "*:" (projectile-project-name) "::" cmd-name ":*")) 112 | (err-buff-name (concat "*:ERROR::" (projectile-project-name) "::" cmd-name ":*")) 113 | (buff (get-buffer-create buff-name))) 114 | (lang-scripts--open-buffer buff) 115 | (projectile-with-default-dir (or dir (projectile-project-root)) 116 | (async-shell-command script-cmd buff-name err-buff-name)) 117 | (set-window-dedicated-p (get-buffer-window buff) t))) 118 | 119 | 120 | (provide 'lang-scripts) 121 | ;;; lang-scripts.el ends here 122 | 123 | -------------------------------------------------------------------------------- /test/core/test-string.el: -------------------------------------------------------------------------------- 1 | ;; -*- lexical-binding: t -*- 2 | (load "./tests/buttercup-helpers.elc") 3 | (load "./src/l-string") 4 | (add-to-list 'load-path "../") 5 | 6 | (test-suite "#join-path" 7 | (context "path ends in /" 8 | (it-should "should join without a bar between path and filename" 9 | (expect (join-path "/path/to/" "file.lau") 10 | :to-equal "/path/to/file.lau"))) 11 | (context "path ends in other thing than a /" 12 | (it-should "add a bar between path and filename" 13 | (expect (join-path "/path/to" "file.lau") 14 | :to-equal "/path/to/file.lau"))) 15 | (context "path or filename is nil" 16 | (it-should "throw error" 17 | (expect (join-path nil "file.lau") 18 | :to-throw) 19 | (expect (join-path "path/to" nil) 20 | :to-throw) 21 | (expect (join-path nil nil) 22 | :to-throw)))) 23 | 24 | (test-suite "#file-extension" 25 | (context "filename or extension is nil" 26 | (it-should "throw error" 27 | (expect (file-extension nil "lau") 28 | :to-throw) 29 | (expect (file-extension "file" nil) 30 | :to-throw) 31 | (expect (file-extension nil nil) 32 | :to-throw))) 33 | (context "filename and extension exists" 34 | (it-should "concatenate filename with extension" 35 | (expect (file-extension "file" "lau") :to-equal "file.lau")))) 36 | 37 | (test-suite "#regex-matches" 38 | (context "there are several matches in string" 39 | (it-should "return all of them in the correct order" 40 | (let ((string "match1 asdasdasda match2 adasdas match3 asd") 41 | (regexp "match[0-9]")) 42 | (expect (regex-matches regexp string) 43 | :to-equal '("match1" "match2" "match3"))))) 44 | (context "there are no matchs" 45 | (it-should "return nil" 46 | (expect (regex-matches "nomatch" "asdasdasdas") 47 | :to-be nil))) 48 | (context "one of the params is nil" 49 | (it-should "throw error" 50 | (expect (regex-matches "regexp" nil) :to-throw) 51 | (expect (regex-matches nil "string") :to-throw) 52 | (expect (regex-matches nil nil) :to-throw)))) 53 | 54 | (test-suite "#get-string-from-file" 55 | (context "param is nil or do not exist" 56 | (it-should "throw error" 57 | (expect (get-string-from-file nil) :to-throw) 58 | (expect (get-string-from-file "invalid filepath") :to-throw))) 59 | (context "param is a valid filepath" 60 | (before-each 61 | (spy-on 'file-exists-p :and-return-value t) 62 | (spy-on 'insert-file-contents 63 | :and-call-fake (lambda (path) (insert "string")))) 64 | (it-should "return file's content" 65 | (expect (get-string-from-file "filepath") 66 | :to-equal "string")))) 67 | 68 | (test-suite "#remove-suffix" 69 | (context "param is nil" 70 | (it-should "throw error" 71 | (expect (remove-suffix) :to-throw ))) 72 | (context "param has suffix" 73 | (it-should "remove suffix" 74 | (expect (remove-suffix "file.lau") :to-equal "file"))) 75 | (context "param has no suffix" 76 | (it-should "return param" 77 | (expect (remove-suffix "file") :to-equal "file")))) 78 | 79 | (test-suite "#insert-on-fst-empty-line" 80 | (context "any param is nil" 81 | (it-should "throw error" 82 | (expect (insert-on-fst-empty-line) :to-throw ) 83 | (expect (insert-on-fst-empty-line "text" nil) :to-throw ) 84 | (expect (insert-on-fst-empty-line nil 0) :to-throw ))) 85 | (context "parameters are valid" 86 | :var* ((buffer-text "first line\n\nthird line") 87 | (text "i will be there") 88 | (point-after-empty-line 15) 89 | (point-before-empty-line 2) 90 | (expected-text "first line\ni will be there\nthird line") 91 | (expected-after-point (+ point-after-empty-line (length text))) 92 | test-on-temp-buffer) 93 | (before-each 94 | (fset 'test-on-temp-buffer (lambda (initial-point) 95 | (with-temp-buffer 96 | (insert buffer-text) 97 | (goto-char initial-point) 98 | (insert-on-fst-empty-line text (point)) 99 | (list (point) (buffer-string)))))) 100 | (context "cursor is after the empty line" 101 | (it-should "insert text and put the cursor in the correct place" 102 | (expect (test-on-temp-buffer point-after-empty-line) 103 | :to-equal (list expected-after-point expected-text)))) 104 | (context "cursor is before the empty line" 105 | (it-should "insert text without changing the cursor point" 106 | (expect (test-on-temp-buffer point-before-empty-line) 107 | :to-equal (list point-before-empty-line expected-text)))))) 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /external/hs-lint/hs-lint.elc: -------------------------------------------------------------------------------- 1 | ;ELC 2 | ;;; Compiled 3 | ;;; in Emacs version 27.2.50 4 | ;;; with all optimizations. 5 | 6 | ;;; This file uses dynamic docstrings, first added in Emacs 19.29. 7 | 8 | ;;; This file does not contain utf-8 non-ASCII characters, 9 | ;;; and so can be loaded in Emacs versions earlier than 23. 10 | 11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 13 | 14 | 15 | (byte-code "\300\301!\210\302\303\304\305\306\307\306\310&\210\311\312\313\314\315\316\306\303&\210\311\317\320\321\315\322\306\303&\210\311\323\304\324\315\322\306\303&\210\311\325\304\326\315\322\306\303&\207" [require compile custom-declare-group hs-lint nil "Run HLint as inferior of Emacs, parse error messages." :group tools haskell custom-declare-variable hs-lint-command "hlint" "The default hs-lint command for \\[hlint]." :type string hs-lint-save-files t "Save modified files when run HLint or no (ask user)" boolean hs-lint-replace-with-suggestions "Replace user's code with suggested replacements" hs-lint-replace-without-ask "Replace user's code with suggested replacements automatically"] 8) 16 | #@53 Setup compilation variables and buffer for `hlint'. 17 | (defalias 'hs-lint-process-setup #[nil "\300\301!\207" [run-hooks hs-lint-setup-hook] 2 (#$ . 1123)]) 18 | #@26 Regex for HLint messages 19 | (defvar hs-lint-regex "^\\(.*?\\):\\([0-9]+\\):\\([0-9]+\\): .*[\n ]Found:[\n ]\\s +\\(.*\\)[\n ]Perhaps:[\n ]\\s +\\(.*\\)[\n ]" (#$ . 1283)) 20 | (defalias 'make-short-string #[(str maxlen) "G W\203 \207\302\303 \304Z#\305P\207" [str maxlen substring 0 3 "..."] 5]) 21 | #@43 Perform actual replacement of suggestions 22 | (defalias 'hs-lint-replace-suggestions #[nil "eb\210\306\307\310#\205\244\311\312!\313\311\314!!\311\315!\311\316!\317\320 \321\"\322\320\f\321\"\323\260\324\211#$\324%\325&\212\326\327 !!\210\330\n!\210\331 \210`#'\204S\332 !\203\237\307\210`$\331 \210\333 !\334\335 %#\203}&\336 %\324\224#\337Q&\324\225%\202`&\336 %\"P&\340#$\341#\210\306&$\310#\203\237\342\f\307\310#\210.\n\202\207" [hs-lint-regex fname fline old-code new-code msg re-search-forward nil t match-string 1 string-to-number 2 4 5 "Replace '" make-short-string 30 "' with '" "'" 0 "" switch-to-buffer get-file-buffer goto-line beginning-of-line yes-or-no-p regexp-quote string-match "\\\\ " substring "\\ *" remove-text-properties (composition nil) replace-match bline eline spos new-old-code hs-lint-replace-without-ask] 7 (#$ . 1581)]) 23 | #@58 Function, that is executed at the end of HLint execution 24 | (defalias 'hs-lint-finish-hook #[(buf msg) "\203\301 \207\302\303\304\"\207" [hs-lint-replace-with-suggestions hs-lint-replace-suggestions next-error 1 t] 3 (#$ . 2471)]) 25 | (defvar hs-lint-mode-hook nil) 26 | (byte-code "\300\301N\204\f\302\300\301\303#\210\304\305!\204\302\305\306\307#\210\300\207" [hs-lint-mode-hook variable-documentation put "Hook run after entering HLint mode.\nNo problems result if this variable is not bound.\n`add-hook' automatically binds it. (This is true for all hook variables.)" boundp hs-lint-mode-map definition-name hs-lint-mode] 4) 27 | (defvar hs-lint-mode-map (make-sparse-keymap)) 28 | (byte-code "\301\302N\204\303\301\302\304\305!#\210\306\307!\204\303\307\310\311#\210\312\313 !\210\307\302N\204-\303\307\302\304\314!#\210\306\300!\204B\303\300\310\311#\210\315\316\300\317\"\210!\210\300\302N\204P\303\300\302\304\320!#\210\303\311\321\322#\207" [hs-lint-mode-abbrev-table hs-lint-mode-map variable-documentation put purecopy "Keymap for `hs-lint-mode'." boundp hs-lint-mode-syntax-table definition-name hs-lint-mode (lambda (#1=#:def-tmp-var) (defvar hs-lint-mode-syntax-table #1#)) make-syntax-table "Syntax table for `hs-lint-mode'." (lambda (#1#) (defvar hs-lint-mode-abbrev-table #1#)) define-abbrev-table nil "Abbrev table for `hs-lint-mode'." derived-mode-parent compilation-mode] 5) 29 | #@236 Mode for check Haskell source code. 30 | 31 | In addition to any hooks its parent mode `compilation-mode' might have run, 32 | this mode runs the hook `hs-lint-mode-hook', as the final or penultimate step 33 | during initialization. 34 | 35 | \{hs-lint-mode-map} 36 | (defalias 'hs-lint-mode #[nil "\306\300!\210\307\310 \210\311\312\310\313N\203\314\311\313\310\313N#\210\315 !\204'\316 \317 \"\210\320\f!\211\2036 \321 =\203<\322\f\323 \"\210)\324\"\325\"\204V\"#=\204V\326\"\325#C#\210\327 !\210\330\f!\210\"#\306\331!\210\332\306\333!\210\307\306\334!\210\335\306\336!\210\337C)\340\341!\207" [delay-mode-hooks major-mode mode-name hs-lint-mode-map hs-lint-mode-syntax-table parent make-local-variable t compilation-mode hs-lint-mode "HLint" mode-class put keymap-parent set-keymap-parent current-local-map char-table-parent standard-syntax-table set-char-table-parent syntax-table abbrev-table-get :parents abbrev-table-put use-local-map set-syntax-table compilation-process-setup-function hs-lint-process-setup compilation-disable-input compilation-scroll-output nil compilation-finish-functions hs-lint-finish-hook run-mode-hooks hs-lint-mode-hook hs-lint-mode-abbrev-table local-abbrev-table] 6 (#$ . 3867) nil]) 37 | #@50 Run HLint for current buffer with haskell source 38 | (defalias 'hs-lint #[nil "\303!\210\304 \305\n\306R\307\"\207" [hs-lint-save-files hs-lint-command buffer-file-name save-some-buffers compilation-start " \"" "\"" hs-lint-mode] 5 (#$ . 5087) nil]) 39 | (provide 'hs-lint) 40 | -------------------------------------------------------------------------------- /personal-libs/npm-scripts/npm-scripts.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | (message "loading npm-scripts...") 8 | 9 | (require 'helm) 10 | (require 'seq) 11 | (load-lib 'functional) 12 | (load-lib 'json-utils) 13 | (load-lib 'lang-scripts) 14 | 15 | ;; 16 | ;; Vars and common funcs 17 | ;; 18 | 19 | (defvar NS--default-import-allowed-modes 20 | '(typescript-mode typescript-tsx-mode js2-mode rjsx-mode js-mode web-mode)) 21 | 22 | ;;;###autoload 23 | (defun NS--allowed-mode? () 24 | "Checks if current mode is allowed based on `NS--default-import-allowed-modes'" 25 | (contains? NS--default-import-allowed-modes major-mode)) 26 | 27 | ;;;###autoload 28 | (defun NS--has-package-json? () 29 | "Returns if there is a package.json in the project root dir 30 | () -> bool" 31 | (file-exists-p (join-path (projectile-project-root) "package.json"))) 32 | 33 | ;; 34 | ;; NPM choose and run 35 | ;; 36 | 37 | ;;;###autoload 38 | (defun NS--get-scripts (package-json) 39 | "@param package.json filepath 40 | @returns a list of all scripts in package.json" 41 | (fp/pipe package-json 42 | ((json-read-file) 43 | (alist-get 'scripts) 44 | (fp/alist-sort-by-car) 45 | (mapcar 'car)))) 46 | 47 | ;;;###autoload 48 | (defun NS--build-scripts (scripts-list) 49 | "@param a list of strings 50 | @returns an alist of (scriptname . \"npm run script\")" 51 | (mapcar (lambda (script) (cons (format "%s" script) 52 | (format "npm run %s" script))) 53 | scripts-list)) 54 | 55 | 56 | ;;;###autoload 57 | (defun NS--helm-candidates () 58 | "Gets the script from package.json and returns an alist (name . command)" 59 | (fp/pipe (json-utils-get-package-json) 60 | ((NS--get-scripts) 61 | (NS--build-scripts)))) 62 | 63 | ;;;###autoload 64 | (defun NS--helm-scripts-source () 65 | (helm-build-sync-source "Avaliable scripts on your package.json: " 66 | :volatile t 67 | :multiline nil 68 | :candidates (NS--helm-candidates) 69 | :action 'lang-scripts:run-script)) 70 | 71 | 72 | ;; API 73 | 74 | ;;;###autoload 75 | (defun npm-scripts:choose-and-run () 76 | "Lists all avaliable scripts on package.json and runs the selected one" 77 | (interactive) 78 | (helm :prompt "Choose a script to run: " 79 | :sources (NS--helm-scripts-source) 80 | :buffer "*helm avaliable npm scripts*")) 81 | 82 | ;; 83 | ;; Install packages 84 | ;; 85 | 86 | ;;;###autoload 87 | (defun npm-scripts:install (package-name) 88 | (interactive "sInsert package name or just hit enter to run \"npm i\": ") 89 | (throw-unless (NS--has-package-json?) "No package.json was found!") 90 | (lang-scripts:run-script (concat "npm install " package-name))) 91 | 92 | ;;;###autoload 93 | (defun npm-scripts:install-dev (package-name) 94 | (interactive "sInsert package name: ") 95 | (throw-unless (NS--has-package-json?) "No package.json was found!") 96 | (throw-if (fp/is-empty? package-name) "package name can't be empty") 97 | (lang-scripts:run-script (concat "npm install -D " package-name))) 98 | 99 | 100 | ;; 101 | ;; Import default 102 | ;; 103 | 104 | (defvar NS--default-import-lib-list 105 | '(("fp-ts/Array" . "A") 106 | ("fp-ts/Either" . "E") 107 | ("fp-ts/IO" . "IO") 108 | ("fp-ts/IOEither" . "IOE" ) 109 | ("fp-ts/TaskEither" . "TE") 110 | ("fp-ts/Task" . "T") 111 | ("io-ts/Decoder" . "D") 112 | ("ramda" . "R") 113 | ("lodash/fp" . "_") 114 | ("rxjs/operators" . "rx"))) 115 | 116 | (setq NS--default-import-candidates 117 | (mapcar (lambda (c) (cons (car c) c)) NS--default-import-lib-list)) 118 | 119 | ;;;###autoload 120 | (defun NS--add-import-to-file (candidate) 121 | (let ((import-as (cdr candidate)) 122 | (lib-name (car candidate))) 123 | (fp/insert-on-fst-empty-line 124 | (format "import * as %s from '%s'" import-as lib-name)))) 125 | 126 | ;;;###autoload 127 | (defun NS--default-import-helm-src () 128 | (helm-build-sync-source "Default import: " 129 | :candidates 'NS--default-import-candidates 130 | :action 'NS--add-import-to-file)) 131 | 132 | 133 | ;; API 134 | 135 | ;;;###autoload 136 | (defun npm-scripts:import-default-lib () 137 | "Add to the first empty line of the code an default js/ts import 138 | e.g.: import * as E from 'fp-ts/Either' 139 | according to the assoc list `NS--default-import-lib-list'. 140 | Will only add if the current buffer is in one of the modes listed in 141 | `NS--default-import-allowed-modes'" 142 | (interactive) 143 | (throw-unless (NS--allowed-mode?)"Not in a js/ts mode!") 144 | (helm 145 | :prompt "Choose lib to import default: " 146 | :sources (NS--default-import-helm-src))) 147 | 148 | 149 | 150 | (provide 'npm-scripts) 151 | 152 | ;; 153 | ;; compiler warnings 154 | ;; 155 | 156 | ;; In NS--get-scripts: 157 | ;; npm-scripts.el:19:25:Warning: function ‘reduce’ from cl package called at 158 | ;; runtime 159 | 160 | ;; In NS--run-script: 161 | ;; npm-scripts.el:45:24:Warning: function ‘reduce’ from cl package called at 162 | ;; runtime 163 | 164 | ;; In NS--active-buffers-alist: 165 | ;; npm-scripts.el:81:15:Warning: function ‘reduce’ from cl package called at 166 | ;; runtime 167 | 168 | ;; In NS--helm-candidates: 169 | ;; npm-scripts.el:91:8:Warning: function ‘reduce’ from cl package called at 170 | ;; runtime 171 | 172 | -------------------------------------------------------------------------------- /personal-libs/ts-repl/ts-repl.el: -------------------------------------------------------------------------------- 1 | ;;; ts-repl.el --- Ts Repl -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2021 Laura Viglioni 4 | 5 | ;; Author: Laura Viglioni 6 | ;; Maintainer: Laura Viglioni 7 | ;; Created: 04 Jul 2021 8 | ;; Keywords: keywods 9 | ;; URL: https://github.com/Viglioni/laurisp/tree/main/personal-libs/ts-repl 10 | ;; Version: 0.0.1 11 | ;; Package-Requires: ((emacs "24.1")) 12 | 13 | ;; This file is not part of GNU Emacs. 14 | 15 | ;; This file is free software; you can redistribute it and/or modify 16 | ;; it under the terms of the GNU General Public License as published by 17 | ;; the Free Software Foundation; either version 3, or (at your option) 18 | ;; any later version. 19 | ;; 20 | ;; This program is distributed in the hope that it will be useful, 21 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | ;; GNU General Public License for more details. 24 | ;; 25 | 26 | ;;; Commentary: 27 | ;; Not a repl per se. 28 | ;; Executes the file and outputs the result, i.e. console.logs with `ts-repl-exec-ts-buffer' 29 | ;; Executes the buffer and consoles the last sexp `ts-repl-send-last-sexp' 30 | ;; External requires: node with npx command, ts-node 31 | 32 | ;;; Code: 33 | 34 | (load-lib 'laurisp-core) 35 | (load-lib 'functional) 36 | 37 | (defvar ts-repl--buffer-name "*TS-result*" 38 | "Output buffer of the TS execution") 39 | 40 | (defvar ts-repl--error-buffer-name "*TS-erros*" 41 | "Output buffer of the TS execution errors") 42 | 43 | 44 | ;;;###autoload 45 | (defun ts-repl--is-ts? (filename) 46 | "Checks if file is a typescript file: *.ts or .tsx" 47 | (bool (string-match "\\.tsx?$" filename))) 48 | 49 | ;;;###autoload 50 | (define-derived-mode ts-repl-mode typescript-mode "TS Repl" 51 | "A major mode for visualizing the output of a TS file") 52 | 53 | 54 | ;;;###autoload 55 | (defun ts-repl--wrap-console (beginning end) 56 | "Wraps a console.log around region" 57 | (concat "\nconsole.log(" 58 | (replace-regexp-in-string 59 | ";$" "" 60 | (buffer-substring beginning end)) 61 | ")\n")) 62 | 63 | ;;;###autoload 64 | (defun ts-repl--pulse (&optional sexp-beg sexp-end) 65 | "Pulses region: sexp region or marked region or the whole buffer" 66 | (pulse-momentary-highlight-region 67 | (or sexp-beg (and (use-region-p) (region-beginning)) (point-min)) 68 | (or sexp-end (and (use-region-p) (region-end)) (point-max)))) 69 | 70 | ;;;###autoload 71 | (defun ts-repl--content (&optional sexp-beg sexp-end) 72 | "Gets the content of the buffer where the function is executed. 73 | If a sexp region is passed as arg or if a region is selected on buffer, 74 | it is wrapped by a console.log statement and concatenated to the end" 75 | (let* ((buffer-content (buffer-substring-no-properties (point-min) (point-max))) 76 | (sexp? (bool (and sexp-beg sexp-end))) 77 | (region-to-be-wrapped? (bool (or sexp? (use-region-p)))) 78 | (beginning (if sexp? sexp-beg (region-beginning))) 79 | (end (if sexp? sexp-end (region-end))) 80 | (console-wrapped-content (if region-to-be-wrapped? 81 | (ts-repl--wrap-console beginning end) 82 | ""))) 83 | (concat buffer-content console-wrapped-content))) 84 | 85 | ;;;###autoload 86 | (defun ts-repl--run-ts (tmp-file) 87 | "Runs the command that will execute the typescript content" 88 | (async-shell-command 89 | (concat "echo \"-*-TS-Repl-start-*-\n\n\"" 90 | " && npx ts-node -T " tmp-file 91 | " && echo \"\n\"" 92 | " || echo \"\n\n-*-An error has occurred-*-\"" 93 | " && echo \"-*-TS-Repl-end-*-\"") 94 | ts-repl--buffer-name 95 | ts-repl--error-buffer-name)) 96 | 97 | ;;;###autoload 98 | (defun ts-repl--run-after-ts (tmp-file) 99 | "Commands that will run after the TS execution: 100 | adds ts-repl-mode and deletes the temp file" 101 | (let* ((result-buff (get-buffer ts-repl--buffer-name)) 102 | (proc (get-buffer-process result-buff))) 103 | (when (process-live-p proc) 104 | (set-process-sentinel 105 | proc 106 | #'(lambda (process signal) 107 | (with-current-buffer result-buff (funcall 'ts-repl-mode)) 108 | (shell-command (concat "rm " tmp-file)) 109 | (shell-command-sentinel process signal)))))) 110 | 111 | ;;;###autoload 112 | (defun ts-repl-send-last-sexp () 113 | "Executes buffer without type verification for efficiency reasons 114 | and consoles the last sexp around the cursor" 115 | (interactive) 116 | (let ((beginning (save-excursion 117 | (backward-sexp) 118 | (move-beginning-of-line nil) 119 | (point))) 120 | (end (point))) 121 | (ts-repl-exec-ts-buffer beginning end))) 122 | 123 | ;;;###autoload 124 | (defun ts-repl-exec-ts-buffer (&optional sexp-beg sexp-end) 125 | "Executes buffer without type verification for efficiency reasons" 126 | (interactive) 127 | (let* ((result-buff (get-buffer-create ts-repl--buffer-name)) 128 | (ts-content (ts-repl--content sexp-beg sexp-end)) 129 | (tmp-file (concat (make-temp-name "ts-repl") ".ts"))) 130 | (throw-unless (ts-repl--is-ts? (buffer-file-name)) 131 | "this is not a typescript file!") 132 | (write-region ts-content nil tmp-file) 133 | (ts-repl--pulse sexp-beg sexp-end) 134 | (ts-repl--run-ts tmp-file) 135 | (ts-repl--run-after-ts tmp-file))) 136 | 137 | 138 | (provide 'ts-repl) 139 | ;;; ts-repl.el ends here 140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /personal-libs/functional/functional.el: -------------------------------------------------------------------------------- 1 | ;;; functional.el --- Common functional programming functions -*- lexical-binding: t -*- 2 | 3 | ;; Author: Laura Viglioni 4 | ;; URL: https://github.com/Viglioni/laurisp 5 | ;; Keywords: functional programming 6 | ;; Version: 0.0.1 7 | ;; Package-Requires: ((emacs "25.1") (seq "2.21")) 8 | 9 | ;; This file is NOT part of GNU Emacs. 10 | 11 | ;; This program is free software; you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation; either version 3, or (at your option) 14 | ;; any later version. 15 | ;; 16 | ;; This program is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | ;; 21 | 22 | ;;; Commentary: 23 | ;; A functional lib for emacs including compose, pipe, curry and more. 24 | 25 | ;;; Code: 26 | 27 | (message "loading functional...") 28 | 29 | ;; 30 | ;; functional related functions 31 | ;; 32 | 33 | (require 'seq) 34 | (require 'cl) 35 | 36 | ;; 37 | ;; Function 38 | ;; 39 | 40 | (defmacro curry-expr (expr) 41 | "Curries an expression 42 | e.g. (curry-expr '(+ 1 2 3)) -> (fp/curry + 1 2 3)" 43 | `(eval (seq-concatenate 'list '(fp/curry) ,expr))) 44 | 45 | (defmacro compose (&rest fn-list) 46 | "Compose functions (and curries them) from right to left. 47 | ((y -> z) ... (m -> o) ((a ... n) -> m) ) -> ((a ... n)->z) 48 | e.g.: 49 | (compose (+ 1) (* 2)) -> (lambda (arg1 ... argN) (+ 1 (* 2 arg1 ... argN)))" 50 | `(let ((curried-fn (quote ,(seq-map (lambda (fn) (curry-expr fn)) fn-list)))) 51 | (reduce 52 | (lambda (f g) 53 | (lexical-let ((f f) (g g)) 54 | (lambda (&rest args) (funcall f (apply g args))))) 55 | curried-fn 56 | :initial-value (fp/curry identity)))) 57 | 58 | 59 | ;;;###autoload 60 | (defmacro fp/curry (fn &rest initial-args) 61 | "Returns the curried function. 62 | e.g.: 63 | (fp/curry + 1 2 3) -> (lambda (argN ... argM) (+ 1 2 3 argN ... argM))" 64 | `(lambda (&rest args) 65 | (apply (quote ,fn) (seq-concatenate 'list (list ,@initial-args) args)))) 66 | 67 | ;;;###autoload 68 | (defmacro fp/pipe (arg fn-list) 69 | "Pipe an argument into composed functions from left to right. 70 | a -> ((a -> b) (b -> c) ... (n -> m)) -> m 71 | e.g.: 72 | (fp/pipe 5 ((+ 1) (* 2))) -> 12" 73 | (declare (indent defun)) 74 | `(funcall (compose ,@(reverse fn-list)) ,arg)) 75 | 76 | ;;;###autoload 77 | (defmacro compose-and-call (fn-list &rest args) 78 | "Since compose returns a function, this helper receives a list of 79 | functions and args and apply them to composed funcs 80 | (a ... n) -> ((y -> z) ... (m -> o) ((a ... n) -> m) ) -> z 81 | e.g.: 82 | (compose-and-call ((+ 1) (* 2)) 2 3) -> 13" 83 | `(funcall (compose ,@fn-list) ,@args)) 84 | 85 | (defun identity (arg) 86 | "Identity function. 87 | a -> a" 88 | arg) 89 | 90 | ;; 91 | ;; Logic 92 | ;; 93 | 94 | ;;;###autoload 95 | (defun bool (x) 96 | "returns t if element is truthy, nil if its falsey 97 | a -> bool" 98 | (not (not x))) 99 | 100 | ;;;###autoload 101 | (defun n-and (&rest args) 102 | "Not and. 103 | * -> bool" 104 | (not (all args))) 105 | 106 | ;;;###autoload 107 | (defun n-or (&rest args) 108 | "Not or. 109 | * -> bool" 110 | (not (any args))) 111 | 112 | ;; 113 | ;; List 114 | ;; 115 | 116 | ;;;###autoload 117 | (defun all (lst) 118 | "Returns t if all elements in list are truthy 119 | [a] → Boolean" 120 | (bool (seq-reduce 121 | (lambda (acc val) (and acc val)) 122 | lst t))) 123 | 124 | ;;;###autoload 125 | (defun any (lst) 126 | "Returns t if at least one element in list is truthy 127 | [a] → Boolean" 128 | (bool (seq-reduce 129 | (lambda (acc val) (or acc val)) 130 | lst nil))) 131 | 132 | ;;;###autoload 133 | (defun contains? (list element) 134 | "Returns t/nil if element is in list 135 | ([a] a) -> bool" 136 | (bool (member element list))) 137 | 138 | ;;;###autoload 139 | (defun head (list) 140 | "Returns the first element of a list 141 | [a] -> a | nil" 142 | (car list)) 143 | 144 | ;TODO: implement last, init 145 | 146 | ;;;###autoload 147 | (defun not-contains? (list element) 148 | "Returns t/nil if element is not in list 149 | ([a] a) -> bool" 150 | (if list (not (contains? list element)))) 151 | 152 | ;;;###autoload 153 | (defun tail (list) 154 | "Returns the list but its first element 155 | [a] -> [a] | nil" 156 | (cdr list)) 157 | 158 | ;;;###autoload 159 | (defun unzip (zipped-list) 160 | "unzip n lists 161 | [[a]] -> [[a]] 162 | e.g.: 163 | (unzip '((1 2 ... n) (1 2 ... n))) -> 164 | '((1 1 ... 1) (2 2 .... 2) ... (n n ... n)" 165 | (if (and zipped-list (all zipped-list)) 166 | (let ((heads (mapcar* 'head zipped-list)) 167 | (tails (mapcar* 'tail zipped-list))) 168 | (append (list heads) (unzip tails))))) 169 | 170 | ;;;###autoload 171 | (defun zip (&rest lists) 172 | "zips n lists 173 | [[a]] -> [[a]] 174 | e.g.: 175 | (zip '(1 1) '(2 2) '(3 3)) -> '((1 2 3) (1 2 3))" 176 | (apply (fp/curry mapcar* 'list) lists)) 177 | 178 | ;; 179 | ;; Number 180 | ;; 181 | 182 | ;;;###autoload 183 | (defun inc (n) 184 | "Returns the increment of n 185 | Number -> Number" 186 | (+ 1 n)) 187 | 188 | ;; 189 | ;; Type 190 | ;; 191 | 192 | ;;;###autoload 193 | (defun all-nil? (&rest args) 194 | "return if all args are nil 195 | (* ... *) -> boolean 196 | e.g (all-nil? nil nil) -> t" 197 | (apply 'n-or args)) 198 | 199 | (defun any-nil? (&rest args) 200 | "return if any args are nil 201 | (* ... *) -> boolean 202 | e.g (any-nil? nil t nil) -> t" 203 | (apply 'n-and args)) 204 | 205 | 206 | ;; 207 | ;; alist 208 | ;; 209 | ;TODO: test it 210 | ;;;###autoload 211 | (defun fp/alist-sort-by-car (alist) 212 | (sort alist (lambda (a b) (string< (car a) (car b))))) 213 | 214 | ;;;###autoload 215 | (defun alist-sort-by-cdr-ci (alist) 216 | "sort alist by cdr. case insensitive" 217 | (sort alist (lambda (a b) (string< (downcase (cdr a)) (downcase (cdr b)))))) 218 | 219 | (provide 'functional) 220 | 221 | ;;; functional.el ends here 222 | -------------------------------------------------------------------------------- /config/l-org-latex-pdf.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | 8 | ;; 9 | ;; Lazy binds from personal libs 10 | ;; 11 | 12 | ;; laurg 13 | (bind-lazy-function 'insert-org-source 'laurg-insert-org-source 'laurg) 14 | (bind-lazy-function 'insert-custom-headers 'laurg-insert-custom-headers 'laurg) 15 | ;; lautex 16 | (bind-lazy-function 'preview-latex-on-buffer 'LauTeX-preview-latex-on-buffer 'lautex) 17 | (bind-lazy-function 'preview-latex-on-section 'LaTeX-preview-latex-on-section 'lautex) 18 | (bind-lazy-function 'compile-org-to-pdf 'LauTeX-compile-org-to-pdf 'lautex) 19 | (bind-lazy-function 'org-env 'LauTeX-org-env 'lautex) 20 | (bind-lazy-function 'org-env-exit 'LauTeX-org-env-exit 'lautex) 21 | (bind-lazy-function 'preview-org-env 'LauTeX-preview-org-env 'lautex) 22 | (bind-lazy-function 'insert-reference 'LauTeX-insert-reference 'lautex) 23 | (bind-lazy-function 'insert-citation 'LauTeX-insert-citation 'lautex) 24 | 25 | ;; 26 | ;; ORG 27 | ;; 28 | ;; 29 | ;; Define org command by cursor position 30 | ;; 31 | 32 | ;;;###autoload 33 | (defmacro define-org-cmd (&rest plist) 34 | "Receives a plist (:situation 'command) as args to define which 35 | command should be called on each situation. 36 | Obs.: the command will ONLY be called on the specific situation. 37 | *~*~* 38 | For now the supported keys are 39 | :heading -> runs when cursor is over a heading 40 | :table -> runs when cursor is over a table 41 | *~*~* 42 | example: (define-org-cmd :heading 'my-fn :table 'my-fn2)" 43 | (throw-if (oddp (length plist)) "arg list must have an even number of args") 44 | `(lambda () 45 | (interactive) 46 | (cond 47 | ((org-at-heading-p) (funcall ,(plist-get plist :heading))) 48 | ((org-at-table-p) (funcall ,(plist-get plist :table)))))) 49 | 50 | 51 | (with-eval-after-load "ob-core" 52 | ;; dont ask before running code 53 | (setq org-confirm-babel-evaluate nil) 54 | 55 | ;; set nodepath to use libs in org-babel 56 | (setenv "NODE_PATH" 57 | (concat (getenv "HOME") "/org-babel-config/js/node_modules" ":" 58 | (getenv "NODE_PATH")))) 59 | 60 | (with-eval-after-load "ox-latex" 61 | ;; add ic-tese-v3 class 62 | (add-to-list 63 | 'org-latex-classes 64 | '("ic-tese-v3" "\\documentclass{ic-tese-v3}" 65 | ("\\chapter{%s}" . "\\chapter*{%s}") 66 | ("\\section{%s}" . "\\section*{%s}") 67 | ("\\subsection{%s}" . "\\subsection*{%s}") 68 | ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))) 69 | 70 | 71 | (setq haskell-process-type 'stack-ghci) 72 | 73 | (with-eval-after-load "org" 74 | ;; load extra configs to org mode 75 | (org-babel-lob-ingest (join-path 76 | laurisp-config-dir 77 | "org-mode-extra-configs.org")) 78 | 79 | ;; add languages to list 80 | (org-babel-do-load-languages 81 | 'org-babel-load-languages 82 | '((haskell . t) 83 | (clojure . t) 84 | (emacs-lisp . t) 85 | (python . t) 86 | (js . t) 87 | (C . t) 88 | (latex . t) 89 | (shell . t) 90 | (sql . t))) 91 | 92 | ;; highlight latex 93 | (setq org-highlight-latex-and-related '(latex script entities)) 94 | 95 | ;; org-mode startup 96 | (setq org-startup-folded t) 97 | (setq org-startup-with-latex-preview nil) 98 | 99 | ;; add latex commands inside major mode 100 | (spacemacs/declare-prefix-for-mode 'org-mode "\\" "LaTeX") 101 | (spacemacs/set-leader-keys-for-major-mode 'org-mode 102 | "\\t" 'org-toggle-latex-fragment 103 | "\\b" 'org-beamer-export-to-pdf 104 | "\\e" 'org-env 105 | "\\p" 'compile-org-to-pdf 106 | "\\r" 'insert-reference 107 | "\\c" 'insert-citation 108 | "\\s" 'preview-latex-on-section 109 | "\\b" 'preview-latex-on-buffer 110 | ;; bind hide entry 111 | "hh" 'org-hide-entry 112 | ;; insert src code 113 | "ic" 'insert-org-source 114 | ;; insert custom headings 115 | "ia" 'insert-custom-headers)) 116 | 117 | ;;;###autoload 118 | (defun latex-define-preview-settings (&optional img-scale) 119 | "Define latex format options using the theme" 120 | (interactive) 121 | (let* ((foreground-color (face-attribute 'default :foreground)) 122 | (background-color (face-attribute 'default :background)) 123 | (text-scale (float (if (boundp 'text-scale-mode-amount) text-scale-mode-amount 0))) 124 | (minimum-scale (or img-scale 13)) 125 | (scale (/ (float (+ minimum-scale text-scale)) 10))) 126 | (plist-put org-format-latex-options :scale scale) 127 | (plist-put org-format-latex-options :foreground foreground-color) 128 | (plist-put org-format-latex-options :background background-color))) 129 | 130 | (add-hook 131 | 'org-mode-hook 132 | (lambda () 133 | ;; key-bindings 134 | (local-set-key (kbd "C-") (define-org-cmd 135 | :heading 'org-move-subtree-up 136 | :table 'org-table-move-row-up)) 137 | (local-set-key (kbd "C-") (define-org-cmd 138 | :heading 'org-move-subtree-down 139 | :table 'org-table-move-row-down)) 140 | (local-set-key (kbd "C-") (define-org-cmd 141 | :heading 'org-promote-subtree 142 | :table 'org-table-move-column-left)) 143 | (local-set-key (kbd "C-") (define-org-cmd 144 | :heading 'org-demote-subtree 145 | :table 'org-table-move-column-right)) 146 | ;; force line breaks 147 | (visual-line-mode) 148 | ;; center buffer 149 | (olivetti-mode) 150 | (setq olivetti-minimum-body-width 100) 151 | ;; define latex preview colours and scale 152 | (latex-define-preview-settings) 153 | )) 154 | 155 | 156 | 157 | ;; 158 | ;; PDF 159 | ;; 160 | 161 | (add-hook 'pdf-view-mode-hook (lambda () (linum-mode 0))) 162 | 163 | 164 | 165 | ;; 166 | ;; LaTeX 167 | ;; 168 | 169 | (add-hook 'latex-mode 'visual-line-mode) 170 | 171 | (with-eval-after-load "tex-fold" 172 | ;; fold buffer on opening 173 | (add-hook 'find-file-hook 'TeX-fold-buffer t) 174 | 175 | ;; fold automatically 176 | (setq TeX-fold-auto t) 177 | 178 | ;; fold these envs: 179 | (add-to-list 'TeX-fold-env-spec-list '("[definition]" ("definition"))) 180 | (add-to-list 'TeX-fold-env-spec-list '("[lemma]" ("lemma"))) 181 | (add-to-list 'TeX-fold-env-spec-list '("[theorem]" ("theorem"))) 182 | (add-to-list 'TeX-fold-env-spec-list '("[example]" ("example")))) 183 | 184 | 185 | (spacemacs/declare-prefix-for-mode 'latex-mode "o" "org-edit-functions") 186 | (spacemacs/set-leader-keys-for-major-mode 'latex-mode 187 | "op" 'preview-org-env 188 | "oe" 'org-env-exit 189 | "or" 'insert-reference) 190 | 191 | 192 | -------------------------------------------------------------------------------- /personal-libs/laurisp-core/laurisp-core.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; general related functions 9 | ;; 10 | 11 | ;;;###autoload 12 | (defmacro throw-if (condition &optional error-description) 13 | "if condition is true, thrown an error" 14 | `(if ,condition (error (or ,error-description "")))) 15 | 16 | (defmacro throw-unless (condition &optional error-description) 17 | "if condition is true, thrown an error" 18 | `(unless ,condition (error (or ,error-description "")))) 19 | 20 | ;; 21 | ;; @author Laura Viglioni 22 | ;; 2021 23 | ;; GNU Public License 3.0 24 | ;; 25 | 26 | ;; 27 | ;; misc related functions 28 | ;; 29 | 30 | ;;(require 'functional) 31 | 32 | ;;;###autoload 33 | (defun create-laurisp-core () 34 | (interactive) 35 | (let* ((filename "laurisp-core.el") 36 | (files (directory-files "." t "^l-[a-z\\-].*\\.el$")) 37 | (content (fp/pipe files 38 | ((mapcar 'get-string-from-file) 39 | (string-join))))) 40 | (with-temp-buffer 41 | (insert content) 42 | (insert "\n\n(provide 'laurisp-core)\n") 43 | (write-file filename)) 44 | (byte-compile-file filename))) 45 | 46 | 47 | ;; 48 | ;; @author Laura Viglioni 49 | ;; 2020 50 | ;; GNU Public License 3.0 51 | ;; 52 | ;;(require 'functional) 53 | ;; (require 'l-string) 54 | ;; (require 'l-general) 55 | 56 | ;; 57 | ;; bash related functions 58 | ;; 59 | 60 | ;;;###autoload 61 | (defun gen-uuid-to-clipboard () 62 | "generates uuid and copies it to clipboard" 63 | (interactive) 64 | (let ((uuid (uuidgen-4))) 65 | (kill-new uuid) 66 | (message (format "copied %s to clipboard" uuid)) 67 | uuid)) 68 | 69 | ;;;###autoload 70 | (defun insert-uuid () 71 | "inserts random uuid" 72 | (interactive) 73 | (insert (uuidgen-4))) 74 | 75 | ;;;###autoload 76 | (defun lpwd (&optional dir) 77 | "returns only the pwd path" 78 | (expand-file-name (or dir "."))) 79 | 80 | ;;;###autoload 81 | (defun ls (&optional dir) 82 | "list files in directory" 83 | (throw-if (and dir (not (file-directory-p dir))) (concat dir " does not exist!")) 84 | (directory-files (or dir "."))) 85 | 86 | ;;;###autoload 87 | (defun touch (filename &optional dir) 88 | "Creates a empty file if it does not exists, returns the file or nil" 89 | (throw-if (any-nil? filename) "filename is nil") 90 | (let* ((path (lpwd dir)) 91 | (file (join-path path filename))) 92 | (if (file-exists-p file) 93 | (progn (print "file already exists") nil) 94 | (progn (write-region "" "" file) file)))) 95 | 96 | ;;;###autoload 97 | (defun echo-into (filename text) 98 | "echoes text into file" 99 | (throw-if (any-nil? filename text) "filename or text is nil") 100 | (throw-if (not (file-exists-p filename)) "filename does not exist!") 101 | (write-region text "" filename) t) 102 | 103 | ;;;###autoload 104 | (defun count-non-empty-lines (file) 105 | (throw-if (any-nil? file) "file is nil") 106 | (fp/pipe file 107 | ((get-string-from-file) 108 | (funcall (lambda (string) (split-string string "\n"))) 109 | (seq-filter (lambda (line) (not (equal 0 (string-match-p "^ *$" line))))) 110 | (length)))) 111 | 112 | ;;;###autoload 113 | (defun count-all-laurisp-lines () 114 | (interactive) 115 | (let* ((files-regexp (rx (| (and line-start 116 | (| "l" "test") 117 | (+ (any "-" letter)) 118 | ".el" 119 | line-end) 120 | (and line-start 121 | (+ (any "-" letter)) 122 | ".snippet" 123 | line-end)))) 124 | (files (directory-files-recursively "~/laurisp" files-regexp t)) 125 | (lines (mapcar 'count-non-empty-lines files))) 126 | (print (apply '+ lines)))) 127 | 128 | 129 | 130 | 131 | ;; 132 | ;; @author Laura Viglioni 133 | ;; 2020 134 | ;; GNU Public License 3.0 135 | ;; 136 | 137 | ;; 138 | ;; string related functions 139 | ;; 140 | 141 | ;;(require 'functional) 142 | ;;(require 'l-general) 143 | 144 | ;;;###autoload 145 | (defun join-path (path filename) 146 | "concat path and file. Adds '/' to the end of the path if necessary" 147 | (throw-if (any-nil? path filename) "path or filename is nil") 148 | (concat path (if (string-match-p "/$" path) "" "/") filename)) 149 | 150 | ;;;###autoload 151 | (defun file-extension (filename extension) 152 | "returns filename.extension" 153 | (throw-if (any-nil? filename extension) "filename or extension is nil") 154 | (concat filename "." extension)) 155 | 156 | ;;;###autoload 157 | (defun regex-matches (regexp string &optional pos matches) 158 | "Returns a list of matches" 159 | (throw-if (any-nil? regexp string) "regexp or string is nil") 160 | (save-match-data 161 | (let ((pos 0) 162 | matches) 163 | (while (string-match regexp string pos) 164 | (push (match-string 0 string) matches) 165 | (setq pos (match-end 0))) 166 | matches))) 167 | 168 | 169 | ;;;###autoload 170 | (defun get-string-from-file (filepath) 171 | "Return filepath's file content in a string" 172 | (throw-if (any-nil? filepath) "filepath is nil") 173 | (throw-if (not (file-exists-p filepath)) "file does not exists") 174 | (with-temp-buffer 175 | (insert-file-contents filepath) 176 | (buffer-string))) 177 | 178 | ;;;###autoload 179 | (defun remove-suffix (file-name) 180 | "remove suffix of file-name" 181 | (throw-if (any-nil? file-name) "file-name is nil") 182 | (replace-regexp-in-string "\\.[a-z]*$" "" file-name)) 183 | 184 | ;;;###autoload 185 | (defun go-to-fst-empty-line () 186 | "search the first empty line in buffer and go to it" 187 | (beginning-of-buffer) ;; TODO use ‘(goto-char (point-min))’ instead. 188 | (search-forward-regexp "^$")) 189 | 190 | ;;;###autoload 191 | (defun insert-on-fst-empty-line (text current-pos) 192 | "inserts text on the first empty line of the buffer and 193 | return the cursor to its position" 194 | (throw-if (any-nil? text current-pos) "text or current-pos is nil") 195 | (let* ((empty-line-pos (progn (go-to-fst-empty-line) (point))) 196 | (is-after? (> current-pos empty-line-pos)) 197 | (return-pos (if is-after? 198 | (+ current-pos (length text)) 199 | current-pos))) 200 | (insert text) 201 | (goto-char return-pos) 202 | t)) 203 | 204 | (defun fp/insert-on-fst-empty-line (text) 205 | "inserts text on the first empty line of the buffer and 206 | return the cursor to its position" 207 | (throw-unless (bool text) "text is nil") 208 | (save-excursion 209 | (go-to-fst-empty-line) 210 | (insert (concat text "\n")))) 211 | 212 | 213 | ;;;###autoload 214 | (defun fp/split (separator text) 215 | "(str str) -> [str] 216 | Split a string using the given separator" 217 | (split-string text separator)) 218 | 219 | ;;;###autoload 220 | (defun fp/is-empty? (obj) 221 | "returns if list or string is empty 222 | (list | str) -> bool" 223 | (or (equal "" obj) (equal nil obj))) 224 | 225 | 226 | 227 | (provide 'laurisp-core) 228 | -------------------------------------------------------------------------------- /personal-libs/laurisp-core/laurisp-core.elc: -------------------------------------------------------------------------------- 1 | ;ELC 2 | ;;; Compiled 3 | ;;; in Emacs version 27.2.50 4 | ;;; with all optimizations. 5 | 6 | ;;; This file uses dynamic docstrings, first added in Emacs 19.29. 7 | 8 | ;;; This file does not contain utf-8 non-ASCII characters, 9 | ;;; and so can be loaded in Emacs versions earlier than 23. 10 | 11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 13 | 14 | 15 | #@39 if condition is true, thrown an error 16 | (defalias 'throw-if '(macro . #[(condition &optional error-description) "\302\303\304 \305BBDE\207" [condition error-description if error or ("")] 6 (#$ . 411)])) 17 | #@39 if condition is true, thrown an error 18 | (defalias 'throw-unless '(macro . #[(condition &optional error-description) "\302\303\304 \305BBDE\207" [condition error-description unless error or ("")] 6 (#$ . 619)])) 19 | (defalias 'create-laurisp-core #[nil "\305\306\307\310\311#\312\313\314\n\315\316$) !\317\320!r\fq\210\321\216 c\210\322c\210\323!\210+\324!+\207" [filename files curried-fn content #1=#:temp-buffer "laurisp-core.el" directory-files "." t "^l-[a-z\\-].*\\.el$" ((lambda #2=(&rest args) (apply 'string-join (seq-concatenate #3='list (list) . #4=(args)))) (lambda #2# (apply 'mapcar (seq-concatenate #3# (list 'get-string-from-file) . #4#)))) reduce #[(f g) "\306\307!\306\310!\211\211 L\210)\211 L\210)\311\312\313\314\315D\316D\316 D\317\257E*\207" [#5=#:--cl-g-- #6=#:--cl-f-- #7=#:v f #8=#:v g make-symbol "--f--" "--g--" lambda (&rest --cl-rest--) apply function #[(#9=#:G692 #10=#:G693 &rest args) "J\303 J\n\"!\207" [#10# #9# args apply] 4] quote --cl-rest--] 8] :initial-value #[#2# "\301\302\303\304\305#\"\207" [args apply identity seq-concatenate list nil] 6] generate-new-buffer " *temp*" #[nil "\301!\205 \302!\207" [#1# buffer-name kill-buffer] 2] "\n\n(provide 'laurisp-core)\n" write-file byte-compile-file] 5 nil nil]) 20 | #@43 generates uuid and copies it to clipboard 21 | (defalias 'gen-uuid-to-clipboard #[nil "\301 \302!\210\303\304\305\"!\210)\207" [uuid uuidgen-4 kill-new message format "copied %s to clipboard"] 4 (#$ . 1888) nil]) 22 | #@21 inserts random uuid 23 | (defalias 'insert-uuid #[nil "\300 c\207" [uuidgen-4] 1 (#$ . 2106) nil]) 24 | #@27 returns only the pwd path 25 | (defalias 'lpwd #[(&optional dir) "\301\206\302!\207" [dir expand-file-name "."] 2 (#$ . 2206)]) 26 | #@25 list files in directory 27 | (defalias 'ls #[(&optional dir) "\203\301!\204\302\303P\206\304!\210\305\206\306!\207" [dir file-directory-p error " does not exist!" "" directory-files "."] 3 (#$ . 2338)]) 28 | #@69 Creates a empty file if it does not exists, returns the file or nil 29 | (defalias 'touch #[(filename &optional dir) "\304!\203\n\305\306!\210\307 !\310\n\"\311 !\203!\312\313!\210\314\202(\315\316\211 #\210 *\207" [filename dir path file any-nil\? error "filename is nil" lpwd join-path file-exists-p print "file already exists" nil write-region ""] 4 (#$ . 2554)]) 30 | #@23 echoes text into file 31 | (defalias 'echo-into #[(filename text) "\302 \"\203 \303\304!\210\305!\204\303\306!\210\307 \310#\210\311\207" [filename text any-nil\? error "filename or text is nil" file-exists-p "filename does not exist!" write-region "" t] 4 (#$ . 2929)]) 32 | (defalias 'count-non-empty-lines #[(file) "\302!\203\n\303\304!\210\305\306\307 \310\311$)!\207" [file curried-fn any-nil\? error "file is nil" ((lambda #1=(&rest args) (apply 'length (seq-concatenate #2='list (list) . #3=(args)))) (lambda #1# (apply 'seq-filter (seq-concatenate #2# (list (lambda (line) (not (equal 0 (string-match-p "^ *$" line))))) . #3#))) (lambda #1# (apply 'funcall (seq-concatenate #2# (list (lambda (string) (split-string string "\n"))) . #3#))) (lambda #1# (apply 'get-string-from-file (seq-concatenate #2# (list) . #3#)))) reduce #[(f g) "\306\307!\306\310!\211\211 L\210)\211 L\210)\311\312\313\314\315D\316D\316 D\317\257E*\207" [#4=#:--cl-g-- #5=#:--cl-f-- #6=#:v f #7=#:v g make-symbol "--f--" "--g--" lambda (&rest --cl-rest--) apply function #[(#8=#:G694 #9=#:G695 &rest args) "J\303 J\n\"!\207" [#9# #8# args apply] 4] quote --cl-rest--] 8] :initial-value #[#1# "\301\302\303\304\305#\"\207" [args apply identity seq-concatenate list nil] 6]] 5]) 33 | (defalias 'count-all-laurisp-lines #[nil "\303\304\305\306#\307\310 \"\311\312\313\n\"!+\207" [files-regexp files lines "^\\(?:l\\|test\\)[[:alpha:]-]+\\.el$\\|^[[:alpha:]-]+\\.snippet$" directory-files-recursively "~/laurisp" t mapcar count-non-empty-lines print apply +] 4 nil nil]) 34 | #@68 concat path and file. Adds '/' to the end of the path if necessary 35 | (defalias 'join-path #[(path filename) "\303 \"\203 \304\305!\210\306\307\310\311#)\266\203\203 \312\202!\313 Q\207" [path filename inhibit-changing-match-data any-nil\? error "path or filename is nil" "/$" nil t string-match "" "/"] 8 (#$ . 4490)]) 36 | #@28 returns filename.extension 37 | (defalias 'file-extension #[(filename extension) "\302 \"\203 \303\304!\210\305 Q\207" [filename extension any-nil\? error "filename or extension is nil" "."] 3 (#$ . 4823)]) 38 | #@27 Returns a list of matches 39 | (defalias 'regex-matches #[(regexp string &optional pos matches) "\305 \"\203 \306\307!\210\310 \311\216\312\313\314 \f#\203)\315\312 \" B\312\225\202 ,\207" [regexp string save-match-data-internal matches pos any-nil\? error "regexp or string is nil" match-data #[nil "\301\302\"\207" [save-match-data-internal set-match-data evaporate] 3] 0 nil string-match match-string] 4 (#$ . 5034)]) 40 | #@44 Return filepath's file content in a string 41 | (defalias 'get-string-from-file #[(filepath) "\302!\203\n\303\304!\210\305!\204\303\306!\210\307\310!r q\210\311\216\312!\210\313 +\207" [filepath #1=#:temp-buffer any-nil\? error "filepath is nil" file-exists-p "file does not exists" generate-new-buffer " *temp*" #[nil "\301!\205 \302!\207" [#1# buffer-name kill-buffer] 2] insert-file-contents buffer-string] 2 (#$ . 5468)]) 42 | #@28 remove suffix of file-name 43 | (defalias 'remove-suffix #[(file-name) "\301!\203\n\302\303!\210\304\305\306#\207" [file-name any-nil\? error "file-name is nil" replace-regexp-in-string "\\.[a-z]*$" ""] 4 (#$ . 5905)]) 44 | #@52 search the first empty line in buffer and go to it 45 | (defalias 'go-to-fst-empty-line #[nil "\300 \210\301\302!\207" [beginning-of-buffer search-forward-regexp "^$"] 2 (#$ . 6128)]) 46 | #@94 inserts text on the first empty line of the buffer and 47 | return the cursor to its position 48 | (defalias 'insert-on-fst-empty-line #[(text current-pos) "\305 \"\203 \306\307!\210\310 \210` \nV\211\203 G\\\202 c\210\fb\210+\311\207" [text current-pos empty-line-pos is-after\? return-pos any-nil\? error "text or current-pos is nil" go-to-fst-empty-line t] 4 (#$ . 6313)]) 49 | #@94 inserts text on the first empty line of the buffer and 50 | return the cursor to its position 51 | (defalias 'fp/insert-on-fst-empty-line #[(text) "\301!\204\n\302\303!\210\212\304 \210\305Pc)\207" [text bool error "text is nil" go-to-fst-empty-line "\n"] 2 (#$ . 6700)]) 52 | #@64 (str str) -> [str] 53 | Split a string using the given separator 54 | (defalias 'fp/split #[(separator text) "\302 \"\207" [text separator split-string] 3 (#$ . 6975)]) 55 | #@60 returns if list or string is empty 56 | (list | str) -> bool 57 | (defalias 'fp/is-empty\? #[(obj) "\301\232\206 \302=\207" [obj "" nil] 2 (#$ . 7144)]) 58 | (provide 'laurisp-core) 59 | -------------------------------------------------------------------------------- /personal-libs/functional/test/functional-test.el: -------------------------------------------------------------------------------- 1 | ;;; functional-test.el --- Projectile's test suite -*- lexical-binding: t -*- 2 | 3 | 4 | ;;; Code: 5 | 6 | (require 'buttercup) 7 | (load "./test/buttercup-helpers") 8 | (load "./functional.el") 9 | 10 | ;; 11 | ;; Functions 12 | ;; 13 | 14 | (test-suite "#compose-and-call" 15 | (context "there are more than one arguments to be applied" 16 | (it-should "compose functions in the correct order and apply args" 17 | (expect (compose-and-call 18 | ((+ 1) 19 | (* 2 1)) 2 3)) 20 | :to-be 13)) 21 | (context "functions are from seq lib" 22 | :var ((test-list '(1 2 3 4 5 6 7 8 9 10)) 23 | (expected 55)) 24 | (it-should "compose functions correctly and apply args" 25 | (expect (compose-and-call 26 | ((apply '+) 27 | (seq-concatenate 'list '(1 2 3 4)) 28 | (seq-map (lambda (x) (+ 1 x))) 29 | (seq-filter (lambda (el) (> el 5)))) test-list) 30 | :to-be expected))) 31 | (context "functions receive regex params" 32 | (it-should "properly compose functions and apply args" 33 | (expect (compose-and-call 34 | ((replace-regexp-in-string "foo" "bar")) 35 | "foo bar") :to-equal "bar bar")))) 36 | 37 | (test-suite "#fp/pipe" 38 | (it-should "pipe functions in the correct order" 39 | (expect (fp/pipe 10 40 | ((+ 1) 41 | (* 2))) 42 | :to-be 22))) 43 | 44 | (test-suite "#compose" 45 | (it-should "compose in the correct order" 46 | (expect 47 | (funcall (compose (+ 1) (* 2)) 10) 48 | :to-equal 21))) 49 | 50 | (test-suite "#fp/curry" 51 | (context "there are several arguments" 52 | (it-should "curry correctly" 53 | (expect 54 | (funcall (fp/curry + 1 2 3 4 5) 6 7 8 9 10) 55 | :to-be 55)))) 56 | 57 | ;; 58 | ;; Logic 59 | ;; 60 | 61 | (test-suite "#n-and" 62 | (context "all truthy vals" 63 | (it-should "return nil" 64 | (expect (n-and 1 2 3 t '(1)) :to-be nil))) 65 | (context "at least one falsey element" 66 | (it-should "should return true" 67 | (expect (n-and 1 2 nil) :to-be t) 68 | (expect (n-and nil nil) :to-be t)))) 69 | 70 | (test-suite "#n-or" 71 | (context "all falsey vals" 72 | (it-should "return t" 73 | (expect (n-or nil nil) :to-be t))) 74 | (context "at least one truthy element" 75 | (it-should "should return nil" 76 | (expect (n-or 1 2 nil) :to-be nil) 77 | (expect (n-or 1 2) :to-be nil)))) 78 | 79 | ;; 80 | ;; List 81 | ;; 82 | 83 | (test-suite "#all" 84 | (context "list has at least one nil entry" 85 | (it-should "return nil" 86 | (expect (all '(1 2 3 nil 4)) :to-be nil) 87 | (expect (all '(nil nil nil)) :to-be nil) 88 | (expect (all '("asd" nil 1 nil)) :to-be nil))) 89 | (context "all entries are truthy" 90 | (it-should "return t" 91 | (expect (all '(1 "ase" '(nil) '())) :to-be t)))) 92 | 93 | (test-suite "#any" 94 | (context "list has at least one truthy entry" 95 | (it-should "return t" 96 | (expect (any '(1 2 3 nil 4)) :to-be t) 97 | (expect (any '(nil nil nil 1)) :to-be t) 98 | (expect (any '("asd" nil 1 nil)) :to-be t))) 99 | (context "all entries are nil" 100 | (it-should "return nil" 101 | (expect (any '(nil nil nil)) :to-be nil)))) 102 | 103 | (test-suite "#contains?" 104 | (context "list is nil" 105 | (it-should "return nil" 106 | (expect (contains? nil 2) :to-be nil))) 107 | (context "element is in the list" 108 | (it-should "return t" 109 | (expect (contains? '(1 2 3) 1) :to-be t))) 110 | (context "element is not in the list" 111 | (it-should "return nil" 112 | (expect (contains? '(1 2 3) 4) :to-be nil)))) 113 | 114 | (test-suite "#head" 115 | (context "list is not empty" 116 | (it-should "return the first element" 117 | (expect (head '(1 2 3)) :to-be 1) 118 | (expect (head '(1)) :to-be 1))) 119 | (context "list is empty" 120 | (it-should "return nil" 121 | (expect (head '()) :to-be nil) 122 | (expect (head nil) :to-be nil)))) 123 | 124 | (test-suite "#not-contains?" 125 | (context "list is nil" 126 | (it-should "return nil" 127 | (expect (not-contains? nil 2) :to-be nil))) 128 | (context "element is not in the list" 129 | (it-should "return t" 130 | (expect (not-contains? '(1 2 3) 4) :to-be t))) 131 | (context "element is in the list" 132 | (it-should "return nil" 133 | (expect (not-contains? '(1 2 3) 3) :to-be nil)))) 134 | 135 | (test-suite "#tail" 136 | (context "list is empty" 137 | (it-should "return nil" 138 | (expect (tail '()) :to-be nil) 139 | (expect (tail nil) :to-be nil))) 140 | (context "there is one elment" 141 | (it-should "return nil" 142 | (expect (tail '(1)) :to-be nil))) 143 | (context "list has at least two elements" 144 | (it-should "return the (n-1)th elements of a list" 145 | (expect (tail '(1 2 3 4)) :to-equal '(2 3 4))))) 146 | 147 | (test-suite "#unzip" 148 | (context "list or sublists are empty" 149 | (it-should "return nil" 150 | (expect (unzip nil) :to-be nil) 151 | (expect (unzip '(nil nil nil)) :to-be nil))) 152 | (context "lists have different size" 153 | (it-should "unzip to the size of the smaller" 154 | (expect (unzip '((1 2) nil)) :to-be nil) 155 | (expect (unzip '((1 2) (1))) :to-equal '((1 1))))) 156 | (context "lists have the same size" 157 | (it-should "unzip properly" 158 | (expect (unzip '((1 2 3) (1 2 3))) :to-equal '((1 1) (2 2) (3 3)))))) 159 | 160 | (test-suite "#zip" 161 | (context "all lists are empty" 162 | (it-should "return one empty list" 163 | (expect (zip nil nil nil) :to-be nil) 164 | (expect (zip '() '() '()) :to-be nil))) 165 | (context "the lists have different sizes" 166 | (it-should "zip the size of the smaller list" 167 | (expect (zip '(1 2) '(1) nil) :to-be nil) 168 | (expect (zip '(1 2 3) '(1 2 3 4) '(1)) :to-equal '((1 1 1))))) 169 | (context "lists have the same length" 170 | (it-should "properly zip them" 171 | (expect (zip '(1 1 1 1) '(2 2 2 2) '(3 3 3 3) '(4 4 4 4)) 172 | :to-equal '((1 2 3 4) (1 2 3 4) (1 2 3 4) (1 2 3 4))))) 173 | (context "lists have different types" 174 | (it-should "properly zip them" 175 | (expect (zip '(1 2) '("fst" "snd") '(("list one") ("list two"))) 176 | :to-equal '((1 "fst" ("list one")) (2 "snd" ("list two"))))))) 177 | 178 | ;; 179 | ;; Number 180 | ;; 181 | 182 | (test-suite "#inc" 183 | (context "number is integer" 184 | (it-should "increment number" 185 | (expect (inc 1) :to-be 2) 186 | (expect (inc 0) :to-be 1) 187 | (expect (inc -1) :to-be 0))) 188 | (context "number is not intenger" 189 | (it-should "increment number" 190 | (expect (inc 1.1) :to-equal 2.1)))) 191 | 192 | 193 | ;; 194 | ;; Types 195 | ;; 196 | 197 | (test-suite "#any-nil?" 198 | (context "all truthy vals" 199 | (it-should "return nil" 200 | (expect (any-nil? 1 2 3 t '(1)) :to-be nil))) 201 | (context "at least one falsey element" 202 | (it-should "should return true" 203 | (expect (any-nil? 1 2 nil) :to-be t) 204 | (expect (any-nil? nil nil) :to-be t)))) 205 | 206 | (test-suite "#all-nil?" 207 | (context "all falsey vals" 208 | (it-should "return t" 209 | (expect (all-nil? nil nil) :to-be t))) 210 | (context "at least one truthy element" 211 | (it-should "should return nil" 212 | (expect (all-nil? 1 2 nil) :to-be nil) 213 | (expect (all-nil? 1 2) :to-be nil)))) 214 | 215 | -------------------------------------------------------------------------------- /personal-libs/lautex/lautex.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2021 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; org-latex-pdf related functions 9 | ;; 10 | 11 | (require 'helm) 12 | (message "loading lautex...") 13 | 14 | ;; 15 | ;; latex preview 16 | ;; 17 | 18 | 19 | ;;;###autoload 20 | (defun LauTeX-preview-latex-on-buffer () 21 | (interactive) 22 | (latex-define-preview-settings) 23 | (org-clear-latex-preview) 24 | (org-latex-preview '(16))) 25 | 26 | ;;;###autoload 27 | (defun LauTeX-preview-latex-on-section () 28 | (interactive) 29 | (latex-define-preview-settings) 30 | (org-latex-preview '(4)) 31 | (org-latex-preview)) 32 | 33 | 34 | ;; 35 | ;; common functions 36 | ;; 37 | 38 | ;;;###autoload 39 | (defun LauTex-compile-org-to-pdf () 40 | (interactive) 41 | (if (and (boundp 'org-beamer-mode) org-beamer-mode) 42 | (org-beamer-export-to-pdf) 43 | (org-latex-export-to-pdf))) 44 | 45 | 46 | ;;;###autoload 47 | (defun lautex--get-org-buffer-name (src-buffer) 48 | (replace-regexp-in-string "\\[" "" (nth 2 (split-string src-buffer " ")))) 49 | 50 | ;;;###autoload 51 | (defun lautex--get-org-file-name () 52 | "If in a edit-special buffer, return the org one, 53 | else return the buffer it was called" 54 | (or (buffer-file-name) 55 | (fp/pipe (buffer-name) 56 | ((lautex--get-org-buffer-name) 57 | (get-buffer) 58 | (buffer-file-name))))) 59 | 60 | ;;;###autoload 61 | (defun lautex--get-text (regexp-prefix regexp-suffix str) 62 | "returns string between two regex prefixes" 63 | (fp/pipe str 64 | ((replace-regexp-in-string regexp-prefix "") 65 | (replace-regexp-in-string regexp-suffix "")))) 66 | 67 | ;;;###autoload 68 | (defun lautex--command (command-name arg) 69 | "return string \\command-name{arg}" 70 | (concat "\\" command-name "{" arg "}")) 71 | 72 | ;;;###autoload 73 | (defun lautex--insert-command (command-name arg) 74 | "insert \\command-name{arg}" 75 | (insert (lautex--command command-name arg)) 76 | (delete-horizontal-space)) 77 | 78 | ;; 79 | ;; inserting LaTeX enviroment in org mode 80 | ;; and editing them in special mode 81 | ;; 82 | 83 | (defvar lautex--env-names 84 | (sort '("text" "theorem" "definition" "remark" "example" "proposition" "figure" "Table" "description" "enumerate" "itemize" "list" "math" "displaymath" "split" "array" "eqnarray" "equation" "equation*" "Matrix" "environments" "Cases" "align" "align*" "alignat" "environments" "center" "flushleft" "flushright" "minipage" "quotation" "quote" "verbatim" "verse" "tabbing" "tabular" "Thebibliography" "Titlepage") 'string<)) 85 | 86 | 87 | ;;;###autoload 88 | (defun lautex--insert-env (env-name) 89 | "inserts LaTeX environment" 90 | (insert (concat 91 | (lautex--command "begin" env-name) 92 | "\n\n" 93 | (lautex--command "end" env-name)))) 94 | 95 | (setq lautex--helm-env-sources 96 | (helm-build-sync-source "Environment" 97 | :candidates 'lautex--env-names 98 | :action 'lautex--insert-env)) 99 | 100 | (setq lautex--helm-env-sources-fallback 101 | (helm-build-dummy-source "Environment" 102 | :action 'lautex--insert-env)) 103 | 104 | ;;;###autoload 105 | (defun LauTeX-org-env () 106 | "inserts LaTeX env and opens edit special" 107 | (interactive) 108 | (if (eq 'org-mode major-mode) 109 | (progn 110 | (helm 111 | :history t 112 | :volatile nil 113 | :sources '(lautex--helm-env-sources lautex--helm-env-sources-fallback)) 114 | (org-edit-special) 115 | (previous-line) 116 | (spacemacs/indent-region-or-buffer)))) 117 | 118 | ;;;###autoload 119 | (defun LauTeX-org-env-exit () 120 | "exits edit special and toggle latex fragment to image" 121 | (interactive) 122 | (org-edit-src-exit) 123 | (org-clear-latex-preview (point) (inc (point))) 124 | (org-toggle-latex-fragment)) 125 | 126 | ;;;###autoload 127 | (defun LauTeX-preview-org-env () 128 | "preview on org buffer latex changes in special edit buffer" 129 | (interactive) 130 | (let* ((edit-buff (buffer-name)) 131 | (original-buf (lautex--get-org-buffer-name edit-buff)) 132 | (buffer-exists (bool (get-buffer original-buf)))) 133 | (if buffer-exists 134 | (progn 135 | (org-edit-src-save) 136 | (switch-to-buffer original-buf) 137 | (org-clear-latex-preview (point) (+ 1 (point))) 138 | (org-toggle-latex-fragment) 139 | (switch-to-buffer edit-buff)) 140 | (print (concat "Buffer " original-buf " does not exists!"))))) 141 | 142 | 143 | ;; 144 | ;; Reference existing labels 145 | ;; 146 | (defvar lautex--regex-prefix-label ".*label\{" "regex prefix for \\label{...}") 147 | 148 | (defvar lautex--regex-sufix-label "\}.*" "regex sufix for \\label{...}") 149 | 150 | ;;;###autoload 151 | (defun lautex--get-label (line) 152 | "get string %s in .*\\label{%s}.*" 153 | (fp/pipe line ((lautex--get-text 154 | lautex--regex-prefix-label 155 | lautex--regex-sufix-label) 156 | (replace-regexp-in-string ":CUSTOM_ID: " "")))) 157 | 158 | ;;;###autoload 159 | (defun lautex--insert-reference (label) 160 | "insert \\ref{label} on text" 161 | (let ((label-type (capitalize (lautex--label-type label)))) 162 | (unless (string-empty-p label-type) 163 | (insert (concat label-type " ")))) 164 | (lautex--insert-command "ref" label)) 165 | 166 | ;;;###autoload 167 | (defun lautex--label-type (label) 168 | (let* ((org-label (replace-regexp-in-string ":CUSTOM_ID: " "" label)) 169 | (splitted (split-string org-label ":")) 170 | (label-type (if (= 2 (length splitted)) (head splitted) ""))) 171 | (upcase label-type))) 172 | 173 | ;;;###autoload 174 | (defun lautex--build-reference-candidate (match) 175 | (let* ((label (lautex--get-label match)) 176 | (description (fp/pipe label 177 | ((replace-regexp-in-string ":CUSTOM_ID: " "" label) 178 | (replace-regexp-in-string "[\\._-]" " ") 179 | (replace-regexp-in-string ".*:" "") 180 | (capitalize)))) 181 | (label-type (lautex--label-type label)) 182 | (full-description (if (string-empty-p label-type) 183 | description 184 | (string-join (list label-type description) ": ")))) 185 | (cons full-description label))) 186 | 187 | 188 | ;;;###autoload 189 | (defun lautex--reference-candidates () 190 | "Get all labels from a org/latex file" 191 | (let* ((text (get-string-from-file (lautex--get-org-file-name))) 192 | (matches (regex-matches (rx (| (and "label{" (* nonl) "}") 193 | (and ":CUSTOM_ID:" (? space) (* nonl)))) 194 | text))) 195 | (seq-map 'lautex--build-reference-candidate matches))) 196 | 197 | ;;;###autoload 198 | (defun lautex--helm-label-source () 199 | (helm-build-sync-source "Label Source" 200 | :candidates (lautex--reference-candidates) 201 | :action 'lautex--insert-reference)) 202 | 203 | ;;;###autoload 204 | (defun LauTeX-insert-reference () 205 | (interactive) 206 | (helm :sources (lautex--helm-label-source) 207 | :buffer "*helm buffer source*")) 208 | 209 | 210 | ;; 211 | ;; Insert libs 212 | ;; 213 | (defvar lautex--regex-bib-files "\\.bib$" "regex to match .bib files") 214 | 215 | ;;;###autoload 216 | (defun lautex--insert-citation (citation) 217 | "insert \\ref{citation} on text" 218 | (lautex--insert-command "cite" citation)) 219 | 220 | ;;;###autoload 221 | (defun lautex--get-bib-files () 222 | "get all .bib files in your project from your project root 223 | or where this function is called" 224 | (directory-files-recursively 225 | (or (projectile-project-root) default-directory) 226 | lautex--regex-bib-files)) 227 | 228 | ;;;###autoload 229 | (defun lautex--get-citation (line) 230 | "get string %s in .*\\label{%s}.*" 231 | (fp/pipe line 232 | ((replace-regexp-in-string "@[a-zA-Z]*\{" "") 233 | (replace-regexp-in-string "," "" )))) 234 | 235 | (defun lautex--bib-citations (file-path) 236 | "get all citations from a given file" 237 | (fp/pipe (get-string-from-file file-path) 238 | ((regex-matches "@[a-zA-Z]*\{[a-z0-9A-Z].*,") 239 | (seq-map 'lautex--get-citation)))) 240 | 241 | ;;;###autoload 242 | (defun lautex--bib-info (line) 243 | "get info from a bib line" 244 | (fp/pipe line 245 | ((replace-regexp-in-string "[a-z]* ?= ?\{*" "") 246 | (replace-regexp-in-string "\}.*" "")))) 247 | 248 | ;;;###autoload 249 | (defun lautex--bib-titles (file) 250 | (let* ((file-content (get-string-from-file file)) 251 | (titles (regex-matches "title ?=.*" file-content))) 252 | (seq-map 'lautex--bib-info titles))) 253 | 254 | 255 | ;;;###autoload 256 | (defun lautex--bib-authors (file) 257 | (let* ((file-content (get-string-from-file file)) 258 | (authors (regex-matches "author ?=.*" file-content))) 259 | (seq-map 'lautex--bib-info authors))) 260 | 261 | 262 | ;;;###autoload 263 | (defun lautex--bib-year (file) 264 | (let* ((file-content (get-string-from-file file)) 265 | (year (regex-matches "year ?=.*" file-content))) 266 | (seq-map 'lautex--bib-info year))) 267 | 268 | 269 | ;;;###autoload 270 | (defun lautex--form-candidates (file) 271 | (let ((citations (lautex--bib-citations file)) 272 | (titles (lautex--bib-titles file)) 273 | (years (lautex--bib-year file)) 274 | (authors (lautex--bib-authors file))) 275 | (mapcar* 276 | (lambda (yea tit aut cit) (cons (format "(%s) %s\n%s" yea tit aut) cit)) 277 | years titles authors citations))) 278 | 279 | 280 | ;;;###autoload 281 | (defun lautex--citation-candidates () 282 | "get all citation candidates of all bib files" 283 | (fp/pipe (lautex--get-bib-files) 284 | ((seq-map 'lautex--form-candidates) 285 | (apply 'append) 286 | (fp/alist-sort-by-car)))) 287 | 288 | ;;;###autoload 289 | (defun lautex--helm-citation-source () 290 | (helm-build-sync-source "Label Source" 291 | :volatile t 292 | :multiline t 293 | :candidates (lautex--citation-candidates) 294 | :action 'lautex--insert-citation)) 295 | 296 | ;;;###autoload 297 | (defun LauTeX-insert-citation () 298 | (interactive) 299 | (helm :prompt "Choose a source to cite: " 300 | :sources (lautex--helm-citation-source) 301 | :buffer "*helm buffer source*")) 302 | 303 | 304 | (provide 'lautex) 305 | 306 | ;; 307 | ;; warnings 308 | ;; 309 | 310 | ;; In latex-define-preview-settings: 311 | ;; lautex.el:29:16:Warning: reference to free variable ‘org-format-latex-options’ 312 | 313 | ;; In lautex--get-org-file-name: 314 | ;; lautex.el:70:12:Warning: function ‘reduce’ from cl package called at runtime 315 | 316 | ;; In lautex--get-text: 317 | ;; lautex.el:73:54:Warning: function ‘reduce’ from cl package called at runtime 318 | ;; lautex.el:107:7:Warning: assignment to free variable 319 | ;; ‘lautex--helm-env-sources’ 320 | ;; lautex.el:112:7:Warning: assignment to free variable 321 | ;; ‘lautex--helm-env-sources-fallback’ 322 | 323 | ;; In LauTeX-org-env: 324 | ;; lautex.el:126:10:Warning: ‘previous-line’ is for interactive use only; use 325 | ;; ‘forward-line’ with negative argument instead. 326 | 327 | ;; In lautex--get-label: 328 | ;; lautex.el:163:27:Warning: function ‘reduce’ from cl package called at runtime 329 | ;; lautex.el:178:7:Warning: assignment to free variable ‘mock-org’ 330 | 331 | ;; In lautex--build-reference-candidate: 332 | ;; lautex.el:198:44:Warning: function ‘reduce’ from cl package called at runtime 333 | 334 | ;; In lautex--get-citation: 335 | ;; lautex.el:246:30:Warning: function ‘reduce’ from cl package called at runtime 336 | 337 | ;; In lautex--bib-citations: 338 | ;; lautex.el:252:31:Warning: function ‘reduce’ from cl package called at runtime 339 | 340 | ;; In lautex--bib-info: 341 | ;; lautex.el:259:26:Warning: function ‘reduce’ from cl package called at runtime 342 | 343 | ;; In lautex--form-candidates: 344 | ;; lautex.el:293:77:Warning: function ‘mapcar*’ from cl package called at runtime 345 | 346 | ;; In lautex--citation-candidates: 347 | ;; lautex.el:302:8:Warning: function ‘reduce’ from cl package called at runtime 348 | 349 | ;; In end of data: 350 | ;; lautex.el:322:1:Warning: the following functions are not known to be defined: org-clear-latex-preview, 351 | ;; org-latex-preview, org-beamer-export-to-pdf, org-latex-export-to-pdf, 352 | ;; org-edit-special, org-edit-src-exit, org-toggle-latex-fragment, 353 | ;; org-edit-src-save 354 | 355 | 356 | -------------------------------------------------------------------------------- /lazy-files/custom-icons-definitions.el: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; @author Laura Viglioni 3 | ;; 2020 4 | ;; GNU Public License 3.0 5 | ;; 6 | 7 | ;; 8 | ;; icons-definitions related functions 9 | ;; 10 | 11 | (message "loading custom-icons-definitions...") 12 | 13 | ;;;###autoload 14 | (defun icon-def (regex icon-name &optional face icon-pkg height v-adjust) 15 | (let ((f (or face 'all-the-icons-lpurple)) 16 | (h (or height '1.0)) 17 | (v (or v-adjust '0.0)) 18 | (icon-pack (or icon-pkg 'all-the-icons-fileicon))) 19 | (list regex icon-pack icon-name :height h :v-adjust v :face f))) 20 | 21 | 22 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 23 | ; Javascript family ; 24 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 25 | 26 | (setq js-colour 'all-the-icons-yellow) 27 | (setq 28 | js-icons 29 | (list 30 | (icon-def "\\.styles\\.js$" "pencil" js-colour 'all-the-icons-octicon) 31 | (icon-def "theme\\.js$" "pencil" js-colour 'all-the-icons-octicon) 32 | (icon-def "\\.spec\\.js$" "test-js" js-colour) 33 | (icon-def "\\.test\\.js$" "test-js" js-colour) 34 | (icon-def "\\.js$" "javascript" js-colour 'all-the-icons-alltheicon) 35 | (icon-def "\\.spec\\.jsx$" "test-react" js-colour) 36 | (icon-def "\\.test\\.jsx$" "test-react" js-colour) 37 | (icon-def "\\.jsx$" "jsx-2" js-colour))) 38 | 39 | (setq ts-colour 'all-the-icons-purple) 40 | (setq ts-icons 41 | (list 42 | (icon-def "\\.styles\\.ts$" "pencil" ts-colour 'all-the-icons-octicon) 43 | (icon-def "theme\\.ts$" "pencil" ts-colour 'all-the-icons-octicon) 44 | (icon-def "\\.spec\\.ts$" "test-typescript" ts-colour) 45 | (icon-def "\\.test\\.ts$" "test-typescript" ts-colour) 46 | (icon-def "\\.d\\.ts$" "typescript" ts-colour) 47 | (icon-def "\\.ts$" "typescript" ts-colour) 48 | (icon-def "\\.spec\\.tsx$" "test-typescript" ts-colour) 49 | (icon-def "\\.test\\.tsx$" "test-typescript" ts-colour) 50 | (icon-def "\\.tsx$" "tsx-alt" ts-colour))) 51 | 52 | (setq 53 | other-js-family-icons 54 | '(("\\.node" all-the-icons-alltheicon "nodejs" :height 1.0 :face all-the-icons-green) 55 | ("\\.babelrc$" all-the-icons-fileicon "babel" :face all-the-icons-yellow) 56 | ("\\.npmignore" all-the-icons-fileicon "npm" :face all-the-icons-dred) 57 | ("^package.json$" all-the-icons-fileicon "npm" :face all-the-icons-red) 58 | ("^package.lock.json$" all-the-icons-fileicon "npm" :face all-the-icons-dred) 59 | ("^yarn\\.lock" all-the-icons-fileicon "yarn" :face all-the-icons-blue-alt) 60 | ("\\.es[0-9]$" all-the-icons-alltheicon "javascript" :height 1.0 :v-adjust 0.0 :face all-the-icons-yellow) 61 | ("\\.njs$" all-the-icons-alltheicon "nodejs" :height 1.2 :face all-the-icons-lgreen) 62 | ("\\.vue$" all-the-icons-fileicon "vue" :face all-the-icons-lgreen) 63 | ("\\.react" all-the-icons-alltheicon "react" :height 1.1 :face all-the-icons-lblue))) 64 | 65 | (setq js-family-icons 66 | (append 67 | js-icons 68 | ts-icons 69 | other-js-family-icons)) 70 | 71 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 72 | ; All other icons not organized yet ; 73 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 74 | 75 | (setq 76 | other-icons 77 | '(("\\.tags" all-the-icons-octicon "tag" :height 1.0 :v-adjust 0.0 :face all-the-icons-blue) 78 | ("^TAGS$" all-the-icons-octicon "tag" :height 1.0 :v-adjust 0.0 :face all-the-icons-blue) 79 | ("\\.log" all-the-icons-octicon "bug" :height 1.0 :v-adjust 0.0 :face all-the-icons-maroon) 80 | ("\\.key$" all-the-icons-octicon "key" :v-adjust 0.0 :face all-the-icons-lblue) 81 | ("\\.pem$" all-the-icons-octicon "key" :v-adjust 0.0 :face all-the-icons-orange) 82 | ("\\.p12$" all-the-icons-octicon "key" :v-adjust 0.0 :face all-the-icons-dorange) 83 | ("\\.crt$" all-the-icons-octicon "key" :v-adjust 0.0 :face all-the-icons-lblue) 84 | ("\\.pub$" all-the-icons-octicon "key" :v-adjust 0.0 :face all-the-icons-blue) 85 | ("\\.gpg$" all-the-icons-octicon "key" :v-adjust 0.0 :face all-the-icons-lblue) 86 | ("^TODO$" all-the-icons-octicon "checklist" :v-adjust 0.0 :face all-the-icons-lyellow) 87 | ("^LICENSE$" all-the-icons-octicon "book" :height 1.0 :v-adjust 0.0 :face all-the-icons-blue) 88 | ("^readme" all-the-icons-octicon "book" :height 1.0 :v-adjust 0.0 :face all-the-icons-lcyan) 89 | ("\\.fish" all-the-icons-alltheicon "terminal" :face all-the-icons-lpink) 90 | ("\\.zsh" all-the-icons-alltheicon "terminal" :face all-the-icons-lcyan) 91 | ("\\.sh" all-the-icons-alltheicon "terminal" :face all-the-icons-purple) 92 | ("\\.bashrc$" all-the-icons-alltheicon "script" :height 0.9 :face all-the-icons-dpink) 93 | ("\\.bowerrc$" all-the-icons-alltheicon "bower" :height 1.0 :v-adjust 0.0 :face all-the-icons-silver) 94 | ("^bower.json$" all-the-icons-alltheicon "bower" :height 1.0 :v-adjust 0.0 :face all-the-icons-lorange) 95 | ("\\.ini$" all-the-icons-octicon "settings" :v-adjust 0.0 :face all-the-icons-yellow) 96 | ("\\.eslintignore" all-the-icons-fileicon "eslint" :height 0.9 :face all-the-icons-purple) 97 | ("\\.eslint" all-the-icons-fileicon "eslint" :height 0.9 :face all-the-icons-lpurple) 98 | ("\\.git" all-the-icons-alltheicon "git" :height 1.0 :face all-the-icons-lred) 99 | ("nginx" all-the-icons-fileicon "nginx" :height 0.9 :face all-the-icons-dgreen) 100 | ("apache" all-the-icons-alltheicon "apache" :height 0.9 :face all-the-icons-dgreen) 101 | ("^Makefile$" all-the-icons-fileicon "gnu" :face all-the-icons-dorange) 102 | ("\\.mk$" all-the-icons-fileicon "gnu" :face all-the-icons-dorange) 103 | ("\\.dockerignore$" all-the-icons-fileicon "dockerfile" :height 1.2 :face all-the-icons-dblue) 104 | ("^\\.?Dockerfile" all-the-icons-fileicon "dockerfile" :face all-the-icons-blue) 105 | ("^Brewfile$" all-the-icons-faicon "beer" :face all-the-icons-lsilver) 106 | ("\\.xml$" all-the-icons-faicon "file-code-o" :height 0.95 :face all-the-icons-lorange) 107 | ("^stack.*.json$" all-the-icons-alltheicon "aws" :face all-the-icons-orange) 108 | ("^serverless\\.yml$" all-the-icons-faicon "bolt" :v-adjust 0.0 :face all-the-icons-yellow) 109 | ("\\.[jc]son$" all-the-icons-octicon "settings" :v-adjust 0.0 :face all-the-icons-yellow) 110 | ("\\.ya?ml$" all-the-icons-octicon "settings" :v-adjust 0.0 :face all-the-icons-dyellow) 111 | ("\\.pkg$" all-the-icons-octicon "package" :v-adjust 0.0 :face all-the-icons-dsilver) 112 | ("\\.rpm$" all-the-icons-octicon "package" :v-adjust 0.0 :face all-the-icons-dsilver) 113 | ("\\.elc$" all-the-icons-octicon "file-binary" :v-adjust 0.0 :face all-the-icons-dsilver) 114 | ("\\.gz$" all-the-icons-octicon "file-binary" :v-adjust 0.0 :face all-the-icons-lmaroon) 115 | ("\\.zip$" all-the-icons-octicon "file-zip" :v-adjust 0.0 :face all-the-icons-lmaroon) 116 | ("\\.7z$" all-the-icons-octicon "file-zip" :v-adjust 0.0 :face all-the-icons-lmaroon) 117 | ("\\.dat$" all-the-icons-faicon "bar-chart" :face all-the-icons-cyan :height 0.9) 118 | ("~$" all-the-icons-octicon "lock" :v-adjust 0.0 :face all-the-icons-maroon) 119 | ("\\.dmg$" all-the-icons-octicon "tools" :v-adjust 0.0 :face all-the-icons-lsilver) 120 | ("\\.dll$" all-the-icons-faicon "cogs" :face all-the-icons-silver) 121 | ("\\.DS_STORE$" all-the-icons-faicon "cogs" :face all-the-icons-silver) 122 | ("\\.scpt$" all-the-icons-fileicon "apple" :face all-the-icons-pink) 123 | ("\\.aup$" all-the-icons-fileicon "audacity" :face all-the-icons-yellow) 124 | ("\\.elm" all-the-icons-fileicon "elm" :face all-the-icons-blue) 125 | ("\\.erl$" all-the-icons-alltheicon "erlang" :face all-the-icons-red :v-adjust -0.1 :height 0.9) 126 | ("\\.hrl$" all-the-icons-alltheicon "erlang" :face all-the-icons-dred :v-adjust -0.1 :height 0.9) 127 | ("\\.eex$" all-the-icons-alltheicon "elixir" :face all-the-icons-lorange :v-adjust -0.1 :height 0.9) 128 | ("\\.ex$" all-the-icons-alltheicon "elixir" :face all-the-icons-lpurple :v-adjust -0.1 :height 0.9) 129 | ("\\.exs$" all-the-icons-alltheicon "elixir" :face all-the-icons-lred :v-adjust -0.1 :height 0.9) 130 | ("^mix.lock$" all-the-icons-alltheicon "elixir" :face all-the-icons-lyellow :v-adjust -0.1 :height 0.9) 131 | ("\\.java$" all-the-icons-alltheicon "java" :height 1.0 :face all-the-icons-purple) 132 | ("\\.go$" all-the-icons-alltheicon "go" :height 1.0 :face all-the-icons-blue) 133 | ("\\.mp3$" all-the-icons-faicon "volume-up" :face all-the-icons-dred) 134 | ("\\.wav$" all-the-icons-faicon "volume-up" :face all-the-icons-dred) 135 | ("\\.m4a$" all-the-icons-faicon "volume-up" :face all-the-icons-dred) 136 | ("\\.jl$" all-the-icons-fileicon "julia" :v-adjust 0.0 :face all-the-icons-purple) 137 | ("\\.matlab$" all-the-icons-fileicon "matlab" :face all-the-icons-orange) 138 | ("\\.nix$" all-the-icons-fileicon "nix" :face all-the-icons-blue) 139 | ("\\.p[ml]$" all-the-icons-alltheicon "perl" :face all-the-icons-lorange) 140 | ("\\.pl6$" all-the-icons-fileicon "perl6" :face all-the-icons-cyan) 141 | ("\\.pm6$" all-the-icons-fileicon "perl6" :face all-the-icons-pink) 142 | ("\\.pod$" all-the-icons-alltheicon "perldocs" :height 1.2 :face all-the-icons-lgreen) 143 | ("\\.php$" all-the-icons-fileicon "php" :face all-the-icons-lsilver) 144 | ("\\.pony$" all-the-icons-fileicon "pony" :face all-the-icons-maroon) 145 | ("\\.ps1$" all-the-icons-fileicon "powershell" :face all-the-icons-blue) 146 | ("\\.prol?o?g?$" all-the-icons-alltheicon "prolog" :height 1.1 :face all-the-icons-lmaroon) 147 | ("\\.py$" all-the-icons-alltheicon "python" :height 1.0 :face all-the-icons-dblue) 148 | ("\\.rkt$" all-the-icons-fileicon "racket" :height 1.2 :face all-the-icons-red) 149 | ("^Gemfile\\(\\.lock\\)?$" all-the-icons-alltheicon "ruby-alt" :face all-the-icons-red) 150 | ("\\.gem$" all-the-icons-alltheicon "ruby-alt" :face all-the-icons-red) 151 | ("_?test\\.rb$" all-the-icons-fileicon "test-ruby" :height 1.0 :v-adjust 0.0 :face all-the-icons-red) 152 | ("_?test_helper\\.rb$" all-the-icons-fileicon "test-ruby" :height 1.0 :v-adjust 0.0 :face all-the-icons-dred) 153 | ("_?spec\\.rb$" all-the-icons-fileicon "test-ruby" :height 1.0 :v-adjust 0.0 :face all-the-icons-red) 154 | ("_?spec_helper\\.rb$" all-the-icons-fileicon "test-ruby" :height 1.0 :v-adjust 0.0 :face all-the-icons-dred) 155 | ("\\.rb$" all-the-icons-octicon "ruby" :v-adjust 0.0 :face all-the-icons-lred) 156 | ("\\.rs$" all-the-icons-alltheicon "rust" :height 1.2 :face all-the-icons-maroon) 157 | ("\\.rlib$" all-the-icons-alltheicon "rust" :height 1.2 :face all-the-icons-dmaroon) 158 | ("\\.r[ds]?x?$" all-the-icons-fileicon "R" :face all-the-icons-lblue) 159 | ("\\.sbt$" all-the-icons-fileicon "sbt" :face all-the-icons-red) 160 | ("\\.scala$" all-the-icons-alltheicon "scala" :face all-the-icons-red) 161 | ("\\.scm$" all-the-icons-fileicon "scheme" :height 1.2 :face all-the-icons-red) 162 | ("\\.swift$" all-the-icons-alltheicon "swift" :height 1.0 :v-adjust -0.1 :face all-the-icons-green) 163 | 164 | ("-?spec\\." all-the-icons-fileicon "test-generic" :height 1.0 :v-adjust 0.0 :face all-the-icons-dgreen) 165 | ("-?test\\." all-the-icons-fileicon "test-generic" :height 1.0 :v-adjust 0.0 :face all-the-icons-dgreen) 166 | ("\\.tf\\(vars\\|state\\)?$" all-the-icons-fileicon "terraform" :height 1.0 :face all-the-icons-purple-alt) 167 | ("\\.v$" all-the-icons-fileicon "verilog" :height 1.0 :v-adjust -0.2 :face all-the-icons-red) 168 | ("\\.vams$" all-the-icons-fileicon "verilog" :height 1.0 :v-adjust -0.2 :face all-the-icons-red) 169 | ("\\.sv$" all-the-icons-fileicon "verilog" :height 1.0 :v-adjust -0.2 :face all-the-icons-red) 170 | ("\\.sva$" all-the-icons-fileicon "verilog" :height 1.0 :v-adjust -0.2 :face all-the-icons-red) 171 | ("\\.svh$" all-the-icons-fileicon "verilog" :height 1.0 :v-adjust -0.2 :face all-the-icons-red) 172 | ("\\.svams$" all-the-icons-fileicon "verilog" :height 1.0 :v-adjust -0.2 :face all-the-icons-red) 173 | ("\\.vhd$" all-the-icons-fileicon "vhdl" :face all-the-icons-blue) 174 | ("\\.vhdl$" all-the-icons-fileicon "vhdl" :face all-the-icons-blue) 175 | ("\\.vhms$" all-the-icons-fileicon "vhdl" :face all-the-icons-blue) 176 | ("\\.cabal$" all-the-icons-fileicon "cabal" :face all-the-icons-lblue) 177 | ("\\.kt$" all-the-icons-fileicon "kotlin" :face all-the-icons-orange) 178 | ("\\.kts$" all-the-icons-fileicon "kotlin" :face all-the-icons-orange) 179 | ("\\.nim$" all-the-icons-fileicon "nimrod" :face all-the-icons-yellow) 180 | ("\\.nims$" all-the-icons-fileicon "nimrod" :face all-the-icons-yellow) 181 | ("\\.sql$" all-the-icons-octicon "database" :face all-the-icons-silver) 182 | ("\\.styles$" all-the-icons-material "style" :face all-the-icons-red) 183 | ("\\.lua$" all-the-icons-fileicon "lua" :face all-the-icons-dblue) 184 | ("\\.adoc$" all-the-icons-fileicon "asciidoc" :face all-the-icons-lblue) 185 | ("\\.asciidoc$" all-the-icons-fileicon "asciidoc" :face all-the-icons-lblue) 186 | ("\\.pp$" all-the-icons-fileicon "puppet" :face all-the-icons-yellow) 187 | ("\\.j2$" all-the-icons-fileicon "jinja" :face all-the-icons-silver) 188 | ("\\.jinja2$" all-the-icons-fileicon "jinja" :face all-the-icons-silver) 189 | ("\\.dockerfile$" all-the-icons-fileicon "dockerfile" :face all-the-icons-cyan) 190 | ("\\.vagrantfile$" all-the-icons-fileicon "vagrant" :face all-the-icons-blue) 191 | ("\\.c$" all-the-icons-alltheicon "c-line" :face all-the-icons-blue) 192 | ("\\.h$" all-the-icons-alltheicon "c-line" :face all-the-icons-purple) 193 | ("\\.m$" all-the-icons-fileicon "apple" :v-adjust 0.0 :height 1.0) 194 | ("\\.mm$" all-the-icons-fileicon "apple" :v-adjust 0.0 :height 1.0) 195 | ("\\.c\\(c\\|pp\\|xx\\)$" all-the-icons-alltheicon "cplusplus-line" :v-adjust -0.2 :face all-the-icons-blue) 196 | ("\\.h\\(h\\|pp\\|xx\\)$" all-the-icons-alltheicon "cplusplus-line" :v-adjust -0.2 :face all-the-icons-purple) 197 | ("\\.csx?$" all-the-icons-alltheicon "csharp-line" :face all-the-icons-dblue) 198 | ("\\.cljc?$" all-the-icons-alltheicon "clojure-line" :height 1.0 :face all-the-icons-blue :v-adjust 0.0) 199 | ("\\.cljs$" all-the-icons-fileicon "cljs" :height 1.0 :face all-the-icons-dblue :v-adjust 0.0) 200 | ("\\.coffee$" all-the-icons-alltheicon "coffeescript" :height 1.0 :face all-the-icons-maroon) 201 | ("\\.iced$" all-the-icons-alltheicon "coffeescript" :height 1.0 :face all-the-icons-lmaroon) 202 | ("\\.dart$" all-the-icons-fileicon "dart" :height 1.0 :face all-the-icons-blue :v-adjust 0.0) 203 | ("^MERGE_" all-the-icons-octicon "git-merge" :v-adjust 0.0 :face all-the-icons-red) 204 | ("^COMMIT_EDITMSG" all-the-icons-octicon "git-commit" :v-adjust 0.0 :face all-the-icons-red) 205 | ("\\.cl$" all-the-icons-fileicon "clisp" :face all-the-icons-lorange) 206 | ("\\.l\\(isp\\)?$" all-the-icons-fileicon "lisp" :face all-the-icons-orange) 207 | ("\\.el$" all-the-icons-fileicon "elisp" :height 1.0 :v-adjust -0.2 :face all-the-icons-purple) 208 | ("\\.css$" all-the-icons-alltheicon "css3" :face all-the-icons-yellow) 209 | ("\\.scss$" all-the-icons-alltheicon "sass" :face all-the-icons-pink) 210 | ("\\.sass$" all-the-icons-alltheicon "sass" :face all-the-icons-dpink) 211 | ("\\.less$" all-the-icons-alltheicon "less" :height 0.8 :face all-the-icons-dyellow) 212 | ("\\.postcss$" all-the-icons-fileicon "postcss" :face all-the-icons-dred) 213 | ("\\.sss$" all-the-icons-fileicon "postcss" :face all-the-icons-dred) 214 | ("\\.styl$" all-the-icons-alltheicon "stylus" :face all-the-icons-lgreen) 215 | ("stylelint" all-the-icons-fileicon "stylelint" :face all-the-icons-lyellow) 216 | ("\\.csv$" all-the-icons-octicon "graph" :v-adjust 0.0 :face all-the-icons-dblue) 217 | ("\\.hs$" all-the-icons-alltheicon "haskell" :height 1.0 :face all-the-icons-red) 218 | ("\\.chs$" all-the-icons-alltheicon "haskell" :height 1.0 :face all-the-icons-red) 219 | ("\\.lhs$" all-the-icons-alltheicon "haskell" :height 1.0 :face all-the-icons-red) 220 | ("\\.hsc$" all-the-icons-alltheicon "haskell" :height 1.0 :face all-the-icons-red) 221 | ("\\.inky-haml$" all-the-icons-fileicon "haml" :face all-the-icons-lyellow) 222 | ("\\.haml$" all-the-icons-fileicon "haml" :face all-the-icons-lyellow) 223 | ("\\.html?$" all-the-icons-alltheicon "html5" :face all-the-icons-orange) 224 | ("\\.inky-erb?$" all-the-icons-alltheicon "html5" :face all-the-icons-lred) 225 | ("\\.erb$" all-the-icons-alltheicon "html5" :face all-the-icons-lred) 226 | ("\\.hbs$" all-the-icons-fileicon "moustache" :face all-the-icons-green) 227 | ("\\.inky-slim$" all-the-icons-octicon "dashboard" :v-adjust 0.0 :face all-the-icons-yellow) 228 | ("\\.slim$" all-the-icons-octicon "dashboard" :v-adjust 0.0 :face all-the-icons-yellow) 229 | ("\\.jade$" all-the-icons-fileicon "jade" :face all-the-icons-red) 230 | ("\\.pug$" all-the-icons-fileicon "pug-alt" :face all-the-icons-red) 231 | ("^gulpfile" all-the-icons-alltheicon "gulp" :height 1.0 :face all-the-icons-lred) 232 | ("^gruntfile" all-the-icons-alltheicon "grunt" :height 1.0 :v-adjust -0.1 :face all-the-icons-lyellow) 233 | ("^webpack" all-the-icons-fileicon "webpack" :face all-the-icons-lblue) 234 | ("\\.d3\\.?js" all-the-icons-alltheicon "d3" :height 0.8 :face all-the-icons-lgreen) 235 | ("\\.re$" all-the-icons-fileicon "reason" :height 1.0 :face all-the-icons-red-alt) 236 | ("\\.rei$" all-the-icons-fileicon "reason" :height 1.0 :face all-the-icons-dred) 237 | ("\\.ml$" all-the-icons-fileicon "ocaml" :height 1.0 :face all-the-icons-lpink) 238 | ("\\.mli$" all-the-icons-fileicon "ocaml" :height 1.0 :face all-the-icons-dpink) 239 | ("\\.ico$" all-the-icons-octicon "file-media" :v-adjust 0.0 :face all-the-icons-blue) 240 | ("\\.png$" all-the-icons-octicon "file-media" :v-adjust 0.0 :face all-the-icons-orange) 241 | ("\\.gif$" all-the-icons-octicon "file-media" :v-adjust 0.0 :face all-the-icons-green) 242 | ("\\.jpe?g$" all-the-icons-octicon "file-media" :v-adjust 0.0 :face all-the-icons-dblue) 243 | ("\\.svg$" all-the-icons-alltheicon "svg" :height 0.9 :face all-the-icons-lgreen) 244 | ("\\.mov" all-the-icons-faicon "film" :face all-the-icons-blue) 245 | ("\\.mp4" all-the-icons-faicon "film" :face all-the-icons-blue) 246 | ("\\.ogv" all-the-icons-faicon "film" :face all-the-icons-dblue) 247 | ("\\.mkv" all-the-icons-faicon "film" :face all-the-icons-blue) 248 | ("\\.webm" all-the-icons-faicon "film" :face all-the-icons-blue) 249 | ("\\.ttf$" all-the-icons-fileicon "font" :v-adjust 0.0 :face all-the-icons-dcyan) 250 | ("\\.woff2?$" all-the-icons-fileicon "font" :v-adjust 0.0 :face all-the-icons-cyan) 251 | ("\\.pdf" all-the-icons-octicon "file-pdf" :v-adjust 0.0 :face all-the-icons-dred) 252 | ("\\.te?xt" all-the-icons-octicon "file-text" :v-adjust 0.0 :face all-the-icons-cyan) 253 | ("\\.doc[xm]?$" all-the-icons-fileicon "word" :face all-the-icons-blue) 254 | ("\\.texi?$" all-the-icons-fileicon "tex" :face all-the-icons-lred) 255 | ("\\.md$" all-the-icons-octicon "markdown" :v-adjust 0.0 :face all-the-icons-lblue) 256 | ("\\.bib$" all-the-icons-fileicon "bib" :face all-the-icons-maroon) 257 | ("\\.org$" all-the-icons-fileicon "org" :face all-the-icons-lgreen) 258 | ("\\.pp[st]$" all-the-icons-fileicon "powerpoint" :face all-the-icons-orange) 259 | ("\\.pp[st]x$" all-the-icons-fileicon "powerpoint" :face all-the-icons-red) 260 | ("\\.knt$" all-the-icons-fileicon "powerpoint" :face all-the-icons-cyan) 261 | ("bookmark" all-the-icons-octicon "bookmark" :height 1.1 :v-adjust 0.0 :face all-the-icons-lpink) 262 | ("\\.cache$" all-the-icons-octicon "database" :height 1.0 :v-adjust 0.0 :face all-the-icons-green) 263 | ("^\\*scratch\\*$" all-the-icons-faicon "sticky-note" :face all-the-icons-lyellow) 264 | ("^\\*scratch.*" all-the-icons-faicon "sticky-note" :face all-the-icons-yellow) 265 | ("^\\*new-tab\\*$" all-the-icons-material "star" :face all-the-icons-cyan) 266 | ("^\\." all-the-icons-octicon "gear" :v-adjust 0.0) 267 | (".?" all-the-icons-faicon "file-o" :v-adjust 0.0 :face all-the-icons-dsilver))) 268 | 269 | 270 | (setq custom-icons 271 | (append 272 | js-family-icons 273 | other-icons)) 274 | 275 | ;; (setq all-the-icons-icon-alist icons-definitions) 276 | 277 | (provide 'custom-icons-definitions) 278 | 279 | ;; 280 | ;; warnings 281 | ;; 282 | ;; custom-icons-definitions.el:26:7:Warning: assignment to free variable 283 | ;; ‘js-colour’ 284 | ;; custom-icons-definitions.el:31:36:Warning: reference to free variable 285 | ;; ‘js-colour’ 286 | ;; custom-icons-definitions.el:28:2:Warning: assignment to free variable 287 | ;; ‘js-icons’ 288 | ;; custom-icons-definitions.el:39:7:Warning: assignment to free variable 289 | ;; ‘ts-colour’ 290 | ;; custom-icons-definitions.el:43:41:Warning: reference to free variable 291 | ;; ‘ts-colour’ 292 | ;; custom-icons-definitions.el:40:7:Warning: assignment to free variable 293 | ;; ‘ts-icons’ 294 | ;; custom-icons-definitions.el:53:2:Warning: assignment to free variable 295 | ;; ‘other-js-family-icons’ 296 | ;; custom-icons-definitions.el:67:8:Warning: reference to free variable 297 | ;; ‘js-icons’ 298 | ;; custom-icons-definitions.el:68:8:Warning: reference to free variable 299 | ;; ‘ts-icons’ 300 | ;; custom-icons-definitions.el:69:8:Warning: reference to free variable 301 | ;; ‘other-js-family-icons’ 302 | ;; custom-icons-definitions.el:65:7:Warning: assignment to free variable 303 | ;; ‘js-family-icons’ 304 | ;; custom-icons-definitions.el:79:8:Warning: reference to free variable 305 | ;; ‘js-family-icons’ 306 | ;; custom-icons-definitions.el:77:7:Warning: assignment to free variable 307 | ;; ‘custom-icons-definitions’ 308 | 309 | --------------------------------------------------------------------------------