Updates to use emacsclient and daemon

This commit is contained in:
Salar Rahmanian 2020-11-28 15:08:09 -08:00
parent 0e1b18cb0d
commit 095e7b7232
5 changed files with 61 additions and 4 deletions

View file

@ -1,2 +0,0 @@
#!/bin/bash
emacs -nw $@

19
gnu.emacs.daemon.plist Normal file
View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>gnu.emacs.daemon</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Emacs.app/Contents/MacOS/Emacs</string>
<string>--daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>salar</string>
</dict>
</plist>

View file

@ -18,7 +18,9 @@
home.stateVersion = "20.09"; home.stateVersion = "20.09";
home.sessionVariables = { home.sessionVariables = {
EDITOR = "nvim"; EDITOR = "$HOME/bin/run-emacsclient-cli";
VISUAL = "$EDITOR";
ALTERNATE_EDITOR = "nvim";
}; };
programs.git = { programs.git = {
@ -171,6 +173,16 @@
let g:ackprg='rg --vimgrep --no-heading' let g:ackprg='rg --vimgrep --no-heading'
set grepprg=rg\ --vimgrep set grepprg=rg\ --vimgrep
let g:rg_command = 'rg --vimgrep -S' let g:rg_command = 'rg --vimgrep -S'
let mapleader = "\<space>"
map! jj <ESC>
" FZF
set rtp+=/Users/salar/.nix-profile/bin/fzf
imap <c-x><c-o> <plug>(fzf-complete-line)
map <leader>b :Buffers<cr>
map <leader>f :Files<cr>
map <leader>g :GFiles<cr>
map <leader>y :Tags<cr>
autocmd! FileType fzf tnoremap <buffer> <leader>q <c-c>
nnoremap <C-p> :FZF<CR> nnoremap <C-p> :FZF<CR>
let g:rainbow_active = 1 let g:rainbow_active = 1
let g:rainbow_conf = { let g:rainbow_conf = {
@ -293,11 +305,14 @@
nixversion="nix eval nixpkgs.lib.version"; nixversion="nix eval nixpkgs.lib.version";
nixdaemon="sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist && launchctl start org.nixos.nix-daemon"; nixdaemon="sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist && launchctl start org.nixos.nix-daemon";
v="nvim"; v="nvim";
vc="emacsclient -c -a ''"; e="$HOME/bin/run-emacsclient-cli";
ew="$HOME/bin/run-emacsclient";
tabninecfg="vc /Users/salar/Library/Preferences/TabNine/TabNine.toml"; tabninecfg="vc /Users/salar/Library/Preferences/TabNine/TabNine.toml";
sshfre1="ssh salar@fre1.softinio.net"; sshfre1="ssh salar@fre1.softinio.net";
moshfre1="mosh salar@fre1.softinio.net"; moshfre1="mosh salar@fre1.softinio.net";
portsupdate="sudo port -v selfupdate"; portsupdate="sudo port -v selfupdate";
emacsload="launchctl load -w ~/Library/LaunchAgents/gnu.emacs.daemon.plist";
emacsunload="launchctl unload ~/Library/LaunchAgents/gnu.emacs.daemon.plist";
}; };
}; };
@ -335,6 +350,7 @@
pkgs.scalafmt pkgs.scalafmt
pkgs.coursier pkgs.coursier
pkgs.ammonite pkgs.ammonite
pkgs.mill
pkgs.bloop pkgs.bloop
pkgs.yarn pkgs.yarn
pkgs.openssl pkgs.openssl
@ -375,5 +391,6 @@
pkgs.tealdeer pkgs.tealdeer
pkgs.hyperfine pkgs.hyperfine
pkgs.graphviz pkgs.graphviz
pkgs.metals
]; ];
} }

18
run-emacsclient Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
if [ -z "$EMACSCLIENT_OPTS" ]; then
EMACSCLIENT_OPTS="-nc"
fi
if [ $# -eq 0 ]; then
COMMAND='/Users/salar/.nix-profile/bin/emacsclient '$EMACSCLIENT_OPTS' -e "(if (display-graphic-p) (x-focus-frame nil))"'
else
COMMAND='/Users/salar/.nix-profile/bin/emacsclient '$EMACSCLIENT_OPTS' "$@"'
fi
if [ -z "$(shopt | grep login_shell)" ]; then
echo "$COMMAND" | exec bash --login -s "$@"
else
eval "exec $COMMAND"
fi

5
run-emacsclient-cli Executable file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
export EMACSCLIENT_OPTS='-t'
exec run-emacsclient "$@"