Skip to content

Conversation

@zaz
Copy link
Contributor

@zaz zaz commented Feb 2, 2025

Previously, it would run (goto-char (point-max)) (insert "\n") in whatever buffer you are currently in.

This was causing issues for some people.

Previously, it would run `(goto-char (point-max)) (insert "\n")` in
whatever buffer you are currently in.
@zaz zaz changed the title # ensure run-expr uses *haskell* buffer ensure run-expr uses *haskell* buffer Feb 2, 2025
Alternatively, C-c C-m can be used.
@purcell
Copy link
Member

purcell commented Feb 4, 2025

Thanks, I cherry-picked and applied the main commit, but will skip the other one. Cheers!

@purcell purcell closed this Feb 4, 2025
@zaz
Copy link
Contributor Author

zaz commented Feb 4, 2025

@purcell Thank you! Do you have time to explain why? Was there something wrong with the code?

As you can see from StackOverflow, this feature is desired. Is there a better way to achieve this goal?

@purcell
Copy link
Member

purcell commented Feb 5, 2025

Do you have time to explain why? Was there something wrong with the code?

Primarily, I wanted to avoid conflating unrelated changes in one PR.

But my reservation is that main is only an obvious entry point in certain files, while in others it might be test. main might also expect command line args. So I don't think this is enough to be very widely useful, though I can imagine it might be a handy shortcut for some people, who could define such a command locally.

@zaz
Copy link
Contributor Author

zaz commented Feb 5, 2025

@purcell Thanks for explaining! Would you accept a PR for a function that prompts the user for which function to run and command line args and then remembers that for future invocations?

Or is there a better way to achieve the same thing? How are most people running their Haskell files from within Emacs?

@purcell
Copy link
Member

purcell commented Feb 5, 2025

Yeah, that could make sense. Maybe just add a function name to the signature of your haskell-load-and-run command:

You can do something like this to remember the last select expr, so that an extra RET will let you quickly re-run the last expression sent:

(defvar haskell-load-and-run-expr-history nil
  "History of expressions used in `haskell-load-and-run'.")

(defun haskell-load-and-run (expr)
  "Load the current buffer and run EXPR, e.g. \"main\"."
  (interactive (list (read-string "Run expression: "
                                  (car haskell-load-and-run-expr-history)
                                  'haskell-load-and-run-expr-history)))
  (haskell-process-load-file)
  (haskell-interactive-mode-run-expr expr))

Perhaps give that a test-drive and see how it is for you in practice?

@purcell
Copy link
Member

purcell commented Feb 5, 2025

(Edited the above on Github to fix typos, just in case you're relying on email)

@zaz zaz mentioned this pull request Feb 8, 2025
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

Successfully merging this pull request may close these issues.

2 participants