Skip to main content
6 of 6
fixed ruby issue
x-yuri
  • 291
  • 1
  • 8

You might want to stick to the defaults, since:

r = my_long_function_name( param1, param2) 

is arguably preferable over:

r = my_long_function_name(param1, param2) 

But if you care (Emacs 26.3), for Python:

(eval-after-load "python" (lambda () (fset 'old-python-indent--calculate-indentation (symbol-function 'python-indent--calculate-indentation)) (defun python-indent--calculate-indentation () (save-excursion (pcase (python-indent-context) (`(,:inside-paren . ,start) (goto-char start) (+ (current-indentation) python-indent-offset)) (_ (old-python-indent--calculate-indentation))))) ;; Alternatively, use advice-add ;; (defun my/python-indent--calculate-indentation (orig-fun &rest args) ;; ... ;; (apply orig-fun args)) ;; (advice-add 'python-indent--calculate-indentation :around #'my/python-indent--calculate-indentation) )) 

For Javascript:

(setq js-indent-align-list-continuation nil) 

For Ruby I tried to monkey-patch the Ruby mode, but by default it uses smie-indent-line. Which in its turn might be used not only by the Ruby mode. And I didn't see a better way than to copy the smie-indent-keyword and fix a thing or two. But I'm far from understanding how it works, so I decided to go with the Enhanced Ruby Mode. After installation, you need to add:

(require 'ruby-mode) ;; https://emacs.stackexchange.com/questions/59782/autoloaded-variable-overrides-the-one-from-the-init-file#comment93779_59782 (setq auto-mode-alist (mapcar (lambda (x) (if (eq (cdr x) 'ruby-mode) (cons (car x) 'enh-ruby-mode) x)) auto-mode-alist)) (setq interpreter-mode-alist (mapcar (lambda (x) (if (eq (cdr x) 'ruby-mode) (cons (car x) 'enh-ruby-mode) x)) interpreter-mode-alist)) 

Then to fix the indentation:

(setq enh-ruby-deep-indent-paren nil) 
x-yuri
  • 291
  • 1
  • 8