0

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 1

1

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.

2
  • 1
    Better use advice-add instead of defadvice. This allows to used functions defined like normal functions (defun) for advices, change them while applied as advices and to remove them.
    – theldoria
    Aug 27, 2016 at 20:34
  • I used advice-add. Though I did end up using the :override for the WHERE argument and rewrote the js--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.
    – lookyhooky
    Aug 28, 2016 at 3:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.