Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haskell-process-generate-tags doesn't work in windows #49

Closed
josh-j opened this issue May 25, 2012 · 4 comments
Closed

haskell-process-generate-tags doesn't work in windows #49

josh-j opened this issue May 25, 2012 · 4 comments

Comments

@josh-j
Copy link

josh-j commented May 25, 2012

(format ":!cd %s && %s | %s | %s"
                 (haskell-session-cabal-dir (haskell-process-session (car state)))
                 "find . -name '*.hs*'"
                 "grep -v '#'" ; To avoid Emacs back-up files. Yeah.
                 "xargs hasktags -e -x")))

I think you'd have to find another way to do that; grep, find, xargs aren't on windows--you might be able to use powershell commands instead.

ETA: This might help.

ETA2: The necessary powershell command is hasktags -e -x (ls -fi *.hs -exclude "#*" -name -r). I don't know elisp or how :!cd works, but from powershell you'd need to do cd %s ; %s

@chrisdone
Copy link
Member

Can you contribute a patch that works and checks for Windows? I don't have Windows.

The whole thing is sent to the GHCi process. : is how you give commands to GHCi. :! is one of the commands, it's for running shell commands. :!ls gives a list of the current dir.

@josh-j
Copy link
Author

josh-j commented May 29, 2012

I have haskell-process-generate-tags working on Windows, but not with haskell-process-send-string. I have to use shell-command, start-process, or call-process (btw, which is the best in this case?)*. For some reason haskell-process-send-string simply does nothing when I use it with the powershell command.

Symptom with haskell-process-send-string: :!dir works correctly in the Haskell-mode REPL, but :!powershell ls freezes the REPL after it's done printing out the directory. Something similar happens with winghci, but I'm able to press enter after :!powershell ls finished its output, and then I get back to the REPL prompt. This doesn't happen if I open ghci from cmd.exe.

I'm assuming this means powershell is expecting input after it finishes its command (the -NonInteractive flag doesn't help).

* I was mistaken.

@josh-j
Copy link
Author

josh-j commented Jun 2, 2012

(defun haskell-process-generate-tags (&optional and-then-find-this-tag)
  "Regenerate the TAGS table."
  (interactive)
  (let ((process (haskell-process)))
    (haskell-process-queue-command
     process
     (haskell-command-make
      (cons process and-then-find-this-tag)
      (lambda (state)
        (if (eq system-type 'windows-nt)
            (shell-command
              (format "powershell -Command \"& { cd %s ; hasktags -e -x (ls -fi *.hs -exclude \\\"#*#\\\" -name -r) }\""
                      (haskell-session-cabal-dir (haskell-process-session (car state)))))
          (haskell-process-send-string
            (car state)
            (format ":!cd %s && %s | %s | %s"
              (haskell-session-cabal-dir (haskell-process-session (car state)))
              "find . -name '*.hs*'"
              "grep -v '#'" ; To avoid Emacs back-up files. Yeah.
              "xargs hasktags -e -x"))))
         nil
         (lambda (state response)
           (when (cdr state)
             (let ((tags-file-name
                    (haskell-session-tags-filename (haskell-process-session (car state)))))
               (find-tag (cdr state))))
           (haskell-mode-message-line "Tags generated."))))))

Is what the code looks like using shell-command, if anyone is interested. Maybe someone else can figure out how to get it working with haskell-process-send-string (or I'll try if I get around to learning elisp).

@chrisdone
Copy link
Member

Will merge a pull request if one is made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants