From ca0ffdc4d5c97f1ffdce94d5a88e2bb78486decc Mon Sep 17 00:00:00 2001 From: "Collin J. Doering" Date: Tue, 18 Nov 2014 05:16:38 -0500 Subject: [PATCH] Allow X emacs frames to be scratchpads in xmonad Cannot have X11 emacs/emacsclient window as scratchpad in xmonad - State "KNOWNCAUSE" from "BUG" [2014-11-07 Fri 02:53] \\ This is due to the fact that in xmonad I am unable to locate a particular emacs frame (X11 window). This is because emacs' frames change there names dynamically and all have the same resource name, thus there's no way to locate them. - State "BUG" from "REPORT" [2014-11-07 Fri 02:52] \\ This is an issue. Emacs in terminal is nice but it's preferred to use a X11 instance when possible. Signed-off-by: Collin J. Doering --- .emacs.d/config/window-management.el | 9 +++++++++ .xmonad/xmonad.hs | 18 +++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.emacs.d/config/window-management.el b/.emacs.d/config/window-management.el index cf7bad1..a765ac8 100644 --- a/.emacs.d/config/window-management.el +++ b/.emacs.d/config/window-management.el @@ -17,6 +17,15 @@ ;; Author: Collin J. Doering ;; Date: Oct 22, 2014 +;; Use this function to create a X11 emacs frame with a static name so it can +;; be treated specially by xmonad (as a scratch-pad in this case). This is expected +;; to be run from command-line like so: +;; emacsclient --eval '(make-frame-with-static-name "emacs-scratch")' +(defun make-frame-with-static-name (given-name) + "Makes a (X11) frame with a unchanging name for the purposes of finding it with +a window manager, and treating it specially." + (select-frame (make-frame `((name . ,given-name))))) + ;; Toggles windows split orientation of 2 adjecent windows ;; Thanks to http://www.emacswiki.org/cgi-bin/wiki?ToggleWindowSplit (defun toggle-window-split () diff --git a/.xmonad/xmonad.hs b/.xmonad/xmonad.hs index 9264589..d025cc9 100644 --- a/.xmonad/xmonad.hs +++ b/.xmonad/xmonad.hs @@ -415,22 +415,22 @@ scratchpads = [ NS "emacs-scratch" spawnEmacsScratch findEmacsScratch manageEmac , NS "mc-scratch" spawnMcScratch findMcScratch manageMcScratch , NS "ncmpcpp-scratch" spawnNcmpcppScratch findNcmpcppScratch manageNcmpcppScratch] where - findEmacsScratch = resource =? "emacs-scratch" + findEmacsScratch = title =? "emacs-scratch" findMaintenanceTerminal = resource =? "scratchpad" - findScreenTerminal = resource =? "screen-scratch" + findScreenTerminal = title =? "screen-scratch" findMcScratch = resource =? "mc-scratch" findNcmpcppScratch = resource =? "ncmpcpp-scratch" - spawnEmacsScratch = myTerminal ++ " -name emacs-scratch -pe -tabbedex -e tmux -2 new-session -s emacs-scratch \"emacsclient -nw\"" + spawnEmacsScratch = "emacsclient --eval '(make-frame-with-static-name \"emacs-scratch\")'" spawnMaintenanceTerminal = myTerminal ++ " -name scratchpad -bg black" - spawnScreenTerminal = myTerminal ++ " -name screen-scratch -bg black" + spawnScreenTerminal = "emacsclient --eval '(make-frame-with-static-name \"screen-scratch\")'" spawnMcScratch = myTerminal ++ " -name mc-scratch -pe -tabbedex -e mc" spawnNcmpcppScratch = myTerminal ++ " -name ncmpcpp-scratch -pe -tabbedex -e ncmpcpp" manageEmacsScratch = customFloating $ W.RationalRect 0.10 0.10 0.80 0.80 manageMaintenanceTerminal = customFloating $ W.RationalRect 0 0.66 1 0.34 - manageScreenTerminal = customFloating $ W.RationalRect 0 0.015 1 0.985 - manageMcScratch = customFloating $ W.RationalRect 0.20 0.15 0.60 0.70 + manageScreenTerminal = customFloating $ W.RationalRect 0 0.01 1 0.99 + manageMcScratch = customFloating $ W.RationalRect 0.125 0.125 0.75 0.75 manageNcmpcppScratch = customFloating $ W.RationalRect 0.225 0.10 0.55 0.80 -- manageScreenTerminal = customFloating $ W.RationalRect l t w h @@ -466,15 +466,11 @@ myEventHook = mempty -- It will add EWMH logHook actions to your custom log hook by -- combining it with ewmhDesktopsLogHook. -- -myLogHook h = dynamicLogWithPP $ xmobarPP +myLogHook h = dynamicLogWithPP . namedScratchpadFilterOutWorkspacePP $ xmobarPP { ppOutput = hPutStrLn h , ppUrgent = xmobarColor "yellow" "red" . xmobarStrip , ppHidden = (\ ws -> "") } --- where --- noScratchPad ws = if ws == "NSP" then "" else ws --- TODO: hide workspace esc:hide; if (ws == "NSP" || ws == "esc:hide") then "" else ws) - ------------------------------------------------------------------------ -- Startup hook