+2013-12-19 Dmitry Gutov <dgutov@yandex.ru>
+
+ * progmodes/ruby-mode.el (ruby-smie--args-separator-p): Allow the
+ first arg to be a string (fixed dead code), or an operator symbol.
+ (ruby-smie--forward-token): Tokenize ` @ ' before strings and
+ operator symbols.
+ (ruby-smie-rules): Remove parent token check in the `.' clause, it
+ did nothing. Don't respond to `(:after ".")', it will be called
+ with :before anyway. Remove the ` @ ' rule, it didn't seem to
+ change anything. Only return indentation for binary operators
+ when they are hanging. De-dent opening paren when its parent is
+ `.', otherwise it looks bad when the dot is not at bol or eol
+ (bug#16182).
+
2013-12-19 Juri Linkov <juri@jurta.org>
* replace.el (query-replace-read-args): Split a non-negative arg
(not (looking-at (regexp-opt '("unless" "if" "while" "until" "or"
"else" "elsif" "do" "end" "and")
'symbols))))
- (memq (syntax-after pos) '(7 15))
- (looking-at "[([]\\|[-+!~:]\\sw")))))
+ (memq (car (syntax-after pos)) '(7 15))
+ (looking-at "[([]\\|[-+!~]\\sw\\|:\\(?:\\sw\\|\\s.\\)")))))
(defun ruby-smie--at-dot-call ()
(and (eq ?w (char-syntax (following-char)))
(let ((pos (point)))
(skip-chars-forward " \t")
(cond
- ((looking-at "\\s\"") ;A heredoc or a string.
- (if (not (looking-at "\n"))
- ""
- ;; Tokenize the whole heredoc as semicolon.
- (goto-char (scan-sexps (point) 1))
- ";"))
+ ((and (looking-at "\n") (looking-at "\\s\"")) ;A heredoc.
+ ;; Tokenize the whole heredoc as semicolon.
+ (goto-char (scan-sexps (point) 1))
+ ";")
((and (looking-at "[\n#]")
(ruby-smie--implicit-semi-p)) ;Only add implicit ; when needed.
(if (eolp) (forward-char 1) (forward-comment 1))
(t
(forward-comment (point-max))
(cond
- ((looking-at ":\\s.+")
- (goto-char (match-end 0)) (match-string 0)) ;; bug#15208.
((and (< pos (point))
(save-excursion
(ruby-smie--args-separator-p (prog1 (point) (goto-char pos)))))
" @ ")
+ ((looking-at ":\\s.+")
+ (goto-char (match-end 0)) (match-string 0)) ;bug#15208.
+ ((looking-at "\\s\"") "") ;A string.
(t
(let ((dot (ruby-smie--at-dot-call))
(tok (smie-default-forward-token)))
(ruby-smie--indent-to-stmt))
((smie-rule-hanging-p)
;; Treat purely syntactic block-constructs as being part of their parent,
- ;; when the opening token is hanging and the parent is not an open-paren.
- (let ((state (smie-backward-sexp 'halfsexp)))
- (unless (and (eq t (car state))
- (not (eq (cadr state) (point-min))))
- (cons 'column (smie-indent-virtual)))))))
+ ;; when the opening token is hanging and the parent is not an
+ ;; open-paren.
+ (cond
+ ((eq (car (smie-indent--parent)) t) nil)
+ ;; When after `.', let's always de-indent,
+ ;; because when `.' is inside the line, the
+ ;; additional indentation from it looks out of place.
+ ((smie-rule-parent-p ".") (smie-rule-parent (- ruby-indent-level)))
+ (t (smie-rule-parent))))))
(`(:after . ,(or `"(" "[" "{"))
;; FIXME: Shouldn't this be the default behavior of
;; `smie-indent-after-keyword'?
;; because we want to reject hanging tokens at bol, too.
(unless (or (eolp) (forward-comment 1))
(cons 'column (current-column)))))
- (`(:after . " @ ") (smie-rule-parent))
(`(:before . "do") (ruby-smie--indent-to-stmt))
- (`(,(or :before :after) . ".")
- (unless (smie-rule-parent-p ".")
- (smie-rule-parent ruby-indent-level)))
+ (`(:before . ".") ruby-indent-level)
(`(:before . ,(or `"else" `"then" `"elsif" `"rescue" `"ensure")) 0)
(`(:before . ,(or `"when"))
(if (not (smie-rule-sibling-p)) 0)) ;; ruby-indent-level
"<=>" ">" "<" ">=" "<=" "==" "===" "!=" "<<" ">>"
"+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "|"
"<<=" ">>=" "&&=" "||=" "and" "or"))
- (if (smie-rule-parent-p ";" nil) ruby-indent-level))
+ (and (smie-rule-parent-p ";" nil)
+ (smie-indent--hanging-p)
+ ruby-indent-level))
(`(:after . ,(or "?" ":")) ruby-indent-level)
(`(:before . "begin")
(unless (save-excursion (skip-chars-backward " \t") (bolp))