Function: ruby-backward-sexp

ruby-backward-sexp is an interactive and byte-compiled function defined in ruby-mode.el.gz.

This command is obsolete since 28.1; use backward-sexp instead.

Signature

(ruby-backward-sexp &optional ARG)

Documentation

Move backward across one balanced expression (sexp).

With ARG, do it many times. Negative ARG means move forward.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/ruby-mode.el.gz
(defun ruby-backward-sexp (&optional arg)
  "Move backward across one balanced expression (sexp).
With ARG, do it many times.  Negative ARG means move forward."
  (declare (obsolete backward-sexp "28.1"))
  ;; TODO: Document body
  (interactive "p")
  (cond
   (ruby-use-smie (backward-sexp arg))
   ((and (numberp arg) (< arg 0))
    (with-suppressed-warnings ((obsolete ruby-forward-sexp))
      (ruby-forward-sexp (- arg))))
   (t
    (let ((i (or arg 1)))
      (condition-case nil
          (while (> i 0)
            (skip-chars-backward "- \t\n,.:;|&^~=!?+*")
            (forward-char -1)
            (cond ((looking-at "\\s)")
                   (goto-char (scan-sexps (1+ (point)) -1))
                   (pcase (char-before)
                     (?% (forward-char -1))
                     ((or ?q ?Q ?w ?W ?r ?x)
                      (if (eq (char-before (1- (point))) ?%)
                          (forward-char -2))))
                   nil)
                  ((looking-at "\\s\"\\|\\\\\\S_")
                   (let ((c (char-to-string (char-before (match-end 0)))))
                     (while (and (search-backward c)
				 (oddp (skip-chars-backward "\\\\")))))
                   nil)
                  ((looking-at "\\s.\\|\\s\\")
                   (if (ruby-special-char-p) (forward-char -1)))
                  ((looking-at "\\s(") nil)
                  (t
                   (forward-char 1)
                   (while (progn (forward-word-strictly -1)
                                 (pcase (char-before)
                                   (?_ t)
                                   (?. (forward-char -1) t)
                                   ((or ?$ ?@)
                                    (forward-char -1)
                                    (and (eq (char-before) (char-after))
                                         (forward-char -1)))
                                   (?:
                                    (forward-char -1)
                                    (eq (char-before) :)))))
                   (if (looking-at ruby-block-end-re)
                       (ruby-beginning-of-block))
                   nil))
            (setq i (1- i)))
        ((error)))
      i))))