I am working on the attached patch to package https://github.com/akermu/emacs-libvterm.git.

When building the package I get the following error:

building /gnu/store/89icdpwha5vvqmn2yn3949w503ck6cq6-emacs-vterm-0-1.de63115.tar.xz.drv...
File vterm-module-make.el is read-only; trying to patch anyway
patching file vterm-module-make.el
File vterm.el is read-only; trying to patch anyway
patching file vterm.el
Hunk #1 FAILED at 45.
1 out of 1 hunk FAILED -- saving rejects to file vterm.el.rej

I have looked at several other packages and the call I'm making to `make-file-writable` _looks_ to be correct. But that function is either not called before the patch is applied or else it is not having the intended effect.

--
Joseph LaFreniere
>From 0b4ae3a55fce423780e376e59e2bf00bed53e2da Mon Sep 17 00:00:00 2001
From: Joseph LaFreniere <jos...@lafreniere.xyz>
Date: Mon, 6 Jan 2020 20:56:35 -0600
Subject: [PATCH] gnu: Add emacs-vterm.

* gnu/packages/emacs-xyz.scm (emacs-vterm): New variable.
---
 gnu/packages/emacs-xyz.scm                    | 60 +++++++++++++++++
 ...emacs-vterm-remove-vterm-module-make.patch | 65 +++++++++++++++++++
 2 files changed, 125 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-vterm-remove-vterm-module-make.patch

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 6c9d493c62..8e1307af55 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -104,6 +104,7 @@
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages telephony)
+  #:use-module (gnu packages terminals)
   #:use-module (gnu packages tex)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tcl)
@@ -17342,6 +17343,65 @@ next, volume) and display and control the current playlist as well as your
 stored playlists.")
     (license license:gpl3+)))
 
+(define-public emacs-vterm
+  (let ((version "0")
+        (revision "1")
+        (commit "de63115918b9b8633c78509b7bdf05f4935ee20d"))
+    (package
+      (name "emacs-vterm")
+      (version (git-version version revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/akermu/emacs-libvterm.git";)
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0qxabjf9nq3i1cpyzghxcf0bjhnl5y9g8dvbqjip0gb0l570sbfm"))
+                (modules '((guix build utils)
+                           (guix build emacs-build-system)
+                           ((guix build cmake-build-system) #:prefix cmake:)))
+                (patches
+                 (search-patches
+                  "emacs-vterm-remove-vterm-module-make.patch"))))
+      (build-system emacs-build-system)
+      (arguments
+       `(#:phases (modify-phases %standard-phases
+                    (add-after 'unpack 'make-el-writable
+                      (lambda _
+                        (for-each make-file-writable
+                                  (find-files "." "\\.el$"))
+                        #t))
+                    (add-before 'add-source-to-load-path 'configure
+                      (lambda* (#:key outputs #:allow-other-keys)
+                        ((assoc-ref cmake:%standard-phases 'configure)
+                         #:outputs outputs
+                         #:out-of-source? #f
+                         #:configure-flags '("-DUSE_SYSTEM_LIBVTERM=ON"))))
+                    (add-before 'install 'make
+                      (lambda* (#:key (make-flags '()) #:allow-other-keys)
+                        (apply invoke "make" "all" make-flags)
+                        #t))
+                    (add-before 'make-autoloads 'move-el
+                      (lambda* (#:key outputs #:allow-other-keys)
+                        (let* ((out (assoc-ref outputs "out"))
+                               (site-lisp (string-append out "/share/emacs/site-lisp")))
+                          (mkdir-p site-lisp)
+                          (copy-file "vterm.el" (string-append site-lisp "/vterm.el"))
+                          (copy-file "vterm-module.so" (string-append site-lisp "/vterm-module.so"))
+                          #t))))
+         #:tests? #f))
+      (native-inputs
+       `(("cmake" ,cmake-minimal)
+         ("libtool" ,libtool)
+         ("libvterm" ,libvterm)))
+      (home-page "https://github.com/akermu/emacs-libvterm";)
+      (synopsis "Emacs libvterm integration")
+      (description "This package implements a bridge to @code{libvterm} to
+display a terminal in an Emacs buffer.")
+      (license license:gpl3+))))
+
 (define-public emacs-simple-mpc
   ;; There have been no releases.
   (let ((commit "bee8520e81292b4c7353e45b193f9a13b482f5b2")
diff --git a/gnu/packages/patches/emacs-vterm-remove-vterm-module-make.patch b/gnu/packages/patches/emacs-vterm-remove-vterm-module-make.patch
new file mode 100644
index 0000000000..284b4a220d
--- /dev/null
+++ b/gnu/packages/patches/emacs-vterm-remove-vterm-module-make.patch
@@ -0,0 +1,65 @@
+From 0780015958a7480a981827a9791c0ea22859062b Mon Sep 17 00:00:00 2001
+From: Joseph LaFreniere <jos...@lafreniere.xyz>
+Date: Thu, 9 Jan 2020 00:55:38 -0600
+Subject: [PATCH] Remove vterm-module-make
+
+---
+ vterm-module-make.el | 31 -------------------------------
+ vterm.el             |  4 +---
+ 2 files changed, 1 insertion(+), 34 deletions(-)
+ delete mode 100644 vterm-module-make.el
+
+diff --git a/vterm-module-make.el b/vterm-module-make.el
+deleted file mode 100644
+index 086907f..0000000
+--- a/vterm-module-make.el
++++ /dev/null
+@@ -1,31 +0,0 @@
+-;;; vterm-module-make.el --- make vterm-module in elisp  -*- lexical-binding: t; -*-
+-
+-(require 'files)
+-
+-(defvar vterm-install-buffer-name " *Install vterm"
+-  "Name of the buffer used for compiling vterm-module.")
+-
+-;;;###autoload
+-(defun vterm-module-compile ()
+-  "This function compiles the vterm-module."
+-  (interactive)
+-  (let ((default-directory
+-          (file-name-directory (file-truename (locate-library "vterm"))))
+-        (make-commands
+-         "mkdir -p build; \
+-          cd build; \
+-          cmake \
+-            -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+-            ..; \
+-          make"))
+-    (unless (file-executable-p (concat default-directory "vterm-module.so"))
+-      (let* ((buffer (get-buffer-create vterm-install-buffer-name)))
+-        (pop-to-buffer vterm-install-buffer-name)
+-        (if (zerop (call-process "sh" nil buffer t "-c" make-commands))
+-            (message "Compilation of emacs-libvterm module succeeded")
+-          (error "Compilation of emacs-libvterm module failed!"))))))
+-
+-(or (require 'vterm-module nil t)
+-    (vterm-module-compile))
+-
+-(provide 'vterm-module-make)
+diff --git a/vterm.el b/vterm.el
+index 0060e6a..93e93fa 100644
+--- a/vterm.el
++++ b/vterm.el
+@@ -45,9 +45,7 @@
+ (unless module-file-suffix
+   (error "VTerm needs module support. Please compile your Emacs with the --with-modules option!"))
+
+-(or (require 'vterm-module nil t)
+-    (and (require 'vterm-module-make)
+-         (require 'vterm-module)))
++(module-load "vterm-module.so")
+
+ (require 'subr-x)
+ (require 'cl-lib)
+--
+2.24.1
-- 
2.24.1

Reply via email to