Skip to content

Commit 42243f5

Browse files
committed
Add support for passing arguments to the command specified by haskell-mode-stylish-haskell-path
1 parent 23978d3 commit 42243f5

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

haskell-commands.el

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
:group 'haskell
4444
:type 'string)
4545

46+
(defcustom haskell-mode-stylish-haskell-args nil
47+
"Arguments to pass to program specified by haskell-mode-stylish-haskell-path."
48+
:group 'haskell
49+
:type 'list)
50+
4651
(defcustom haskell-interactive-set-+c
4752
t
4853
"Issue ':set +c' in interactive session to support type introspection."
@@ -806,9 +811,9 @@ stylish-haskell executable. This function tries to preserve
806811
cursor position and markers by using
807812
`haskell-mode-buffer-apply-command'."
808813
(interactive)
809-
(haskell-mode-buffer-apply-command haskell-mode-stylish-haskell-path))
814+
(haskell-mode-buffer-apply-command haskell-mode-stylish-haskell-path haskell-mode-stylish-haskell-args))
810815

811-
(defun haskell-mode-buffer-apply-command (cmd)
816+
(defun haskell-mode-buffer-apply-command (cmd &optional args)
812817
"Execute shell command CMD with current buffer as input and output.
813818
Use buffer as input and replace the whole buffer with the
814819
output. If CMD fails the buffer remains unchanged."
@@ -817,9 +822,9 @@ output. If CMD fails the buffer remains unchanged."
817822
(err-file (make-temp-file "stylish-error")))
818823
(unwind-protect
819824
(let* ((_errcode
820-
(call-process-region (point-min) (point-max) cmd nil
821-
`((:file ,out-file) ,err-file)
822-
nil))
825+
(apply 'call-process-region (point-min) (point-max) cmd nil
826+
`((:file ,out-file) ,err-file)
827+
nil args))
823828
(err-file-empty-p
824829
(equal 0 (nth 7 (file-attributes err-file))))
825830
(out-file-empty-p

0 commit comments

Comments
 (0)