haskell-mode icon indicating copy to clipboard operation
haskell-mode copied to clipboard

haskell-interactive-bring process buffer not compatible with org-mode babel ob-haskell session buffer

Open stardiviner opened this issue 9 years ago • 14 comments

When I execute command haskell-interactive-bring will start a process buffer named *haskell* from haskell source code buffer.

When I execute Org-mode Babel haskell src block like this:

#+BEGIN_SRC haskell
1 + 3
#+END_SRC

It will start a session buffer named *haskell* too.

But the problem is they are not compatible with each other.

If I start haskell process buffer from haskell source code buffer with command haskell-interactive-bring at first, then run the Org-mode haskell babel src block, then I will get error:

org-babel-execute:haskell: Buffer *haskell* does not exist or has no process

And in reverse, execute org-mode babel at first to start the session buffer, then I run command haskell-interactive-bring from haskell source code buffer, I will get another error:

Debugger entered--Lisp error: (error "Format specifier doesn’t match argument type")
  format("*%s <%d>*" "haskell" "nil")
  haskell-session-interactive-buffer(((name . "haskell")))
  haskell-interactive-bring()
  funcall-interactively(haskell-interactive-bring)
  call-interactively(haskell-interactive-bring nil nil)
  command-execute(haskell-interactive-bring)

stardiviner avatar Sep 30 '16 14:09 stardiviner

Can you provide a PR? As I understand the point is to rename the buffer and make it unique, right?

gracjan avatar Oct 08 '16 08:10 gracjan

No, ob-haskell and haskell-interactive-mode should both use same *haskell* inferior process buffer. The problem is that one of them started *haskell*, but later the other can't recognize it. Report error:

Buffer *haskell* does not exist or has no process

stardiviner avatar Oct 08 '16 14:10 stardiviner

Any updated on this?

stardiviner avatar Nov 17 '16 13:11 stardiviner

@stardiviner It looks like ob-haskell will need to be updated to use haskell-interactive-mode instead of inf-haskell.

codygman avatar Dec 30 '16 09:12 codygman

So in ob-haskell I think run-haskell is failing. run-haskell is created by declare-function which appears to start the entire mode or something, I'm not really sure to be honest. Maybe tomorrow I can step through it in a debugger.

codygman avatar Dec 30 '16 09:12 codygman

I also just ran into this issue I believe:

org-babel--get-vars not defined in orgmode<=8.3.4

codygman avatar Dec 30 '16 18:12 codygman

Just for more information, here is my info:

System Info :computer:

  • OS: gnu/linux
  • Emacs: 25.1.50.2
  • Spacemacs: 0.200.5
  • Spacemacs branch: master (rev. 664ba6a)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(rust csv yaml auto-completion emacs-lisp git org
      (shell :variables shell-default-height 30 shell-default-position 'bottom)
      syntax-checking markdown haskell purescript javascript clojure scala go)
  • System configuration features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11

I'm feeling uneasy about getting the issue above since I have the latest org-mode. What I'll do is delete all of my packages and reinstall, then see if I can replicate that error.

codygman avatar Dec 30 '16 18:12 codygman

Neither org-20161224 nor org-plus-contrib-20161224 seem to contain org-babel-get-header or org-babel--get-vars, so we can't use the same fix they did. Actually no, org-babel-get-header seems to be there but I can't find it with grep so I guess it is generated somehow.

The fix they did in the ob-go should work.

codygman avatar Dec 30 '16 19:12 codygman

Default Haskell session name comes from haskell-session-default-name which is haskell by default. If you change that there no longer will be collision with ob-haskell.

Not that it solves the problem for everybody, but at least it removes the collision for now.

gracjan avatar Jan 13 '17 09:01 gracjan

I tried change the function haskell-session-default-name definition:

(defun haskell-session-default-name ()
    "Generate a default project name for the new project prompt."
    (let ((file (haskell-cabal-find-file)))
      (or (when file
            (downcase (file-name-sans-extension
                       (file-name-nondirectory file))))
          "*haskell*")))

But it does not work.

And in new version Org-mode, new error occurs:

Emacs version:

GNU Emacs 25.1.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.5) of 2016-12-23

Org-mode version: 9.0.3

main :: IO ()
main = do
  putStrLn "Hello, World!"
"org-babel-haskell-eoe"
Loaded GHCi configuration from /home/stardiviner/.ghci
λ> 
<interactive>:1:1: error:
    • Variable not in scope: main :: IO ()
    • Perhaps you meant ‘min’ (imported from Prelude)
λ> 
<interactive>:2:8: error: Empty 'do' block
λ> Hello, World!
λ> "org-babel-haskell-eoe"
λ> 

stardiviner avatar Jan 14 '17 02:01 stardiviner

Hmm, it looks like it tries to load the haskell source code verbatim to GHCi in single line mode. This will not work this way, it has to save the source code to a file and load that.

I'm not sure how ob-haskell works, but it should have a switch to make it write to file.

gracjan avatar Jan 16 '17 11:01 gracjan

Is there any update on this?

yiufung avatar Sep 03 '18 15:09 yiufung

These days i think inf-haskell has a different error with org-babel. It seems to fail to create a haskell buffer/session on my machines which results in make-comint failing. This issue though may or may not be fixed... not sure.

On Mon, Sep 3, 2018 at 10:10 AM Yiufung Cheong [email protected] wrote:

Is there any update on this?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/haskell/haskell-mode/issues/1429#issuecomment-418141616, or mute the thread https://github.com/notifications/unsubscribe-auth/AANyN0YdyX_uOEigOAJu8WhfM-cOJlJUks5uXUZmgaJpZM4KLKIW .

codygman avatar Sep 04 '18 17:09 codygman

Just ran into this.

dustinlacewell avatar Sep 10 '20 03:09 dustinlacewell