aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-03-22 23:48:01 +0800
committerGuangxiong Lin <[email protected]>2022-03-22 23:50:57 +0800
commit248fc7fca0b684c27234acd34011d5a67570bdd2 (patch)
tree40c5fc549b16349e0a04a169a076cc89ccf26d1f
parent390f25523d441204962ba146fe1aefdaf4c2dede (diff)
downloaddotfiles-248fc7fca0b684c27234acd34011d5a67570bdd2.tar.gz
dotfiles-248fc7fca0b684c27234acd34011d5a67570bdd2.tar.bz2
dotfiles-248fc7fca0b684c27234acd34011d5a67570bdd2.zip
Update ec (emacs)
-rwxr-xr-xbin/ec40
1 files changed, 22 insertions, 18 deletions
diff --git a/bin/ec b/bin/ec
index 4a4dfb9..78483a7 100755
--- a/bin/ec
+++ b/bin/ec
@@ -2,25 +2,29 @@
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() {
+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
+if [[ $(uname) == Darwin ]]; then
+ # 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
+else
+ emacsclient -a "" -n -c "$@"
+fi