Subject: [PATCH 3/3] gnu: Add highlight-gui.

From: gemmaro <[email-masked]>
Date: Tue, 1 Aug 2023 08:45:47 +0900

* gnu/packages/pretty-print.scm (highlight-gui): New variable.
---
 gnu/packages/pretty-print.scm | 45 +++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gnu/packages/pretty-print.scm b/gnu/packages/pretty-print.scm
index 1b2cf4becf..1ec4df50a9 100644
--- a/gnu/packages/pretty-print.scm
+++ b/gnu/packages/pretty-print.scm
@@ -52,6 +52,7 @@ (define-module (gnu packages pretty-print)
   #:use-module (gnu packages lua)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages qt)
   #:use-module (gnu packages swig))
 
 (define-public a2ps
@@ -404,3 +405,47 @@ (define-public highlight
 TeX, SVG, BBCode and terminal escape sequences with colored syntax
 highlighting.  Language definitions and color themes are customizable.")
     (license gpl3+)))
+
+(define-public highlight-gui
+  (package
+    (inherit highlight)
+    (name "highlight-gui")
+    (build-system gnu-build-system)
+    (arguments
+     (substitute-keyword-arguments (package-arguments highlight)
+       ((#:phases phases)
+        #~(modify-phases #$phases
+            (add-after 'unpack 'fix-paths
+              (lambda* (#:key inputs #:allow-other-keys)
+                (let* ((highlight:out (assoc-ref inputs "highlight"))
+                       (data (string-append highlight:out "/share/highlight/"))
+                       (conf (string-append highlight:out "/etc/highlight/"))
+                       (doc (string-append highlight:out
+                                           "/share/doc/highlight/")))
+                  (substitute* "makefile"
+                    (("HL_DATA_DIR=.* HL_CONFIG_DIR=.* HL_DOC_DIR=.* gui-qt")
+                     (string-append "HL_DATA_DIR=\""
+                                    data
+                                    "\" HL_CONFIG_DIR=\""
+                                    conf
+                                    "\" HL_DOC_DIR=\""
+                                    doc
+                                    "\" gui-qt"))))))
+            (add-after 'fix-search-for-lua 'fix-search-for-lua/GUI
+              (lambda _
+                (substitute* "src/gui-qt/highlight.pro"
+                  (("PKGCONFIG \\+= lua")
+                   (string-append "PKGCONFIG += lua-"
+                                  #$(version-major+minor (package-version lua)))))))
+            (replace 'build
+              (lambda _
+                (invoke "make" "gui")))
+            (delete 'install-perl-bindings)
+            (replace 'install
+              (lambda* (#:key outputs #:allow-other-keys)
+                (let ((out (assoc-ref outputs "out")))
+                  (mkdir-p (string-append out "/bin"))
+                  (invoke "make" "install-gui"))))))))
+    (native-inputs (list pkg-config))
+    (inputs (list highlight lua boost qtbase-5))
+    (synopsis "Graphical user interface for highlight")))
-- 
2.41.0