I am using js-mode in emacs 25.1. There are some indentation rules that are not editable through the provided customization variables. The specific one I have issue with is the indentation of arrow functions, they are not indented like regular anonymous functions. After looking at the function js--proper-indentation, the only way to edit it is to redefine the function. Should I redefine it in my js-mode-hook?
1 Answer
You will probably want to use defadvice
to provide a wrapper around js--proper-indentation
, rather than cometely redefining it. This will allow you to handle the indentation for arrow functions yourself, while calling through to the original function to handle everything else.
-
1Better use
advice-add
instead ofdefadvice
. This allows to used functions defined like normal functions (defun
) for advices, change them while applied as advices and to remove them. Aug 27, 2016 at 20:34 -
I used
advice-add
. Though I did end up using the:override
for the WHERE argument and rewrote thejs--proper-indentation
function. Originally I tried use:before-until
, but there where so many conditions to handle before I could event try to check for the arrow functions, it was easiest to use the real function as a template and make my adjustments. Aug 28, 2016 at 3:39