Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix ruby

  • Loading branch information...
commit 0510a4725a50f49c57da39365fcfb7e5041ad8d9 1 parent eeca4fc
@dz authored
View
2  emacsd/configs/modeline.el
@@ -34,8 +34,6 @@
(:propertize mode-name
face mode-line-mode-face)
"%] "
- (:eval (propertize (format-mode-line minor-mode-alist)
- 'face 'mode-line-minor-mode-face))
(:propertize mode-line-process
face mode-line-process-face)
(global-mode-string global-mode-string)
View
52 emacsd/configs/ruby.el
@@ -5,10 +5,62 @@
'(progn
;; work around possible elpa bug
(ignore-errors (require 'ruby-compilation))
+ (setq ruby-deep-indent-paren nil)
(setq ruby-use-encoding-map nil)
(add-hook 'ruby-mode-hook 'inf-ruby-keys)
(define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)))
+;; This allows indentation like:
+;; object.method(
+;; arg1
+;; )
+;; when ruby-deep-indent-paren is nil
+(defadvice ruby-indent-line (after unindent-closing-paren activate)
+ (if (eq ruby-deep-indent-paren nil)
+ (let ((column (current-column))
+ indent offset)
+ (save-excursion
+ (back-to-indentation)
+ (let ((state (syntax-ppss)))
+ (setq offset (- column (current-column)))
+ (when (and (eq (char-after) ?\))
+ (not (zerop (car state))))
+ (goto-char (cadr state))
+ (setq indent (current-indentation)))))
+ (when indent
+ (indent-line-to indent)
+ (when (> offset 0) (forward-char offset))))))
+
+;; This allows indentation without parenthesis
+;; object.method arg1,
+;; arg2
+;; when ruby-deep-indent-paren is nil
+;; object.method arg1,
+;; arg2
+(defadvice ruby-indent-line (after line-up-args activate)
+ (let (indent prev-indent arg-indent)
+ (save-excursion
+ (back-to-indentation)
+ (when (zerop (car (syntax-ppss)))
+ (setq indent (current-column))
+ (skip-chars-backward " \t\n")
+ (when (eq ?, (char-before))
+ (ruby-backward-sexp)
+ (back-to-indentation)
+ (setq prev-indent (current-column))
+ (skip-syntax-forward "w_.")
+ (skip-chars-forward " ")
+ (setq arg-indent (current-column)))))
+ (when prev-indent
+ (let ((offset (- (current-column) indent)))
+ (cond ((< indent prev-indent)
+ (indent-line-to prev-indent))
+ ((= indent prev-indent)
+ (if (eq ruby-deep-indent-paren nil)
+ (indent-line-to (+ prev-indent 2))
+ (indent-line-to arg-indent))))
+ (when (> offset 0) (forward-char offset))))))
+
;; rinari
(add-to-list 'load-path "~/.emacs.d/vendor/rinari")
(add-to-list 'load-path "~/.emacs.d/vendor/rinari/util")
View
2  emacsd/init.el
@@ -34,7 +34,7 @@
"mac" ;; mac specific key bindings and ui changes
"modeline"
"project" ;; project definitions
- "vim" ;; vim keybindings yo
+ ;;"vim" ;; vim keybindings yo
;; languages
"python"
"javascript"
Please sign in to comment.
Something went wrong with that request. Please try again.