Subject: bug#55495: [PATCH] gnu: emacs-haskell-mode: Fix build.

From: Taiju HIGASHI <[email-masked]>
Date: Wed, 18 May 2022 23:31:29 +0900

* gnu/packages/emacs-xyz.scm (emacs-haskell-mode): Fix build.
---
 gnu/packages/emacs-xyz.scm                    |   9 +-
 .../emacs-haskell-mode-fix-tests.patch        | 282 ++++++++++++++++++
 2 files changed, 289 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/emacs-haskell-mode-fix-tests.patch

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 529e9329d6..9d9669f383 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -1553,11 +1553,16 @@ (define-public emacs-haskell-mode
              (commit version)))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "0zxbacqzr84krmhqpvzndnvlcjh1gs1x20ys0dykgd7chyhci5j5"))))
+        (base32 "0zxbacqzr84krmhqpvzndnvlcjh1gs1x20ys0dykgd7chyhci5j5"))
+        ;; Submitted for inclusion upstream.
+        ;; Not identical patches due to different target versions.
+        ;; (see: https://github.com/haskell/haskell-mode/pull/1780)
+       (patches
+        (search-patches "emacs-haskell-mode-fix-tests.patch"))))
     (propagated-inputs
      (list emacs-dash))
     (native-inputs
-     (list emacs-minimal emacs-el-search emacs-stream texinfo))
+     (list emacs-minimal emacs-el-search emacs-stream texinfo git))
     (build-system gnu-build-system)
     (arguments
      (list
diff --git a/gnu/packages/patches/emacs-haskell-mode-fix-tests.patch b/gnu/packages/patches/emacs-haskell-mode-fix-tests.patch
new file mode 100644
index 0000000000..9e47a5a46f
--- /dev/null
+++ b/gnu/packages/patches/emacs-haskell-mode-fix-tests.patch
@@ -0,0 +1,282 @@
+diff --git a/haskell-cabal.el b/haskell-cabal.el
+index a2de2ea..dd08ab6 100644
+--- a/haskell-cabal.el
++++ b/haskell-cabal.el
+@@ -361,7 +361,8 @@ OTHER-WINDOW use `find-file-other-window'."
+ (defconst haskell-cabal-conditional-regexp "^[ \t]*\\(\\if\\|else\\|}\\)")
+ 
+ (defun haskell-cabal-classify-line ()
+-  "Classify the current line into 'section-header 'subsection-header 'section-data 'comment and 'empty '"
++  "Classify the current line into 'section-header 'subsection-header
++'section-data 'comment and 'empty '"
+   (save-excursion
+     (beginning-of-line)
+     (cond
+@@ -494,7 +495,8 @@ OTHER-WINDOW use `find-file-other-window'."
+           ((equal component-type "benchmark")  "bench"))))
+ 
+ (defun haskell-cabal-enum-targets (&optional process-type)
+-  "Enumerate .cabal targets. PROCESS-TYPE determines the format of the returned target."
++  "Enumerate .cabal targets. PROCESS-TYPE determines the format of the
++returned target."
+   (let ((cabal-file (haskell-cabal-find-file))
+         (process-type (if process-type process-type 'ghci)))
+     (when (and cabal-file (file-readable-p cabal-file))
+@@ -926,7 +928,9 @@ resulting buffer-content.  Unmark line at the end."
+ (defun haskell-cabal-line-filename ()
+   "Expand filename in current line according to the subsection type
+ 
+-Module names in exposed-modules and other-modules are expanded by replacing each dot (.) in the module name with a forward slash (/) and appending \".hs\"
++Module names in exposed-modules and other-modules are expanded by
++replacing each dot (.) in the module name with a forward slash (/) and
++appending \".hs\"
+ 
+ Example: Foo.Bar.Quux ==> Foo/Bar/Quux.hs
+ 
+diff --git a/haskell-compile.el b/haskell-compile.el
+index 667102c..6a8e3cd 100644
+--- a/haskell-compile.el
++++ b/haskell-compile.el
+@@ -41,35 +41,40 @@
+ 
+ (defcustom haskell-compile-cabal-build-command
+   "cabal build --ghc-option=-ferror-spans"
+-  "Default build command to use for `haskell-cabal-build' when a cabal file is detected.
++  "Default build command to use for `haskell-cabal-build' when a cabal
++file is detected.
+ For legacy compat, `%s' is replaced by the cabal package top folder."
+   :group 'haskell-compile
+   :type 'string)
+ 
+ (defcustom haskell-compile-cabal-build-alt-command
+   "cabal clean -s && cabal build --ghc-option=-ferror-spans"
+-  "Alternative build command to use when `haskell-cabal-build' is called with a negative prefix argument.
++  "Alternative build command to use when `haskell-cabal-build' is
++called with a negative prefix argument.
+ For legacy compat, `%s' is replaced by the cabal package top folder."
+   :group 'haskell-compile
+   :type 'string)
+ 
+ (defcustom haskell-compile-stack-build-command
+   "stack build --fast"
+-  "Default build command to use for `haskell-stack-build' when a stack file is detected.
++  "Default build command to use for `haskell-stack-build' when a stack
++file is detected.x
+ For legacy compat, `%s' is replaced by the stack package top folder."
+   :group 'haskell-compile
+   :type 'string)
+ 
+ (defcustom haskell-compile-stack-build-alt-command
+   "stack clean && stack build --fast"
+-  "Alternative build command to use when `haskell-stack-build' is called with a negative prefix argument.
++  "Alternative build command to use when `haskell-stack-build' is
++called with a negative prefix argument.
+ For legacy compat, `%s' is replaced by the stack package top folder."
+   :group 'haskell-compile
+   :type 'string)
+ 
+ (defcustom haskell-compile-command
+   "ghc -Wall -ferror-spans -fforce-recomp -c %s"
+-  "Default build command to use for `haskell-cabal-build' when no cabal or stack file is detected.
++  "Default build command to use for `haskell-cabal-build' when no
++cabal or stack file is detected.
+ The `%s' placeholder is replaced by the current buffer's filename."
+   :group 'haskell-compile
+   :type 'string)
+@@ -82,9 +87,9 @@ The `%s' placeholder is replaced by the current buffer's filename."
+ 
+ (defcustom haskell-compiler-type
+   'auto
+-  "Controls whether to use cabal, stack, or ghc to compile.
+-   Auto (the default) means infer from the presence of a cabal or stack spec file,
+-   following same rules as haskell-process-type."
++  "Controls whether to use cabal, stack, or ghc to compile.  Auto (the
++   default) means infer from the presence of a cabal or stack spec
++   file, following same rules as haskell-process-type."
+     :type '(choice (const auto) (const ghc) (const stack) (const cabal))
+     :group 'haskell-compile)
+ (make-variable-buffer-local 'haskell-compiler-type)
+@@ -170,7 +175,7 @@ base directory for build tools, or the current buffer for
+   (interactive "P")
+   (save-some-buffers (not compilation-ask-about-save)
+                      compilation-save-buffers-predicate)
+-  (let (htype dir)                      
++  (let (htype dir)
+     ;;test haskell-compiler-type to set htype and dir
+     (cond
+      ((eq haskell-compiler-type 'cabal)
+diff --git a/haskell-customize.el b/haskell-customize.el
+index c316de2..235a3c4 100644
+--- a/haskell-customize.el
++++ b/haskell-customize.el
+@@ -172,7 +172,8 @@ pass additional flags to `ghc'."
+ 
+ (defcustom haskell-process-do-cabal-format-string
+   ":!cd %s && %s"
+-  "The way to run cabal comands. It takes two arguments -- the directory and the command.
++  "The way to run cabal comands. It takes two arguments -- the
++directory and the command.
+ See `haskell-process-do-cabal' for more details."
+   :group 'haskell-interactive
+   :type 'string)
+@@ -241,7 +242,8 @@ is a member of the hidden package, blah blah."
+ 
+ (defcustom haskell-process-suggest-overloaded-strings
+   t
+-  "Suggest adding OverloadedStrings pragma to file when getting type mismatches with [Char]."
++  "Suggest adding OverloadedStrings pragma to file when getting type
++mismatches with [Char]."
+   :type 'boolean
+   :group 'haskell-interactive)
+ 
+@@ -409,9 +411,9 @@ imports."
+ presence of a *.cabal file or stack.yaml file or something similar.")
+ 
+ (defun haskell-build-type ()
+-  "Looks for cabal and stack spec files. 
+-   When found, returns a pair (TAG . DIR) 
+-   where TAG is 'cabal-project, 'cabal-sandbox. 'cabal, or 'stack; 
++  "Looks for cabal and stack spec files.
++   When found, returns a pair (TAG . DIR)
++   where TAG is 'cabal-project, 'cabal-sandbox. 'cabal, or 'stack;
+    and DIR is the directory containing cabal or stack file.
+    When none found, DIR is nil, and TAG is 'ghc"
+   ;; REVIEW maybe just 'cabal is enough.
+diff --git a/haskell-indent.el b/haskell-indent.el
+index afa5585..83eb1de 100644
+--- a/haskell-indent.el
++++ b/haskell-indent.el
+@@ -435,7 +435,8 @@ Returns the location of the start of the comment, nil otherwise."
+         (haskell-indent-skip-blanks-and-newlines-forward end))))
+ 
+ (defun haskell-indent-next-symbol-safe (end)
+-  "Puts point to the next following symbol, or to end if there are no more symbols in the sexp."
++  "Puts point to the next following symbol, or to end if there are no
++more symbols in the sexp."
+   (condition-case _errlist (haskell-indent-next-symbol end)
+     (error (goto-char end))))
+ 
+diff --git a/haskell-interactive-mode.el b/haskell-interactive-mode.el
+index f4fb325..ae5fcd3 100644
+--- a/haskell-interactive-mode.el
++++ b/haskell-interactive-mode.el
+@@ -48,7 +48,7 @@
+   "Mark used for the old beginning of the prompt.")
+ 
+ (defun haskell-interactive-prompt-regex ()
+-  "Generate a regex for searching for any occurrence of the prompt\
++  "Generate a regex for searching for any occurrence of the prompt
+ at the beginning of the line.  This should prevent any
+ interference with prompts that look like haskell expressions."
+   (concat "^" (regexp-quote haskell-interactive-prompt)))
+diff --git a/haskell-lexeme.el b/haskell-lexeme.el
+index 622f53f..198c994 100644
+--- a/haskell-lexeme.el
++++ b/haskell-lexeme.el
+@@ -452,8 +452,10 @@ Possible results are:
+ - 'string: for strings literals
+ - 'char: for char literals
+ - 'number: for decimal, float, hexadecimal and octal number literals
+-- 'template-haskell-quote: for a string of apostrophes for template haskell
+-- 'template-haskell-quasi-quote: for a string of apostrophes for template haskell
++- 'template-haskell-quote: for a string of apostrophes for template
++  haskell
++- 'template-haskell-quasi-quote: for a string of apostrophes for
++  template haskell
+ 
+ Note that for qualified symbols (match-string 1) returns the
+ unqualified identifier or symbol.  Further qualification for
+diff --git a/haskell-mode.el b/haskell-mode.el
+index c20e66a..0cedf14 100644
+--- a/haskell-mode.el
++++ b/haskell-mode.el
+@@ -1142,7 +1142,8 @@ successful, nil otherwise."
+  "2015-11-11")
+ 
+ (defun haskell-mode-toggle-scc-at-point ()
+-  "If point is in an SCC annotation, kill the annotation.  Otherwise, try to insert a new annotation."
++  "If point is in an SCC annotation, kill the annotation.
++Otherwise, try to insert a new annotation."
+   (interactive)
+   (if (not (haskell-mode-try-kill-scc-at-point))
+       (if (not (haskell-mode-try-insert-scc-at-point))
+@@ -1181,7 +1182,8 @@ Uses `haskell-guess-module-name-from-file-name'."
+ 
+ (defvar haskell-auto-insert-module-format-string
+   "-- | \n\nmodule %s where\n\n"
+-  "Template string that will be inserted in new haskell buffers via `haskell-auto-insert-module-template'.")
++  "Template string that will be inserted in new haskell buffers via
++`haskell-auto-insert-module-template'.")
+ 
+ (defun haskell-auto-insert-module-template ()
+   "Insert a module template for the newly created buffer."
+diff --git a/haskell-move-nested.el b/haskell-move-nested.el
+index c4a7bd5..1339043 100644
+--- a/haskell-move-nested.el
++++ b/haskell-move-nested.el
+@@ -34,7 +34,8 @@
+ 
+ ;;;###autoload
+ (defun haskell-move-nested (cols)
+-  "Shift the nested off-side-rule block adjacent to point by COLS columns to the right.
++  "Shift the nested off-side-rule block adjacent to point by COLS
++columns to the right.
+ 
+ In Transient Mark mode, if the mark is active, operate on the contents
+ of the region instead.
+diff --git a/haskell-process.el b/haskell-process.el
+index 2ca131f..f1f5303 100644
+--- a/haskell-process.el
++++ b/haskell-process.el
+@@ -205,7 +205,8 @@ HPTYPE is the result of calling `'haskell-process-type`' function."
+     t))
+ 
+ (defun haskell-process-send-string (process string)
+-  "Try to send a string to the process's process. Ask to restart if it's not running."
++  "Try to send a string to the process's process. Ask to restart if
++it's not running."
+   (let ((child (haskell-process-process process)))
+     (if (equal 'run (process-status child))
+         (let ((out (concat string "\n")))
+diff --git a/haskell.el b/haskell.el
+index a679b62..66e5f7e 100644
+--- a/haskell.el
++++ b/haskell.el
+@@ -446,7 +446,7 @@ Give optional NEXT-P parameter to override value of
+                       (list "build --ghc-options=-fforce-recomp"))))))
+ 
+ (defun haskell-process-file-loadish (command reload-p module-buffer)
+-  "Run a loading-ish COMMAND that wants to pick up type errors\
++  "Run a loading-ish COMMAND that wants to pick up type errors
+ and things like that.  RELOAD-P indicates whether the notification
+ should say 'reloaded' or 'loaded'.  MODULE-BUFFER may be used
+ for various things, but is optional."
+diff --git a/inf-haskell.el b/inf-haskell.el
+index e62b6ed..1bda90e 100644
+--- a/inf-haskell.el
++++ b/inf-haskell.el
+@@ -74,7 +74,8 @@ directory structure."
+ 
+ (defvar inferior-haskell-multiline-prompt-re
+   "^\\*?[[:upper:]][\\._[:alnum:]]*\\(?: \\*?[[:upper:]][\\._[:alnum:]]*\\)*| "
+-  "Regular expression for matching multiline prompt (the one inside :{ ... :} blocks).")
++  "Regular expression for matching multiline prompt (the one inside
++:{ ... :} blocks).")
+ 
+ (defconst inferior-haskell-error-regexp-alist
+   `(;; Format of error messages used by GHCi.
+diff --git a/w3m-haddock.el b/w3m-haddock.el
+index 141cbf4..4ef6a88 100644
+--- a/w3m-haddock.el
++++ b/w3m-haddock.el
+@@ -49,7 +49,9 @@ directories of package-name-x.x.
+ You can rebind this if you're using hsenv by adding it to your
+ .dir-locals.el in your project root. E.g.
+ 
+-    ((haskell-mode . ((haskell-w3m-haddock-dirs . (\"/home/chris/Projects/foobar/.hsenv/cabal/share/doc\")))))
++    ((haskell-mode .
++      ((haskell-w3m-haddock-dirs .
++       (\"/home/chris/Projects/foobar/.hsenv/cabal/share/doc\")))))
+ 
+ "
+   :group 'haskell
-- 
2.36.0