emacsemacs24haskell-mode

Can't rebind C-x C-s to use haskell-mode specific function since its definition is void


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?


Solution

  • 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.