Subject: Re: bug#26454: [PATCH 2/2] gnu: add emacs-exwm

From: "Feng Shu" <[email-masked]>
Date: Sat, 15 Apr 2017 20:29:43 +0800

tumashu <[email-masked]> writes:

> I need to debug and contact with exwm's developer, exwm is a powerful wm, maybe it is more powful and easy use than stumpwm with other emacs packages help,  in my personal opinion,  guile-wm just a toy project.

I have found the reason: https://github.com/ch11ng/exwm/issues/213

exwm need DISPLAY is ":0" instead of ":0.0", I don't know the reason.

The below is my updated patch, which changes a lot, so review is need again:

>From 56c84ac96c30529ced5ca66a26c70ebf52e59902 Mon Sep 17 00:00:00 2001
From: Feng Shu <[email-masked]>
Date: Fri, 14 Apr 2017 23:06:15 +0800
Subject: [PATCH 1/2] gnu: add emacs-xelb

* gnu/packages/emacs.scm (emacs-xelb): New variable.
---
 gnu/packages/emacs.scm | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 71058136a..0320d66c7 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -4348,3 +4348,52 @@ commands are also offered as part of the AUCTeX package, but it is not
 the same - CDLaTeX focuses on speediness for inserting LaTeX
 constructs.")
     (license license:gpl3+)))
+
+(define-public emacs-xelb
+  (package
+    (name "emacs-xelb")
+    (version "0.12-3.d1d6b6c")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/ch11ng/xelb")
+                    (commit "d1d6b6cb48a6a9562252be20ab49f24708b34335")))
+              (file-name (string-append name "-" version "-checkout"))
+              (sha256
+               (base32
+                "0sxx2n3mi90dz66yi4xya89jrznyixfbmnj8b84l6qbkdp9iwd91"))))
+    (build-system emacs-build-system)
+    ;; The following functions or variables is need by emacs-xelb,
+    ;; which is not included in 'emacs-minimal'.
+    ;; x-display-screens x-keysym-table x-alt-keysym x-meta-keysym
+    ;; x-hyper-keysym x-super-keysym libxml-parse-xml-region
+    ;; x-display-pixel-width x-display-pixel-height
+    (arguments
+     `(#:emacs ,emacs
+       #:phases
+       ;; Generate .el files from the XML description of the XCB bindings.
+       ;; This will be adjusted when xelb developer comment in issue page:
+       ;; https://github.com/ch11ng/xelb/issues/16
+       (modify-phases %standard-phases
+         (add-after 'unpack 'regenerate-el-files
+           (lambda _
+             (let ((xcb-proto-xml-path (string-append (assoc-ref %build-inputs
+                                                                 "xcb-proto")
+                                                      "/share/xcb"))
+                   (emacs-path         (string-append (assoc-ref %build-inputs
+                                                                 "emacs")
+                                                      "/bin/emacs")))
+               (substitute* "Makefile"
+                 (("PROTO_PATH := ../xcb-proto/src")
+                  (string-append "PROTO_PATH := " xcb-proto-xml-path))
+                 (("EMACS_BIN := emacs -Q")
+                  (string-append "EMACS_BIN := " emacs-path "  -Q")))
+               (zero? (system* "make" "all"))))))))
+    (inputs `(("xcb-proto" ,xcb-proto)))
+    (home-page "https://github.com/ch11ng/xelb")
+    (synopsis "X protocol Emacs Lisp Binding")
+    (description "@code{emacs-xelb} is a pure Emacs Lisp implementation
+of the X11 protocol based on the XML description files from the XCB
+project. It features an object-oriented API and permits a certain degree
+of concurrency. It should enable you to implement low-level X11 applications.")
+    (license license:gpl3+)))
-- 
2.12.2

>From 1fd5bc3bb55923f65057a2b9922ebad458a2ed8b Mon Sep 17 00:00:00 2001
From: Feng Shu <[email-masked]>
Date: Sat, 15 Apr 2017 20:23:10 +0800
Subject: [PATCH 2/2] gnu: add emacs-exwm

* gnu/packages/emacs.scm (emacs-exwm): New variable
---
 gnu/packages/emacs.scm | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 0320d66c7..b7e2b83a2 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -4397,3 +4397,84 @@ of the X11 protocol based on the XML description files from the XCB
 project. It features an object-oriented API and permits a certain degree
 of concurrency. It should enable you to implement low-level X11 applications.")
     (license license:gpl3+)))
+
+(define-public emacs-exwm
+  (package
+    (name "emacs-exwm")
+    (version "0.13-3.7a5bb11")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/ch11ng/exwm")
+                    (commit "7a5bb1156d07848e465f55fd31f8ec755b52aa01")))
+              (file-name (string-append name "-" version "-checkout"))
+              (sha256
+               (base32
+                "0cbaq2ls8pivz4h8hwgn9ldvg16pwlisdf047civvilqiqczw31w"))))
+    (build-system emacs-build-system)
+    (propagated-inputs
+     `(("emacs-xelb" ,emacs-xelb)
+       ("xhost" ,xhost)
+       ("dbus" ,dbus)))
+    ;; The following functions or variables is need by emacs-exwm,
+    ;; which is not included in 'emacs-minimal'.
+    ;; scroll-bar-mode, fringe-mode
+    ;; x-display-pixel-width x-display-pixel-height
+    (arguments
+     `(#:emacs ,emacs
+       #:phases
+       ;; Generate .el files from the XML description of the XCB bindings.
+       ;; This will be adjusted when xelb developer comment in issue page:
+       ;; https://github.com/ch11ng/xelb/issues/16
+       (modify-phases %standard-phases
+         (add-after 'build 'install-xsession
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((emacs-path (string-append (assoc-ref %build-inputs
+                                                          "emacs")
+                                               "/bin/emacs"))
+                    (sh-path    (string-append (assoc-ref %build-inputs
+                                                          "bash")
+                                               "/bin/sh"))
+                    (xhost-path (string-append (assoc-ref %build-inputs
+                                                          "xhost")
+                                               "/bin/xhost"))
+                    (dbus-launch-path (string-append (assoc-ref %build-inputs
+                                                                "dbus")
+                                                     "/bin/dbus-launch"))
+                    (output (assoc-ref outputs "out"))
+                    (xsessions-dir (string-append output "/share/xsessions"))
+                    (desktop-file (string-append xsessions-dir "/exwm-demo.desktop"))
+                    (bin-dir (string-append output "/bin"))
+                    (exwm-demo-file (string-append bin-dir "/exwm-demo-session")))
+               ;; Add a .desktop file to xsessions.
+               (mkdir-p xsessions-dir)
+               (mkdir-p bin-dir)
+               (with-output-to-file desktop-file
+                 (lambda _
+                   (format #t
+                    "[Desktop Entry]~@
+                     Name=Exwm-Demo~@
+                     Comment=Demo of Emacs X Window Manager ~@
+                     Exec=~a/bin/exwm-demo-session~@
+                     TryExec=~@*~a/bin/exwm-demo-session~@
+                     Icon=~@
+                     Type=Application~%"
+                    output)))
+               ;; Add a shell wrap file to bin directory.
+               ;; Fixup: Set DISPLAY variable for the reason:
+               ;; https://github.com/ch11ng/exwm/issues/213
+               (with-output-to-file exwm-demo-file
+                 (lambda _
+                   (format #t
+                    "#!~a ~@
+                     export DISPLAY=:0 ~@
+                     ~a +SI:localuser:$USER ~@
+                     exec ~a --exit-with-session ~a -q --eval \"(progn (require 'exwm)(require 'exwm-config)(exwm-config-default))\" ~%"
+                    sh-path xhost-path dbus-launch-path emacs-path)))
+               (chmod exwm-demo-file #o555)
+               #t))))))
+    (home-page "https://github.com/ch11ng/exwm")
+    (synopsis "Emacs X Window Manager")
+    (description "EXWM (Emacs X Window Manager) is a full-featured
+tiling X window manager for Emacs built on top of XELB.")
+    (license license:gpl3+)))
-- 
2.12.2