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-mode-contextual-space called on zero length identifier #572

Closed
RasmusWL opened this issue Apr 7, 2015 · 8 comments
Closed

haskell-mode-contextual-space called on zero length identifier #572

RasmusWL opened this issue Apr 7, 2015 · 8 comments

Comments

@RasmusWL
Copy link

RasmusWL commented Apr 7, 2015

I tried turning on debug-on-error in my emacs, and it comes up with the following error when performing a haskell-mode-contextual-space. This bug seems to break the current session, as nothing happens when i call haskell-process-cabal-build.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("^[A-Za-z_]" nil)
  #[(state) "\301�@\302\303�A\"\203��\304\305�A\"\202��\304\306�A\"\"\207" [state haskell-process-send-string string-match "^[A-Za-z_]" format ":info %s" ":info (%s)"] 5]((((name . "futhark") (current-response-cursor . 0) (current-response . "") (command-queue) (inferior-process . #<process futhark>) (is-restarting) (current-command . [cl-struct-haskell-command #0 #[(state) "\301�@\302\303�A\"\203��\304\305�A\"\202��\304\306�A\"\"\207" [state haskell-process-send-string string-match "^[A-Za-z_]" format ":info %s" ":info (%s)"] 5] nil #[(state response) "\301\302�\"\206��\301\303�\"?\205��\304�!\207" [response string-match "^Top level" "^<interactive>" haskell-mode-message-line] 3]]) (suggested-imported) (sent-stdin) (evaluating) (session (name . "futhark") (ignored-files "/home/rasmus/uni/flat/futhark/.ghci" "/home/rasmus/uni/flat/futhark") (interactive-buffer . #<buffer *futhark*>) (current-dir . "/home/rasmus/uni/flat/futhark/") (target . "") (cabal-checksum . "7e75d6e37133be0705f160ed78fc3dd7") (cabal-dir . "/home/rasmus/uni/flat/futhark/") (process (name . "futhark") (current-response-cursor . 0) (current-response . "") (command-queue) (inferior-process . #<process futhark>) (is-restarting) (current-command . [cl-struct-haskell-command #0 #[(state) "\301�@\302\303�A\"\203��\304\305�A\"\202��\304\306�A\"\"\207" [state haskell-process-send-string string-match "^[A-Za-z_]" format ":info %s" ":info (%s)"] 5] nil #[(state response) "\301\302�\"\206��\301\303�\"?\205��\304�!\207" [response string-match "^Top level" "^<interactive>" haskell-mode-message-line] 3]]) (suggested-imported) (sent-stdin) (evaluating) #2)))))
  haskell-command-exec-go([cl-struct-haskell-command (((name . "futhark") (current-response-cursor . 0) (current-response . "") (command-queue) (inferior-process . #<process futhark>) (is-restarting) (current-command . #0) (suggested-imported) (sent-stdin) (evaluating) (session (name . "futhark") (ignored-files "/home/rasmus/uni/flat/futhark/.ghci" "/home/rasmus/uni/flat/futhark") (interactive-buffer . #<buffer *futhark*>) (current-dir . "/home/rasmus/uni/flat/futhark/") (target . "") (cabal-checksum . "7e75d6e37133be0705f160ed78fc3dd7") (cabal-dir . "/home/rasmus/uni/flat/futhark/") (process (name . "futhark") (current-response-cursor . 0) (current-response . "") (command-queue) (inferior-process . #<process futhark>) (is-restarting) (current-command . #0) (suggested-imported) (sent-stdin) (evaluating) #3)))) #[(state) "\301�@\302\303�A\"\203��\304\305�A\"\202��\304\306�A\"\"\207" [state haskell-process-send-string string-match "^[A-Za-z_]" format ":info %s" ":info (%s)"] 5] nil #[(state response) "\301\302�\"\206��\301\303�\"?\205��\304�!\207" [response string-match "^Top level" "^<interactive>" haskell-mode-message-line] 3]])
  haskell-process-trigger-queue(((name . "futhark") (current-response-cursor . 0) (current-response . "") (command-queue) (inferior-process . #<process futhark>) (is-restarting) (current-command . [cl-struct-haskell-command (#0) #[(state) "\301�@\302\303�A\"\203��\304\305�A\"\202��\304\306�A\"\"\207" [state haskell-process-send-string string-match "^[A-Za-z_]" format ":info %s" ":info (%s)"] 5] nil #[(state response) "\301\302�\"\206��\301\303�\"?\205��\304�!\207" [response string-match "^Top level" "^<interactive>" haskell-mode-message-line] 3]]) (suggested-imported) (sent-stdin) (evaluating) (session (name . "futhark") (ignored-files "/home/rasmus/uni/flat/futhark/.ghci" "/home/rasmus/uni/flat/futhark") (interactive-buffer . #<buffer *futhark*>) (current-dir . "/home/rasmus/uni/flat/futhark/") (target . "") (cabal-checksum . "7e75d6e37133be0705f160ed78fc3dd7") (cabal-dir . "/home/rasmus/uni/flat/futhark/") (process (name . "futhark") (current-response-cursor . 0) (current-response . "") (command-queue) (inferior-process . #<process futhark>) (is-restarting) (current-command . [cl-struct-haskell-command (#0) #[(state) "\301�@\302\303�A\"\203��\304\305�A\"\202��\304\306�A\"\"\207" [state haskell-process-send-string string-match "^[A-Za-z_]" format ":info %s" ":info (%s)"] 5] nil #[(state response) "\301\302�\"\206��\301\303�\"?\205��\304�!\207" [response string-match "^Top level" "^<interactive>" haskell-mode-message-line] 3]]) (suggested-imported) (sent-stdin) (evaluating) #1))))
  haskell-process-queue-command(((name . "futhark") (current-response-cursor . 0) (current-response . "") (command-queue) (inferior-process . #<process futhark>) (is-restarting) (current-command . [cl-struct-haskell-command (#0) #[(state) "\301�@\302\303�A\"\203��\304\305�A\"\202��\304\306�A\"\"\207" [state haskell-process-send-string string-match "^[A-Za-z_]" format ":info %s" ":info (%s)"] 5] nil #[(state response) "\301\302�\"\206��\301\303�\"?\205��\304�!\207" [response string-match "^Top level" "^<interactive>" haskell-mode-message-line] 3]]) (suggested-imported) (sent-stdin) (evaluating) (session (name . "futhark") (ignored-files "/home/rasmus/uni/flat/futhark/.ghci" "/home/rasmus/uni/flat/futhark") (interactive-buffer . #<buffer *futhark*>) (current-dir . "/home/rasmus/uni/flat/futhark/") (target . "") (cabal-checksum . "7e75d6e37133be0705f160ed78fc3dd7") (cabal-dir . "/home/rasmus/uni/flat/futhark/") (process (name . "futhark") (current-response-cursor . 0) (current-response . "") (command-queue) (inferior-process . #<process futhark>) (is-restarting) (current-command . [cl-struct-haskell-command (#0) #[(state) "\301�@\302\303�A\"\203��\304\305�A\"\202��\304\306�A\"\"\207" [state haskell-process-send-string string-match "^[A-Za-z_]" format ":info %s" ":info (%s)"] 5] nil #[(state response) "\301\302�\"\206��\301\303�\"?\205��\304�!\207" [response string-match "^Top level" "^<interactive>" haskell-mode-message-line] 3]]) (suggested-imported) (sent-stdin) (evaluating) #1))) [cl-struct-haskell-command (((name . "futhark") (current-response-cursor . 0) (current-response . "") (command-queue) (inferior-process . #<process futhark>) (is-restarting) (current-command . #0) (suggested-imported) (sent-stdin) (evaluating) (session (name . "futhark") (ignored-files "/home/rasmus/uni/flat/futhark/.ghci" "/home/rasmus/uni/flat/futhark") (interactive-buffer . #<buffer *futhark*>) (current-dir . "/home/rasmus/uni/flat/futhark/") (target . "") (cabal-checksum . "7e75d6e37133be0705f160ed78fc3dd7") (cabal-dir . "/home/rasmus/uni/flat/futhark/") (process (name . "futhark") (current-response-cursor . 0) (current-response . "") (command-queue) (inferior-process . #<process futhark>) (is-restarting) (current-command . #0) (suggested-imported) (sent-stdin) (evaluating) #3)))) #[(state) "\301�@\302\303�A\"\203��\304\305�A\"\202��\304\306�A\"\"\207" [state haskell-process-send-string string-match "^[A-Za-z_]" format ":info %s" ":info (%s)"] 5] nil #[(state response) "\301\302�\"\206��\301\303�\"?\205��\304�!\207" [response string-match "^Top level" "^<interactive>" haskell-mode-message-line] 3]])
  haskell-process-do-try-info(nil)
  haskell-mode-contextual-space()
  ad-Orig-call-interactively(haskell-mode-contextual-space nil nil)
  (with-no-warnings (ad-Orig-call-interactively function record-flag keys))
  (setq ad-return-value (with-no-warnings (ad-Orig-call-interactively function record-flag keys)))
  (let ((ido-ubiquitous-next-override (ido-ubiquitous-get-command-override function))) (setq ad-return-value (with-no-warnings (ad-Orig-call-interactively function record-flag keys))))
  (ido-ubiquitous-with-override (ido-ubiquitous-get-command-override function) (setq ad-return-value (with-no-warnings (ad-Orig-call-interactively function record-flag keys))))
  (let (ad-return-value) (ido-ubiquitous-with-override (ido-ubiquitous-get-command-override function) (setq ad-return-value (with-no-warnings (ad-Orig-call-interactively function record-flag keys)))) ad-return-value)
  call-interactively(haskell-mode-contextual-space nil nil)

Specs

I'm using haskell-mode-20150403.1144 with emacs 24.3.1 onUbuntu 14.04.2 LTS, using ghc 7.8.4 and cabal 1.22.2.0

init.el

Here is the haskell part of my init.el (no ghc-mod currently)

(require 'haskell-mode)
(load "haskell-mode-autoloads")

(eval-after-load 'haskell-mode
  '(progn
     (setq haskell-notify-p t)
     (setq haskell-tags-on-save t)
     (setq haskell-indent-offset 2)))

(add-hook 'haskell-mode-hook 'rwl-haskell-hook)

(defun rwl-haskell-hook ()
  (turn-on-haskell-simple-indent)
  (define-key haskell-mode-map (kbd "<return>") 'haskell-simple-indent-newline-same-col)
  (define-key haskell-mode-map (kbd "C-<return>") 'haskell-simple-indent-newline-indent)

  ;; Taken from Troels / haskell-mode example
  ;; Contextually do clever things on the space key, in particular:
  ;;   1. Complete imports, letting you choose the module name.
  ;;   2. Show the type of the symbol after the space.
  (define-key haskell-mode-map (kbd "SPC") 'haskell-mode-contextual-space)

  ;; Jump to the imports. Keep tapping to jump between import
  ;; groups. C-u f8 to jump back again.
  (define-key haskell-mode-map [f8] 'haskell-navigate-imports)

  ;; Indent the below lines on columns after the current column.
  (define-key haskell-mode-map (kbd "C-S-<right>")
    (lambda ()
      (interactive)
      (haskell-move-nested 1)))
  ;; Same as above but backwards.
  (define-key haskell-mode-map (kbd "C-S-<left>")
    (lambda ()
      (interactive)
      (haskell-move-nested -1)))

  (interactive-haskell-mode t))
@gracjan
Copy link
Contributor

gracjan commented Apr 7, 2015

@RasmusWL: thanks for the report.

As I see contetual space tries to do :info on the symbol it finds, except it find an empty symbol. What is the thing just before the space?

@gracjan gracjan changed the title haskell-mode-contextual-space bug (?) haskell-mode-contextual-space called on zero length identifier Apr 7, 2015
@RasmusWL
Copy link
Author

RasmusWL commented Apr 7, 2015

At least it happens when point is at the beginning of an empty line

@gracjan
Copy link
Contributor

gracjan commented Apr 7, 2015

Where does this idea of contextual space come from? There are so much wrong about it:

  • for completions Emacs usually uses TAB not space
  • it works only when non-obvious conditions are met
  • it sometimes pops up Minibuffer, thus space gets into interactive entry mode (when completing import)
  • it sometimes does not pop up Minibuffer, just does :info for a near by symbol
  • whole thing can just hang due to interactive-haskell being in non-receptive state
  • and it will sometimes sort and align the whole import group

And all of that just after a SPACEBAR!

What was the reasoning behind this function?

@gracjan
Copy link
Contributor

gracjan commented Apr 8, 2015

@RasmusWL: are you actually trying to use contextual space for something useful or you just enabled it because it was in init.el?

@RasmusWL
Copy link
Author

RasmusWL commented Apr 8, 2015

I saw it in the example section on this repo, so I just wanted to try it out. The one time it worked I thought: "oh, that could probably be useful".

@gracjan
Copy link
Contributor

gracjan commented Apr 8, 2015

That is what I thought. Contextual space is a nice idea and I'm afraid that inner workings of interactive-haskell-mode are not a solid enough foundation to provide such functionality.

@RasmusWL
Copy link
Author

RasmusWL commented Apr 8, 2015

So what is going to happen to it then?

@gracjan
Copy link
Contributor

gracjan commented Apr 8, 2015 via email

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

No branches or pull requests

2 participants