(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)) (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)) (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)) (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) )) (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) )) (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) )) But if you care (Emacs 26.3Emacs 26.3), for PythonPython:
For Ruby I tried to monkey-patch the Ruby mode, but it by default it uses smie-indent-line. Which in its turn might be used not only by the Ruby mode. And I don'tdidn'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:
But if you care (Emacs 26.3), for Python:
For Ruby I tried to monkey-patch the Ruby mode, but it by default uses smie-indent-line. Which in its turn might be used not only by the Ruby mode. And I don'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:
But if you care (Emacs 26.3), for Python:
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: