From 1f52a78d2f863acea1cfc9f1dea6688abee27df0 Mon Sep 17 00:00:00 2001 From: "Marcel Kapfer (mmk2410)" Date: Fri, 23 Dec 2016 22:06:39 +0100 Subject: [PATCH] Connected stumpwm with emacsclient --- .gitignore | 1 + .stumpwmrc | 20 ++++++++++++++++++++ emacs.el | 11 +++++++++++ es.sh | 4 ++++ fish/config.fish | 4 ++-- 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100755 es.sh diff --git a/.gitignore b/.gitignore index 0f73a34..4bc0d09 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /fish/fishd.* +*~ diff --git a/.stumpwmrc b/.stumpwmrc index 7bee610..4a2cf32 100644 --- a/.stumpwmrc +++ b/.stumpwmrc @@ -43,6 +43,10 @@ ;;; terminal (define-key *root-map* (kbd "c") "exec urxvt") + +;;; es as emacs +(define-key *root-map* (kbd "e") "exec es") + ;;; groups to rpws keys (define-key *root-map* (kbd "C-1") "change-workspace 1") (define-key *root-map* (kbd "C-2") "change-workspace 2") @@ -134,3 +138,19 @@ "Switch workspace" (run-commands (concatenate 'string "gselect " n)) (echo (concatenate 'string "Switched to " n))) + + +;; working with emacsclient +(defvar *es-win* nil + "to hold the window called emacsclient") +(defun save-es-called-win () + (setf *es-win* (current-window))) + +(defun return-es-called-window (win) + (let* ((group (window-group win)) + (frame (window-frame win)) + (old-frame (tile-group-current-frame group))) + (frame-raise-window group frame win) + (focus-all win) + (unless (eq frame old-frame) + (show-frame-indicator group)))) diff --git a/emacs.el b/emacs.el index 8ecf105..6c1f409 100644 --- a/emacs.el +++ b/emacs.el @@ -119,3 +119,14 @@ ;;; diff-hl (global-diff-hl-mode t) (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh) + +;; stumpwm: working with emacsclient +(add-hook 'after-init-hook 'server-start) +(setq server-raise-frame t) + +(if window-system + (add-hook 'server-done-hook + (lambda () + (shell-command + "stumpish 'eval (stumpwm::return-es-called-win stumpwm::*es-win*)'")))) + diff --git a/es.sh b/es.sh new file mode 100755 index 0000000..1920e99 --- /dev/null +++ b/es.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +stumpish 'eval (stumpwm::save-es-called-win)' > /dev/null +emacsclient -c --alternate-editor=$ALTERNATE_EDITOR "$@" diff --git a/fish/config.fish b/fish/config.fish index 8e929b5..872737a 100644 --- a/fish/config.fish +++ b/fish/config.fish @@ -41,11 +41,11 @@ if [ -z $SSH_CLIENT ] end if [ -z $EDITOR ] - set -Ux EDITOR nvim + set -Ux EDITOR es end if [ -z $VISUAL ] - set -Ux VISUAL nvim + set -Ux VISUAL es end if [ -z $GOPATH ]