Function: ruby--electric-indent-p

ruby--electric-indent-p is a byte-compiled function defined in ruby-mode.el.gz.

Signature

(ruby--electric-indent-p CHAR)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/ruby-mode.el.gz
(defun ruby--electric-indent-p (char)
  (cond
   ((memq char ruby--electric-indent-chars)
    ;; Reindent after typing a char affecting indentation.
    (ruby--at-indentation-p (1- (point))))
   ((memq (char-after) ruby--electric-indent-chars)
    ;; Reindent after inserting something in front of the above.
    (ruby--at-indentation-p (1- (point))))
   ((or (and (>= char ?a) (<= char ?z)) (memq char '(?_ ?? ?! ?:)))
    (let ((pt (point)))
      (save-excursion
        (skip-chars-backward "[:alpha:]:_?!")
        (and (ruby--at-indentation-p)
             (looking-at (regexp-opt (cons "end" ruby-block-mid-keywords)))
             ;; Outdent after typing a keyword.
             (or (eq (match-end 0) pt)
                 ;; Reindent if it wasn't a keyword after all.
                 (eq (match-end 0) (1- pt)))))))))