aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-03-20 18:41:45 +0800
committerGuangxiong Lin <[email protected]>2022-03-20 18:41:45 +0800
commite64253adc84b62a01660e7de276ba61711f7421f (patch)
tree366c84346d3097fa99a6dca6b29350d5c8b53681
parent630a82c2f5c242c81671c823e7e88a95f232c7ab (diff)
downloaddotfiles-e64253adc84b62a01660e7de276ba61711f7421f.tar.gz
dotfiles-e64253adc84b62a01660e7de276ba61711f7421f.tar.bz2
dotfiles-e64253adc84b62a01660e7de276ba61711f7421f.zip
Improve emacsclient
-rw-r--r--.aliases6
-rwxr-xr-xbin/ec30
-rwxr-xr-xbin/ek12
-rwxr-xr-xbin/et3
4 files changed, 47 insertions, 4 deletions
diff --git a/.aliases b/.aliases
index ba4c5aa..582a776 100644
--- a/.aliases
+++ b/.aliases
@@ -6,10 +6,8 @@ alias diff='diff --color=auto'
alias grep='grep --color=auto'
alias emacs='emacs -nw'
-alias et='emacsclient -a "" -t'
-alias ec='nohup emacsclient -a "" -c &!'
-alias mu4e='emacs -nw -f mu4e'
-alias agenda='emacs -nw -f org-agenda'
+alias magit='et -e "(magit-status \"$(pwd)\")"'
+alias agenda='et -e "(org-agenda)"'
alias nb='cd ~/journals; vim index.md; cd -'
alias todo='cd ~/journals; vim gtd.md; cd -'
alias vimg='vim +Git +only'
diff --git a/bin/ec b/bin/ec
new file mode 100755
index 0000000..96499d3
--- /dev/null
+++ b/bin/ec
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+# Below is copied from network. I am not quite sure its purpose. Maybe I
+# may need it someday.
+
+
+# # Number of current visible frames,
+# # Emacs daemon always has a visible frame called F1
+# visible_frames() {
+# emacsclient -a "" -e '(length (visible-frame-list))'
+# }
+#
+# change_focus() {
+# emacsclient -n -e "(select-frame-set-input-focus (selected-frame))" > /dev/null
+# }
+#
+# # try switching to the frame incase it is just minimized
+# # will start a server if not running
+# test "$(visible_frames)" -eq "1" && change_focus
+#
+# if [ "$(visible_frames)" -lt "2" ]; then # need to create a frame
+# # -c $@ with no args just opens the scratch buffer
+# emacsclient -n -c "$@" && change_focus
+# else # there is already a visible frame besides the daemon, so
+# change_focus
+# # -n $@ errors if there are no args
+# test "$#" -ne "0" && emacsclient -n "$@"
+# fi
+
+emacsclient -a "" -n -c "$@"
diff --git a/bin/ek b/bin/ek
new file mode 100755
index 0000000..4420327
--- /dev/null
+++ b/bin/ek
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+server_running () {
+ emacsclient -a "false" -e "(boundp 'server-process)"
+}
+
+if [ "t" == "$(server_running)" ]; then
+ emacsclient -e '(kill-emacs)'
+ echo "Emacs server is killed"
+else
+ echo "Emacs server is not running"
+fi
diff --git a/bin/et b/bin/et
new file mode 100755
index 0000000..807fa38
--- /dev/null
+++ b/bin/et
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+exec emacsclient -a "" -c -t "$@"