Emacs 24 jump to compilation errors #67

Closed
jabolopes opened this Issue Jun 23, 2012 · 6 comments

Comments

Projects
None yet
4 participants
@jabolopes

Hello,

I have been using haskell-mode with emacs 23.* for quite some time. Great work!
Recently, I have upgraded emacs to version 24.1.1 and compilation error jumps seem to have stopped working.

For example, you're working on a haskell file, you do C-c C-l to load that file, and compilation errors (if any) will appear in the compilation buffer.
In emacs 23.*, you could hit RET on those compilation errors to jump to the appropriate file location.
This does not seem to work anymore.

If you need any more information, please let me know!

Cheers,
José

@dop

This comment has been minimized.

Show comment Hide comment
@dop

dop Jul 21, 2012

Contributor

I don't know why but removing some elements in one of regexps of inferior-haskell-error-regexp-alist (inf-haskell.el) fixes hyperlinks. I've changed this

;; Format of error messages used by GHCi.
("^\\(.+?\\):\\([0-9]+\\):\\(\\([0-9]+\\):\\)?\\( \\|\n *\\)\\(Warning\\)?"
 1 2 4 ,@(if (fboundp 'compilation-fake-loc)
         '((6) nil (5 '(face nil font-lock-multiline t)))))

to this

("^\\(.+?\\):\\([0-9]+\\):\\(\\([0-9]+\\):\\)?\\( \\|\n *\\)\\(Warning\\)?"
 1 2 4 ,@(if (fboundp 'compilation-fake-loc)
         '((6) nil)))

Actually I've added hook, so that I don't have to change inf-haskell.el:

(add-hook 'inferior-haskell-mode-hook
      (lambda ()
        (setq compilation-first-column 1)
        (setq compilation-error-regexp-alist
          (cons `("^\\(.+?\\):\\([0-9]+\\):\\(\\([0-9]+\\):\\)?\\( \\|\n *\\)\\(Warning\\)?"
              1 2 4 ,@(if (fboundp 'compilation-fake-loc)
                      '((6) nil)))
            (cdr (cdr inferior-haskell-error-regexp-alist))))))

This removes first element which is regexp for Hugs errors.

Contributor

dop commented Jul 21, 2012

I don't know why but removing some elements in one of regexps of inferior-haskell-error-regexp-alist (inf-haskell.el) fixes hyperlinks. I've changed this

;; Format of error messages used by GHCi.
("^\\(.+?\\):\\([0-9]+\\):\\(\\([0-9]+\\):\\)?\\( \\|\n *\\)\\(Warning\\)?"
 1 2 4 ,@(if (fboundp 'compilation-fake-loc)
         '((6) nil (5 '(face nil font-lock-multiline t)))))

to this

("^\\(.+?\\):\\([0-9]+\\):\\(\\([0-9]+\\):\\)?\\( \\|\n *\\)\\(Warning\\)?"
 1 2 4 ,@(if (fboundp 'compilation-fake-loc)
         '((6) nil)))

Actually I've added hook, so that I don't have to change inf-haskell.el:

(add-hook 'inferior-haskell-mode-hook
      (lambda ()
        (setq compilation-first-column 1)
        (setq compilation-error-regexp-alist
          (cons `("^\\(.+?\\):\\([0-9]+\\):\\(\\([0-9]+\\):\\)?\\( \\|\n *\\)\\(Warning\\)?"
              1 2 4 ,@(if (fboundp 'compilation-fake-loc)
                      '((6) nil)))
            (cdr (cdr inferior-haskell-error-regexp-alist))))))

This removes first element which is regexp for Hugs errors.

@jabolopes

This comment has been minimized.

Show comment Hide comment
@jabolopes

jabolopes Aug 1, 2012

Thanks dop, that seem to have worked!

Thanks dop, that seem to have worked!

@manzyuk

This comment has been minimized.

Show comment Hide comment
@manzyuk

manzyuk Aug 4, 2012

Unlike Emacs 23, in which fontification of compilation error is handled by font-lock.el, in Emacs 24, it is performed by compile.el itself, in a rather ad hoc fashion. In particular, it doesn't handle the faces specified by property lists of the form (face FACE PROP1 VAL1 PROP2 VAL2 ...). I fixed this by patching compile.el.

However, even with proper fontification, visiting error messages and source code locations with C-x `` is inconsistent. For example, if I first start an inferior Haskell process withM-x run-haskelland then load my file into it by pressingC-c C-lfrom the file's buffer, pressingC-x brings me to the location of the first error (if there are any). However, if no Haskell process is running and I press `C-c C-l`, then even if there are any compilation errors, pressing `C-x merely displays a message "No more errors yet". Also, error navigation stops working once the file is reloaded from the inferior Haskell buffer by entering :r. Loading the file with C-c C-l fixes the problem, but it is still annoying.

I suspect that the problem is again in the new compile.el, so maybe it's better to report it to the bug-gnu-emacs list.

manzyuk commented Aug 4, 2012

Unlike Emacs 23, in which fontification of compilation error is handled by font-lock.el, in Emacs 24, it is performed by compile.el itself, in a rather ad hoc fashion. In particular, it doesn't handle the faces specified by property lists of the form (face FACE PROP1 VAL1 PROP2 VAL2 ...). I fixed this by patching compile.el.

However, even with proper fontification, visiting error messages and source code locations with C-x `` is inconsistent. For example, if I first start an inferior Haskell process withM-x run-haskelland then load my file into it by pressingC-c C-lfrom the file's buffer, pressingC-x brings me to the location of the first error (if there are any). However, if no Haskell process is running and I press `C-c C-l`, then even if there are any compilation errors, pressing `C-x merely displays a message "No more errors yet". Also, error navigation stops working once the file is reloaded from the inferior Haskell buffer by entering :r. Loading the file with C-c C-l fixes the problem, but it is still annoying.

I suspect that the problem is again in the new compile.el, so maybe it's better to report it to the bug-gnu-emacs list.

@jabolopes

This comment has been minimized.

Show comment Hide comment
@jabolopes

jabolopes Aug 7, 2012

I am not sure if manzyuk fixed this problem but when jumping to an error it does not always jump to the appropriate line.
SOMETIMES it jumps a few lines ahead.

I am not sure if manzyuk fixed this problem but when jumping to an error it does not always jump to the appropriate line.
SOMETIMES it jumps a few lines ahead.

@manzyuk

This comment has been minimized.

Show comment Hide comment
@manzyuk

manzyuk Aug 17, 2012

@manzyuk

This comment has been minimized.

Show comment Hide comment
@manzyuk

manzyuk Aug 17, 2012

It turns out that the inconsistent error navigation I'm talking about above is not particular to Emacs 24, it is also present in Emacs 23. In fact, jumping to errors seems to work only when the file is loaded into the inferior Haskell process with C-c C-l. I've tried to debug this problem and have chased it down to the function compilation-forget-errors, which resets the variables compilation-current-error and compilation-messages-start. This function is called from the function inferior-haskell-load-file bound to C-c C-l. To confirm my guess, evaluating M-: (compilation-forget-errors) before manually loading or reloading a file with :l resp. :r helps.

manzyuk commented Aug 17, 2012

It turns out that the inconsistent error navigation I'm talking about above is not particular to Emacs 24, it is also present in Emacs 23. In fact, jumping to errors seems to work only when the file is loaded into the inferior Haskell process with C-c C-l. I've tried to debug this problem and have chased it down to the function compilation-forget-errors, which resets the variables compilation-current-error and compilation-messages-start. This function is called from the function inferior-haskell-load-file bound to C-c C-l. To confirm my guess, evaluating M-: (compilation-forget-errors) before manually loading or reloading a file with :l resp. :r helps.

@chrisdone chrisdone closed this May 19, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment