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 becomes unresponsive when adding a language pragma #820

Closed
mpickering opened this issue Aug 19, 2015 · 20 comments
Closed

haskell-mode becomes unresponsive when adding a language pragma #820

mpickering opened this issue Aug 19, 2015 · 20 comments

Comments

@mpickering
Copy link

When haskell-mode offers to add a language pragma or a cabal package
dependency, emacs becomes unresponsive. C-g does not make emacs
responsive. The only way to continue working with emacs is to kill the
ghc process.

Emacs setting

In GNU Emacs 24.5.1 (x86_64-w64-mingw32)
of 2015-04-12 on KAEL
Windowing system distributor Microsoft Corp.', version 6.1.7601 Configured using: configure --prefix=/z/emacs --host=x86_64-w64-mingw32
--target=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --with-wide-int
--with-jpeg --with-xpm --with-png --with-tiff --with-rsvg --with-xml2
--with-gnutls --with-sound=yes --with-file-notification=yes
--without-dbus --without-imagemagick 'CFLAGS=-Ofast
-fomit-frame-pointer -funroll-loops -g0 -pipe' 'LDFLAGS=-static-libgcc
-static-libstdc++ -static -s -Wl,-s''

Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: cp1252

Major mode: Haskell

Minor modes in effect:
global-semanticdb-minor-mode: t
global-semantic-idle-scheduler-mode: t
semantic-mode: t
diff-auto-refine-mode: t
yas-minor-mode: t
haskell-indentation-mode: t
shell-dirtrack-mode: t
interactive-haskell-mode: t
flycheck-mode: t
show-paren-mode: t
global-hl-line-mode: t
elscreen-persist-mode: t
desktop-save-mode: t
delete-selection-mode: t
auto-insert-mode: t
guru-global-mode: t
guru-mode: t
ido-everywhere: t
display-time-mode: t
tooltip-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t

Features:
(pp shadow sort mail-extr emacsbug sendmail calculator semantic/edit
semantic/tag-write jtags-extras jtags superword subword semantic/db-file
data-debug cedet-files semantic/wisent/java-tags semantic/java
semantic/decorate/include semantic/db-find semantic/db-ref
semantic/decorate/mode semantic/decorate pulse semantic/doc
semantic/wisent/javat-wy semantic/wisent semantic/wisent/wisent
semantic/db-mode semantic/db eieio-base semantic/idle semantic/format
ezimage semantic/tag-ls semantic/find semantic/ctxt semantic/util-modes
semantic/util semantic semantic/tag semantic/lex semantic/fw mode-local
cedet cc-langs browse-url autorevert filenotify log-edit message rfc822
mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047
rfc2045 ietf-drums mailabbrev gmm-utils mailheader pcvs-util add-log
diff-mode vc-bzr vc-sccs vc-svn vc-cvs vc-rcs vc-dir ewoc vc
vc-dispatcher autopair cl-macs smex hippie-exp misearch multi-isearch
thingatpt vc-git java-snippets yasnippet haskell-indentation haskell-doc
eldoc inf-haskell haskell-decl-scan imenu shell haskell
haskell-completions haskell-load haskell-commands highlight-uses-mode
haskell-modules haskell-sandbox haskell-repl haskell-debug
haskell-interactive-mode haskell-presentation-mode haskell-collapse
haskell-navigate-imports haskell-compile haskell-process haskell-session
haskell-cabal haskell-utils url-util url-parse auth-source eieio
byte-opt bytecomp byte-compile cl-extra haskell-font-lock pcase cconv
eieio-core password-cache url-vars json flycheck help-mode subr-x dash
ghc ghc-indent ghc-ins-mod ghc-command ghc-check ghc-doc ghc-info
ghc-comp ghc-rewrite ghc-process ghc-func haskell-mode haskell-string
haskell-sort-imports haskell-lexeme rx haskell-align-imports
haskell-compat haskell-complete-module flymake etags compile dabbrev
haskell-customize saveplace org-w3m org-irc org-info org-bibtex bibtex
org-bbdb ob-plantuml ob-latex ob-haskell ob-C cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs paren gnus
gnus-ems nnheader gnus-util mail-utils mm-util mail-prsvr wid-edit
hl-line elscreen-persist revive desktop frameset delsel autoinsert
cus-start cus-load ws-butler cl gv mule-util elscreen dired guru-mode
edmacro kmacro cl-loaddefs cl-lib ido ox-latex ox-icalendar ox-html
ox-ascii ox-publish ox org-element avl-tree org advice help-fns
org-macro org-footnote org-pcomplete pcomplete org-list org-faces
org-entities noutline outline easy-mmode org-version ob-emacs-lisp ob
ob-tangle ob-ref ob-lob ob-table ob-exp org-src ob-keys ob-comint comint
ansi-color ring ob-core ob-eval org-compat org-macs org-loaddefs
find-func cal-menu calendar cal-loaddefs format-spec org-install
boron-theme tex-site info easymenu package epg-config time time-date
tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
dos-w32 ls-lisp w32-common-fns disp-table w32-win w32-vars tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
w32notify w32 multi-tty emacs)

Memory information:
((conses 16 542652 80020)
(symbols 56 47672 0)
(miscs 48 1044 1302)
(strings 32 111366 10681)
(string-bytes 1 3560275)
(vectors 16 52504)
(vector-slots 8 1051076 12779)
(floats 8 312 323)
(intervals 56 11372 4138)
(buffers 960 43))

@gracjan
Copy link
Contributor

gracjan commented Aug 19, 2015 via email

@dysinger
Copy link

dysinger commented Sep 2, 2015

I'm also experiencing this crash every single time on the latest melpa release.

I'm on Emacs 24 on Ubuntu 15.04

@gracjan
Copy link
Contributor

gracjan commented Sep 3, 2015

This is very surprising, at least the LANGUAGE pragma. We use precomputed list of available extensions, so there should be no interaction with ghc at this point.

@vejkse
Copy link

vejkse commented Sep 3, 2015

I’m also using the latest melpa release with emacs 24.5.1 and I can bring a few precisions:

  • emacs recovers its responsiveness after hitting C-g 3 times (or, as said above, killing ghc, but this is unnecessary, at least in my case);
  • the answers (y/n) are not discarded, but inserted into the source code once emacs is responsive again;
  • it happens also when unnecessary imports are suggested for removal.

Edit: I investigated the question further and it seems that I found the culprit: when haskell-doc-mode is turned on, the problem is present, but disappears when it’s turned off. It’s not that simple, however: there is no problem the first time I’m proposed to remove an unnecessary import, even with haskell-doc-mode on [at least when I’ve done nothing else before].

@rainbyte
Copy link

Hi. We are experiencing this behavior with release 13.18, using Emacs 24.5.1 on Arch Linux.

Please let me know if I can provide you with any further information.

@gracjan
Copy link
Contributor

gracjan commented Jan 24, 2016

@geraldus: Can you try to find out what is going on here?

@geraldus
Copy link
Contributor

@gracjan there was some issues related to doc-mode in past if I'm not mistaken.

Apologize pals, I will be able to put my hands on this issue only in the middle of next week.

@geraldus
Copy link
Contributor

@gracjan ok, one small notice:

This is very surprising, at least the LANGUAGE pragma. We use precomputed list of available extensions, so there should be no interaction with ghc at this point.

we are talking not about language pragma being inserted manually, Emacs hangs when offers to insert language pragma automatically or when offers to remove redundant imports (I believe this happens when starting/loading/reloading interactive process). If I'm not mistaken I had same issue with doc-mode long ago. I'll share my further investigations here.

@geraldus
Copy link
Contributor

Ok, I was able to reproduce this:

  • turn on haskell-doc-mode
  • add some unused import, e.g. import Data.Char
  • load file in REPL haskell-process-load-file
  • when asked to remove redundant import answer y or c
  • Emacs hangs, triple C-g resumes normal functionality.

Answering n does not lead to hang.

@geraldus
Copy link
Contributor

Ok, folks, I guess I've found the crux of the matter:

  • Firstly, when you move point at the beginning of import statement haskell-doc-mode shows you a tip import [qualified] modid [as modid] [impspec](which helpfulness is quite questionable).
  • Secondly, the hang occurs when read-event is called and waiting for keyboard event while haskell-doc-mode produces output to mini-buffer.

To see that everything is works you can increase haskell-doc-idle-delay value, make some changes to force suggestions to take place during next reloading and reload file into REPL, e.g. (setq haskell-doc-idle-delay 30) (for some unknown reason this variable is not customizable), this will give you 30 seconds to press y and import will be removed without hang.

I see only one solution at this moment: turn-off haskell-doc-mode if it is enabled and re-enable it if necessary at the end of execution when haskell-process-load-complete (or even better haskell-process-trigger-suggestions) is running.

haskell-doc-mode looks nice and helpful, but sometimes it is very annoying because all other messages are effectively disappears from mini-buffer when it turned on (though because of this I've discovered presentation mode in past). Maybe it will be better to pop up haskell-doc tips rather than echo them to mini-buffer, but I'm afraid such popups will bring a lot conflicts with other useful packages. Also, I think we need to take a closer look at current doc-mode source, I see a lot of hardcoded stuff there, potentially there are some pieces we can improve, other may be outdated.

By the way, tab-based indentation in haskell-load.el makes code completely unreadable in my Emacs setup. Also, there are a lot of huge function which is hard to follow. This module should be refactored and simplified.

@gracjan
Copy link
Contributor

gracjan commented Jan 25, 2016

So haskell-process-load asks modal questions in minibuffer and minibuffer is overwritten?

Short term solution:

  1. haskell-doc-mode needs to suspend showing anything while a modal question is running, that is while haskell-process-trigger-suggestions is running.

Long term solution:

  1. haskell-process-load puts warning overlays in place of code where it can do fixes, fixes are triggered by a key combination.
  2. haskell-doc-mode uses tooltips to show information.

Overall modal questions are bad UI/UX unless caused directly by interactive function or its keybinding.

@geraldus
Copy link
Contributor

Agree, also I always miss the moment when REPL asks me to add/remove something and waiting till spot that question in mini-buffer.

haskell-doc-mode uses tooltips to show information

Do you mean mouse-over tooltips?

@gracjan can you create a well defined task for this? I could take care of this at the end of week if nobody will outrun me.

@gracjan
Copy link
Contributor

gracjan commented Jan 25, 2016 via email

@gracjan
Copy link
Contributor

gracjan commented Jan 27, 2016

Also see discussion in #754.

@geraldus
Copy link
Contributor

Should we just use this as temporal workaround?

(defun haskell-process-trigger-suggestions-ad (orig-fun &rest args)
  (turn-off-haskell-doc)
  (apply orig-fun args)
  (turn-on-haskell-doc))

(advice-add 'haskell-process-trigger-suggestions
   :around #'haskell-process-trigger-suggestions-ad)

I still didn't catch what you mean by "tooltip"?

@geraldus
Copy link
Contributor

Should be fixed now. Please reopen if still relevant.

@anakreontas
Copy link

Thank you.

@gracjan gracjan reopened this Feb 6, 2016
@gracjan
Copy link
Contributor

gracjan commented Feb 6, 2016

@geraldus, I've found much better way to fix this: http://emacs.stackexchange.com/a/20126/5213

Basically (not this-command) ensures that we are free to use minibuffer.

Can you please:

  • revert your changes (sorry about that)
  • use (not this-command) to safeguard output to minibuffer
  • use (not (minibufferp)) to prevent overwriting minibuffer while in minibuffer

Thanks.

@geraldus
Copy link
Contributor

geraldus commented Feb 7, 2016

@gracjan hmm, it's ok, but I could delay with this for some time, very short in time now ):

@gracjan
Copy link
Contributor

gracjan commented Feb 7, 2016

Or, do nothing about this one :) We will remove haskell-doc-mode soon enough :) Closing in fovor of #1138.

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

7 participants