« Basic pointers on Latent Semantic Analysis and other semantic space modelsWindow switching in haskell-mode fixed »

How to prevent haskell-mode 2.4 from guessing and changing the working directory

07/02/09

Permalink 03:51:37 pm, 246 words
Categories: Code

How to prevent haskell-mode 2.4 from guessing and changing the working directory

Edit: Thorsten Altenkirch pointed out that inferior-haskell-mode defines a defcustom inferior-haskell-find-project-root in addition to defining a function named the same thing. So the fix is actually to add the line ‘(inferior-haskell-find-project-root nil) in your ‘custom-set-variables. Ignore my advice to edit the inf-haskell.el.


I disabled haskell-mode 2.4’s code that changes the current directory after it detects your project root. I’m sure this works great if you have a Cabal project set up, but I don’t. So find the function inferior-haskell-load-file and comment out the unless clause after the comment “Not sure if it’s useful/needed and if it actually works". The author was suspicious of this code, and rightly so.

        ;; Go to the root of the Cabal project, if applicable.
        (when (and inferior-haskell-find-project-root
                   (setq root (inferior-haskell-find-project-root buf)))
          ;; Not sure if it's useful/needed and if it actually works.
          ; Answer: No, it wasn't, and find-project-root doesn't work.
          ;(unless (equal default-directory root)
          ;  (setq default-directory root)
          ;  (inferior-haskell-send-command
          ;   proc (concat ":cd " default-directory)))

The result from inferior-haskell-find-project-root is wrong and I don’t have time to fix the function. I’ll worry about fixing it when I’m retired, or when I start developing heaps of open source software in Haskell. Whichever comes first.

Note: my research code is notionally open source, but I’m too lazy to package it up in a cabal project. HOWEVER, I am going to put up an unfinished Research page today that links to my existing disorganised code. The links will not work, but you can click them anyway.

6 comments

Comment from: Thorsten Altenkirch [Visitor] Email
Isn't it easier just to set inferior-haskell-find-project-root to nil?
21/02/09 @ 10:02
Comment from: sandersn [Member]
Oh. Yes. I don't know elisp that well. I'm not used to elisp's lack of namespaces but (apparently) multiple slots for each name. So when I read

(and inferior-haskell-find-project-root (setq root (inferior-haskell-find-project-root buf)))

I assumed that 'inferior-haskell-find-project-root was a function and *only* a function because of the second argument to 'and. I thought use of 'and was just defensive programming to check if somebody had undefined the function.

Turns out that inferior-haskell-find-project-root is also a variable exposed to customize.

I'll amend the tip to be much simpler and more trivial. Thanks!
21/02/09 @ 17:04
Comment from: Brad Larsen [Visitor] Email · http://ragingrobot.net
Thanks for the tip! This fixed my inf-haskell woes.
31/07/09 @ 14:26
Comment from: registry clean [Visitor] Email · http://www.RegTidy.com
very informative article. It is helpful to
me. Thank you.
23/09/09 @ 23:08
Comment from: Vilhelm S [Visitor]
Just what I was looking for!

But your first paragraph has a typo, it should say

‘(inferior-haskell-find-project-root nil)

not

‘(inferior-haskell-find-project nil)
28/04/10 @ 17:25
Comment from: sandersn [Member]
Thanks for pointing that out. I fixed it.
30/04/10 @ 07:48

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
powered by b2evolution