1

In order to do specific actions on save in haskell-mode, this page recommends to rebind the C-x C-s keybinding to use haskell-mode-save-buffer instead of just the standard save-buffer command:

(define-key haskell-mode-map (kbd "C-x C-s") 'haskell-mode-save-buffer)

The intended behaviour is to be able to add haskell-mode specific hooks to the standard save command. So I've added it to my ~/.emacs file.

But when I use this keybinding in haskell-mode, this error occurs:

Symbol's function definition is void: haskell-mode-save-buffer

I also added this line to the .emacs file:

(add-hook 'haskell-mode-hook 'haskell-mode-save-buffer)

But it doesn't help. I guess it doesn't seem to do anything since haskell-mode'save-buffers definition is void, so I guess adding it to stuff won't help. I also tried to add the line

(define-key haskell-mode-map (kbd "C-x C-s") 'haskell-mode-save-buffer)

to the haskell-mode.el file itself (file in the installed directory (ELPA)), but I don't really know if that helped. I'm not at the point where I can debug that kind of stuff.

I tried to find if this function is defined in haskell-mode at all. Running M-x describe-variable "haskell-mode-" with TAB shows that it doesn't exist in this set of variables. EDIT: As pointed out in the comments, I should use describe-function to try to find this function. Running M-x describe-function "haskell-mode-" with TAB shows that haskell-mode-save-buffer is not to be found here. Interestingly, though, two functions which seem to hint at being able to provide the intended functionality is listed here:

haskell-mode-before-save-handler

[...]

haskell-mode-after-save-handler

Searching through the haskell-mode.el file for "haskell-mode-save-buffer" yields no results.

Is there something wrong on my end, with how I'm rebinding the key (it wasn't explicitly mentioned that I should add the line to .emacs, anyway, that was just an assumption on my part), or is this way of adding hooks to the save command not used in haskell-mode any longer?

Community
  • 1
  • 1
Guildenstern
  • 2,179
  • 1
  • 17
  • 39
  • Rather than `describe-variable`, use `describe-function` since you're looking for a function. Is it correct that you searched `haskell-mode.el` for `haskell-mode-save-buffer` and did not find it? – Dan Aug 04 '14 at 12:45
  • @Dan "Is it correct that you searched [...]" - Yes, that's right. I'll update my post regarding the `describe-function` command. – Guildenstern Aug 04 '14 at 12:57
  • Please do **not** follow instructions from the EmacsWiki unless you have verified that they are up to date and still apply to the Emacs version and packages that you are using. The page linked in your question was last updated in May 2012, and is absolutely out of date now. Rather, follow the [excellent Haskell Mode manual on Github](https://github.com/haskell/haskell-mode/wiki). –  Aug 04 '14 at 13:10
  • @lunaryorn you mean haskellwiki? – Guildenstern Aug 04 '14 at 13:13
  • Indeed, I meant to write Haskell Wiki, sorry. That goes for any wiki, though. You should always verify such content unless it's really official documentation from the maintainers of the corresponding software. –  Aug 04 '14 at 14:52
  • @lunaryorn Yeah that's good advice. Something I didn't mention in my post was that I tried my best to google the issue to see if it was mentioned some place else, either this particular problem or the issue of adding hooks to the save command in general. It wasn't though so I had to ask *somewhere*. :) – Guildenstern Aug 04 '14 at 17:24

1 Answers1

4

As of this change to haskell-mode, the function haskell-mode-save-buffer does not exist anymore, and the tasks it used to perform are automatically performed by save handlers set up for Haskell mode buffers. Thus, the advice to bind C-x C-s to haskell-mode-save-buffer is outdated.

legoscia
  • 39,593
  • 22
  • 116
  • 167