Question

Many times it happens that while I try to compile an .hs file, the Emacs 23 Haskell mode goes into an unending process and does not show any response. The only thing that happens is that the cursor turns into a circle and within the circle the dots start circling.

What is the best approach to avoid this situation? If I get into this situation, how can I get out? At present, I restart my computer. Please guide.

Recently, it happened for the following code:

import Control.Monad
import Data.Char
main = do
  putStrLn "This is an addition"
  contents <- getContents
  putStrLn $ (shortLinesOnly contents)
  shortLinesOnly :: String -> String
shortLinesOnly input =
  allLines = lines input
   shortLines = filter (\line -> length line < 10) allLines
               res = unlines shortLines
                     in result
Was it helpful?

Solution

Maybe it would make sense to find the function that does the compilation and wrap it into something like:

(with-local-quit
  (with-timeout (60 (error "The process didn't finish in 60 seconds"))
     ;; do the calls to the compiler here
     ))

If this has not been done already. If this has been done, then, as illusionoflife suggested, you should be able to interrupt the process with C-g.

Sometimes, however, Emacs may become too slow or too unresponsive (the system may give very high priority to the process it launched, so that you will have to wait very long until the control will return to Emacs from a blocking process with high priority). Still, this is not yet the reason to restart the computer. On Linux, you are probably running in runlevel 3, in which case you could do Ctrl+Alt+1 or any number less then the shell running X-server, then do

$ ps aux | grep "my process name"

this will print you some details about the process, starting with its id, given the id you can do:

$ kill id

Alternatively, you could just kill all instances of emacs and all processes spawned from it:

$ killall emacs

OTHER TIPS

Use C-g. You can use it to stop any sync process, internal or external.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top