-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
307 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
;; ((org-mode | ||
;; (eval add-hook! 'after-save-hook | ||
;; '(lambda () (if (y-or-n-p "Tangle?") | ||
;; (org-babel-tangle) | ||
;; t)) nil t))) | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
# BEHAVIOR CHANGES | ||
############################################################################## | ||
# fish_vi_key_bindings | ||
# fish_hybrid_key_bindings | ||
# fish_default_key_bindings | ||
# [[file:oh-my-fish.org::*Path][Path:1]] | ||
set -x PATH \ | ||
$HOME/.npm-global/bin \ | ||
$HOME/bin \ | ||
$HOME/.yarn/bin \ | ||
$HOME/.config/yarn/global/node_modules/.bin \ | ||
$HOME/.luarocks/bin \ | ||
$HOME/.emacs.d/bin \ | ||
/usr/local/bin \ | ||
/usr/local/opt/openjdk/bin \ | ||
/usr/bin \ | ||
/usr/sbin \ | ||
/sbin \ | ||
/usr/local/MacGPG2/bin \ | ||
/Library/Frameworks/Mono.framework/Versions/Current/bin \ | ||
$PATH | ||
# Path:1 ends here | ||
|
||
# PATH | ||
############################################################################## | ||
set -x PATH $HOME/.npm-global/bin $HOME/bin $HOME/.yarn/bin $HOME/.config/yarn/global/node_modules/.bin $PATH | ||
set -x PATH $HOME/.luarocks/bin /usr/local/bin $HOME/.emacs.d/bin $PATH | ||
set -x LUA_PATH '$HOME/.luarocks/share/lua/5.3/?.lua;$HOME/.luarocks/share/lua/5.3/?/init.lua;/usr/local/share/lua/5.3/?.lua;/usr/local/share/lua/5.3/?/init.lua;/usr/local/Cellar/luarocks/3.1.3/share/lua/5.3/?.lua;/usr/local/lib/lua/5.3/?.lua;/usr/local/lib/lua/5.3/?/init.lua;./?.lua;./?/init.lua' | ||
set -x LUA_CPATH '$HOME/.luarocks/lib/lua/5.3/?.so;/usr/local/lib/lua/5.3/?.so;/usr/local/lib/lua/5.3/loadall.so;./?.so' | ||
|
||
# CONFIG | ||
############################################################################## | ||
# set -gx JAVA_TOOL_OPTIONS "--add-modules=java.xml.bind" | ||
|
||
# Conditional Configs | ||
############################################################################## | ||
# [[file:oh-my-fish.org::*Bindings][Bindings:1]] | ||
fish_default_key_bindings | ||
# Bindings:1 ends here | ||
|
||
# DIR ENV | ||
############################################################################## | ||
# [[file:oh-my-fish.org::*Dir Env][Dir Env:1]] | ||
direnv hook fish | source | ||
# Dir Env:1 ends here | ||
|
||
|
||
# Nix | ||
############################################################################## | ||
# set -x NIX_PATH "darwin-config=$HOME/.nixpkgs/darwin-configuration.nix:$HOME/.nix-defexpr/channels" | ||
# source ~/dotfiles/client/nix/nix.fish | ||
# echo "$NIX_PATH" | ||
# [[file:oh-my-fish.org::*ASDF Version Manager][ASDF Version Manager:1]] | ||
source (brew --prefix asdf)"/asdf.fish" | ||
# ASDF Version Manager:1 ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# [[file:oh-my-fish.org::*Setup Install Script][Setup Install Script:1]] | ||
#!/usr/bin/env bash | ||
# Setup Install Script:1 ends here | ||
|
||
# [[file:oh-my-fish.org::*Install Fish][Install Fish:1]] | ||
brew install fish | ||
# Install Fish:1 ends here | ||
|
||
# [[file:oh-my-fish.org::*Change Default Shell][Change Default Shell:1]] | ||
which fish | sudo tee -a /etc/shells | ||
chsh -s `which fish` | ||
# Change Default Shell:1 ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#+title: Oh My Fish | ||
:CONFIG: | ||
#+property: header-args:fish :tangle init.fish | ||
#+property: header-args:bash :tangle install.sh | ||
#+property: header-args :mkdirp yes | ||
#+startup: indent | ||
:END: | ||
|
||
|
||
* Install | ||
|
||
** Setup Install Script | ||
|
||
Generate shebang for install.sh script | ||
|
||
#+begin_src bash | ||
#!/usr/bin/env bash | ||
#+end_src | ||
|
||
** Install Fish | ||
#+begin_src bash | ||
brew install fish | ||
#+end_src | ||
|
||
** Change Default Shell | ||
|
||
#+begin_src bash | ||
which fish | sudo tee -a /etc/shells | ||
chsh -s `which fish` | ||
#+end_src | ||
|
||
* Config | ||
|
||
** Path | ||
|
||
Determines which binaries and executables are always accessible without having | ||
to specify a path prefix. | ||
|
||
#+begin_src fish | ||
set -x PATH \ | ||
$HOME/.npm-global/bin \ | ||
$HOME/bin \ | ||
$HOME/.yarn/bin \ | ||
$HOME/.config/yarn/global/node_modules/.bin \ | ||
$HOME/.luarocks/bin \ | ||
$HOME/.emacs.d/bin \ | ||
/usr/local/bin \ | ||
/usr/local/opt/openjdk/bin \ | ||
/usr/bin \ | ||
/usr/sbin \ | ||
/sbin \ | ||
/usr/local/MacGPG2/bin \ | ||
/Library/Frameworks/Mono.framework/Versions/Current/bin \ | ||
$PATH | ||
#+end_src | ||
|
||
** Bindings | ||
|
||
#+begin_src fish | ||
fish_default_key_bindings | ||
#+end_src | ||
|
||
* Plugins | ||
|
||
** Dir Env | ||
|
||
Loads .envrc files when entering into a directory | ||
https://direnv.net/docs/hook.html#fish | ||
|
||
#+begin_src fish | ||
direnv hook fish | source | ||
#+end_src | ||
|
||
** ASDF Version Manager | ||
|
||
A version manager for a wide variety of tools such as node. | ||
http://asdf-vm.com/guide/getting-started.html#_3-install-asdf | ||
|
||
#+begin_src fish | ||
source (brew --prefix asdf)"/asdf.fish" | ||
#+end_src | ||
|
||
|
||
;; Local Variables: | ||
;; eval: (add-hook 'after-save-hook (lambda ()(if (y-or-n-p "Tangle?")(org-babel-tangle))) nil t) | ||
;; End: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
;; [[file:testing.org::*Emacs Advice Test][Emacs Advice Test:1]] | ||
(defun some-fun (&rest args) | ||
(string-join (cons "original" args) " ")) | ||
;; Emacs Advice Test:1 ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#+title: Emacs Advice Test | ||
#+property: header-args :tangle advice-test.el | ||
|
||
* Emacs Advice Test | ||
|
||
Implementing an advising system for [[https://fennel-lang.org][fennel-lang]] for use in the OS X [[https://github.com/agzam/spacehammer/][Spacehammer]] | ||
configuration framework. | ||
|
||
** Original function definition | ||
|
||
#+begin_src elisp | ||
(defun some-fun (&rest args) | ||
(message "original some-fun called %s" (string-join args " ")) | ||
(string-join (cons "original" args) " ")) | ||
#+end_src | ||
|
||
#+RESULTS: | ||
: some-fun | ||
|
||
** Advice | ||
|
||
*** Before 3 | ||
|
||
#+begin_src elisp :results none | ||
(defadvice! advtest-before-3 (&rest args) | ||
"Before test 3" | ||
:before #'some-fun | ||
(message "before-3 args: %s" (string-join args " "))) | ||
#+end_src | ||
|
||
*** Before 1 | ||
|
||
#+begin_src elisp :results none | ||
(defadvice! advtest-before-1 (&rest args) | ||
"Before test 1" | ||
:before #'some-fun | ||
(message "before-1 args: %s" (string-join args " "))) | ||
#+end_src | ||
|
||
*** Before-While 1 | ||
|
||
#+begin_src elisp :results none | ||
(defadvice! advtest-before-while-1 (&rest args) | ||
"Before-while test 1" | ||
:before-while #'some-fun | ||
(message "before-while-1 args: %s" (string-join args " ")) | ||
nil) | ||
#+end_src | ||
|
||
|
||
*** After 1 | ||
|
||
#+begin_src elisp :results none | ||
(defadvice! advtest-after-1 (&rest args) | ||
"After test 1" | ||
:after #'some-fun | ||
(message "after-1 args: %s" (string-join args " "))) | ||
#+end_src | ||
|
||
*** Before 2 | ||
|
||
#+begin_src elisp :results none | ||
(defadvice! advtest-before-2 (&rest args) | ||
"Before test 2" | ||
:before #'some-fun | ||
(message "before-2 args: %s" (string-join args " "))) | ||
#+end_src | ||
|
||
** Test Advice | ||
|
||
#+begin_src elisp :tangle no | ||
(some-fun "one" "two") | ||
#+end_src | ||
|
||
#+RESULTS: | ||
|
||
** Debugging & Reset | ||
|
||
:PROPERTIES: | ||
:header-args: :tangle no | ||
:END: | ||
|
||
#+begin_src elisp | ||
(describe-function #'some-fun) | ||
#+end_src | ||
|
||
#+RESULTS: | ||
: some-fun is a Lisp function. | ||
: | ||
: (some-fun &rest ARGS) | ||
: | ||
: Not documented. | ||
|
||
#+begin_src elisp | ||
(defun advice-unadvice (sym) | ||
"Remove all advices from symbol SYM." | ||
(interactive "aFunction symbol: ") | ||
(advice-mapc (lambda (advice _props) (advice-remove sym advice)) sym)) | ||
#+end_src | ||
|
||
#+RESULTS: | ||
: advice-unadvice | ||
|
||
#+begin_src elisp | ||
(advice-unadvice #'some-fun) | ||
#+end_src | ||
|
||
#+RESULTS: | ||
|
||
** Results | ||
|
||
1. Advice is additive, supports multiple of same type | ||
2. Advice fires last-added-runs-first | ||
3. Types of advice processed at specific times: before and before-while are | ||
processed together before calling the original function | ||
4. In the case of before-while, the before and after advice that added after the | ||
=before-while= advice did run. The =before= advice added earlier will not run if | ||
=before-while= returns ~nil~. | ||
a. Does this mean that if before-while returns false it short-circuits the | ||
remaining advice defined before it, which would run after =before-while=? |
Oops, something went wrong.