diff --git a/dotfiles/emacs.d b/dotfiles/emacs.d index f0067856..4c68b4f2 160000 --- a/dotfiles/emacs.d +++ b/dotfiles/emacs.d @@ -1 +1 @@ -Subproject commit f0067856bffe9ae3255e842c637e675330a68acf +Subproject commit 4c68b4f2ae2ca0ff178fceeda0ea0dc340c218a3 diff --git a/dotfiles/lib/shellrc/emacs.sh b/dotfiles/lib/shellrc/emacs.sh index d607ae97..4df19aba 100644 --- a/dotfiles/lib/shellrc/emacs.sh +++ b/dotfiles/lib/shellrc/emacs.sh @@ -1,12 +1,12 @@ +alias e='emacs_open' alias emacs='_emacs -c -n ' is_osx && alias emacs='cocoa_emacs' alias terminal_emacs='_emacs -t' -alias ec='_emacs -n ' export GLOBAL_EMACS="" is_ssh && emacs="terminal_emacs" function cocoa_emacs { - reattach-to-user-namespace zsh -c "source ~/.zshrc && _emacs -c -n" + reattach-to-user-namespace zsh -c 'source ~/.zshrc && _emacs -c -n "$@"' } function _emacs { @@ -46,21 +46,26 @@ function existing_emacs { } function emacs_make_frame_if_none_exists { - emacsclient -e '(make-frame-if-none-exists)' --server-file=$1 + emacsclient -e '(make-frame-if-none-exists-and-focus)' --server-file=$1 + focus_emacs } -function get_running_emacs_instances { +function focus_emacs { + osascript -e 'tell application "Emacs" to activate' +} + +function emacs_get_running_instances { pgrep -i emacs | xargs ps -o command -p | egrep -o " --daemon=(.*)" | awk -F= '{print $2}' | sed 's/\^J3,4\^J//' } function emacs_open { - local server_file="$(get_running_emacs_instances | head -n1)" - if [ -z $server_file ]; then - _emacs -c -n "$@" - return + if ! emacs_daemon_exists; then + emacs fi + local server_file="$(emacs_get_running_instances | head -n1)" emacs_make_frame_if_none_exists $server_file [ ! -z "$@" ] && emacsclient "$@" -n --server-file="$server_file" + focus_emacs } # Make emacs the default editor. diff --git a/dotfiles/lib/zsh/system-wide-clipboard.zsh b/dotfiles/lib/zsh/system-wide-clipboard.zsh new file mode 100644 index 00000000..65535fa7 --- /dev/null +++ b/dotfiles/lib/zsh/system-wide-clipboard.zsh @@ -0,0 +1,48 @@ +pb-kill-line () { + zle kill-line + echo -n $CUTBUFFER | clipboard +} + +pb-kill-whole-line () { + zle kill-whole-line + echo -n $CUTBUFFER | clipboard +} + +pb-backward-kill-word () { + zle backward-kill-word + echo -n $CUTBUFFER | clipboard +} + +pb-kill-word () { + zle kill-word + echo -n $CUTBUFFER | clipboard +} + +pb-kill-buffer () { + zle kill-buffer + echo -n $CUTBUFFER | clipboard +} + +pb-copy-region-as-kill-deactivate-mark () { + zle copy-region-as-kill + zle set-mark-command -n -1 + echo -n $CUTBUFFER | clipboard +} + +pb-yank () { + CUTBUFFER=$(pbpaste) + zle yank +} + +zle -N pb-kill-line +zle -N pb-kill-whole-line +zle -N pb-backward-kill-word +zle -N pb-kill-word +zle -N pb-kill-buffer +zle -N pb-copy-region-as-kill-deactivate-mark +zle -N pb-yank + +bindkey '^K' pb-kill-line +bindkey '^U' pb-kill-whole-line +bindkey '\ew' pb-copy-region-as-kill-deactivate-mark +bindkey '\eW' pb-copy-region-as-kill-deactivate-mark \ No newline at end of file diff --git a/resources/Emacs.app/Contents/Info.plist b/resources/Emacs.app/Contents/Info.plist index c4e0860c..36fe9d29 100644 --- a/resources/Emacs.app/Contents/Info.plist +++ b/resources/Emacs.app/Contents/Info.plist @@ -15,7 +15,8 @@ CFBundleTypeExtensions - * + * + org CFBundleTypeName Automator workflow file