Ticket #95 (new feature request: None)

Opened 10 years ago

Last modified 3 years ago

GHCi :edit command should jump to the the last error

Reported by: martijnislief Owned by:
Priority: normal Milestone: _|_
Component: GHCi Version: None
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Easy (less than 1 hour)
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by simonmar) (diff)

GHCi has a :edit command for editing the current source file. Hugs's command of the same name automatically jumps the editor to the location of the last error; it would be nice if GHCi's did the same.

Attachments

le.ghci Download (1.3 KB) - added by claus 5 years ago.
example .ghci script implementing :le (load/reload and edit)

Change History

Changed 6 years ago by simonmar

  • difficulty set to Easy (1 hr)
  • os set to Unknown
  • architecture set to Unknown
  • description modified (diff)

I implemented :edit, but without the line-number-jumping facility for now.

Changed 6 years ago by igloo

  • component changed from None to GHCi
  • milestone set to 6.6.1

Changed 6 years ago by simonmar

  • priority changed from normal to low

Changed 5 years ago by igloo

  • priority changed from low to normal
  • milestone changed from 6.6.1 to 6.6.2

Punting on this.

The only problem with fixing it is that we've forgotten where the first error was by the time :e is given; shouldn't be too hard to fix, though, by updating a mutable variable when appropriate.

Changed 5 years ago by simonmar

  • milestone changed from 6.6.2 to 6.8

Changed 5 years ago by claus

starting somewhere in 6.7, you can define something like that yourself. the trick is to have a :redirErr command that allows you to capture ghci command error output. then you do a :l or :r, capture the errors, and use :e to edit the first one.

a slight complication is that :l/:r invalidate all variable bindings, so we need to define a temporary :afterCmd, in order to restore stderr and to read the errors after the :l/:r.

please note that many editors support quick compile/edit cycles (in vim, try :help quickfix; emacs should also support something similar), which will do this kind of thing more easily in most cases.

add the attached le.ghci to your .ghci, or source it with :cmd readFile "le.ghci". then, :le <mod> will :load and :edit, and :le on its own will :reload and :edit. adapt the code to your needs.

there is a patch pending for ghc head that will allow us to avoid having to compress ghci definitions into single lines, which will make things like this a lot more readable and maintainable..

Changed 5 years ago by claus

example .ghci script implementing :le (load/reload and edit)

Changed 5 years ago by guest

actually, it turns out you can define all this even back in 6.4.1 (had i only known back then!-). you need to define your own :e command (:def is available), and ghci 6.4.1 is somewhat annoying about command names that are prefixes of each other. have a look at

 http://www.cs.kent.ac.uk/people/staff/cr3/toolbox/haskell/dot-squashed.ghci641

 http://www.cs.kent.ac.uk/people/staff/cr3/toolbox/haskell/dot-squashed.ghci

since .ghci files are not very readable with definitions squashed into single lines, you might want to check the explanations of the latter file in

 http://www.haskell.org/pipermail/haskell-cafe/2007-September/032260.html

(note: the names in the 6.4.1 version differ from those in the described version)

i'm not yet sure whether being able to define :e means that it shouldn't be part of ghci at all (and this ticket be closed), or whether there are still any advantages to having it built in? perhaps ghci releases should have a selection of .ghci files with useful definitions?

Changed 5 years ago by simonmar

  • owner nobody deleted
  • status changed from assigned to new

Changed 4 years ago by igloo

  • milestone changed from 6.8 branch to 6.10 branch

Changed 4 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 4 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 3 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

Changed 3 years ago by simonmar

  • difficulty changed from Easy (1 hr) to Easy (less than 1 hour)

Changed 3 years ago by simonmar

  • failure set to None/Unknown
  • summary changed from GHCi editor binding with ":e" to GHCi :edit command should jump to the the last error
  • description modified (diff)
  • milestone changed from 6.12 branch to _|_

You can define it yourself, but it's a bit hacky and it would clearly be better to have it built-in. This is also a small self-contained task (limited to the GHCi front end) that a new contributor could take on.

Note: See TracTickets for help on using tickets.