aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-03-21 20:04:33 +0800
committerGuangxiong Lin <[email protected]>2022-03-21 20:04:33 +0800
commit1e23aab1fbdf1f7ae03d20e41298561f1fdca548 (patch)
tree06c2b156828635344202ada428ac89b97be1af42 /bin
parent51a582ac7d8528cdce0b5e489a5eacaee18472e1 (diff)
downloaddotfiles-1e23aab1fbdf1f7ae03d20e41298561f1fdca548.tar.gz
dotfiles-1e23aab1fbdf1f7ae03d20e41298561f1fdca548.tar.bz2
dotfiles-1e23aab1fbdf1f7ae03d20e41298561f1fdca548.zip
Use the same window in ec (emacs)
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ec46
-rwxr-xr-xbin/et2
2 files changed, 22 insertions, 26 deletions
diff --git a/bin/ec b/bin/ec
index eaa3cf2..4a4dfb9 100755
--- a/bin/ec
+++ b/bin/ec
@@ -1,30 +1,26 @@
#!/usr/bin/env bash
-# Below is copied from network. I am not quite sure its purpose. Maybe I
-# may need it someday.
+export LC_CTYPE=zh_CN.UTF-8
+# Number of current visible frames,
+# Emacs daemon always has a visible frame called F1
+visible_frames() {
+ emacsclient -a "" -e '(length (visible-frame-list))'
+}
-# # 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
+change_focus() {
+ emacsclient -n -e "(select-frame-set-input-focus (selected-frame))" > /dev/null
+}
-LC_CTYPE=zh_CN.UTF-8 emacsclient -a "" -n -c "$@"
+# 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
diff --git a/bin/et b/bin/et
index 807fa38..d270ffd 100755
--- a/bin/et
+++ b/bin/et
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
-exec emacsclient -a "" -c -t "$@"
+exec emacsclient -a "" -t "$@"