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 <rekahsoft@gmail.com>
This commit is contained in:
Collin J. Doering 2014-11-18 05:16:38 -05:00 committed by Collin J. Doering
parent 5f3173ff64
commit ca0ffdc4d5
2 changed files with 16 additions and 11 deletions

View File

@ -17,6 +17,15 @@
;; Author: Collin J. Doering <collin.doering@rekahsoft.ca> ;; Author: Collin J. Doering <collin.doering@rekahsoft.ca>
;; Date: Oct 22, 2014 ;; 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 ;; Toggles windows split orientation of 2 adjecent windows
;; Thanks to http://www.emacswiki.org/cgi-bin/wiki?ToggleWindowSplit ;; Thanks to http://www.emacswiki.org/cgi-bin/wiki?ToggleWindowSplit
(defun toggle-window-split () (defun toggle-window-split ()

View File

@ -415,22 +415,22 @@ scratchpads = [ NS "emacs-scratch" spawnEmacsScratch findEmacsScratch manageEmac
, NS "mc-scratch" spawnMcScratch findMcScratch manageMcScratch , NS "mc-scratch" spawnMcScratch findMcScratch manageMcScratch
, NS "ncmpcpp-scratch" spawnNcmpcppScratch findNcmpcppScratch manageNcmpcppScratch] , NS "ncmpcpp-scratch" spawnNcmpcppScratch findNcmpcppScratch manageNcmpcppScratch]
where where
findEmacsScratch = resource =? "emacs-scratch" findEmacsScratch = title =? "emacs-scratch"
findMaintenanceTerminal = resource =? "scratchpad" findMaintenanceTerminal = resource =? "scratchpad"
findScreenTerminal = resource =? "screen-scratch" findScreenTerminal = title =? "screen-scratch"
findMcScratch = resource =? "mc-scratch" findMcScratch = resource =? "mc-scratch"
findNcmpcppScratch = resource =? "ncmpcpp-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" 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" spawnMcScratch = myTerminal ++ " -name mc-scratch -pe -tabbedex -e mc"
spawnNcmpcppScratch = myTerminal ++ " -name ncmpcpp-scratch -pe -tabbedex -e ncmpcpp" spawnNcmpcppScratch = myTerminal ++ " -name ncmpcpp-scratch -pe -tabbedex -e ncmpcpp"
manageEmacsScratch = customFloating $ W.RationalRect 0.10 0.10 0.80 0.80 manageEmacsScratch = customFloating $ W.RationalRect 0.10 0.10 0.80 0.80
manageMaintenanceTerminal = customFloating $ W.RationalRect 0 0.66 1 0.34 manageMaintenanceTerminal = customFloating $ W.RationalRect 0 0.66 1 0.34
manageScreenTerminal = customFloating $ W.RationalRect 0 0.015 1 0.985 manageScreenTerminal = customFloating $ W.RationalRect 0 0.01 1 0.99
manageMcScratch = customFloating $ W.RationalRect 0.20 0.15 0.60 0.70 manageMcScratch = customFloating $ W.RationalRect 0.125 0.125 0.75 0.75
manageNcmpcppScratch = customFloating $ W.RationalRect 0.225 0.10 0.55 0.80 manageNcmpcppScratch = customFloating $ W.RationalRect 0.225 0.10 0.55 0.80
-- manageScreenTerminal = customFloating $ W.RationalRect l t w h -- 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 -- It will add EWMH logHook actions to your custom log hook by
-- combining it with ewmhDesktopsLogHook. -- combining it with ewmhDesktopsLogHook.
-- --
myLogHook h = dynamicLogWithPP $ xmobarPP myLogHook h = dynamicLogWithPP . namedScratchpadFilterOutWorkspacePP $ xmobarPP
{ ppOutput = hPutStrLn h { ppOutput = hPutStrLn h
, ppUrgent = xmobarColor "yellow" "red" . xmobarStrip , ppUrgent = xmobarColor "yellow" "red" . xmobarStrip
, ppHidden = (\ ws -> "") } , 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 -- Startup hook