ruby-mode.el: fix argument indent
* misc/ruby-mode.el (ruby-block-end-re, ruby-delimiter) (ruby-mode-syntax-table, ruby-parse-partial, ruby-beginning-of-indent): merge from Emacs. * misc/ruby-mode.el (ruby-calculate-indent): fix indentation of argument lines in parentheses. [Bug #5140] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
488fb86a1e
commit
983c2e874f
@ -1,3 +1,12 @@
|
|||||||
|
Mon Dec 3 12:43:35 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* misc/ruby-mode.el (ruby-block-end-re, ruby-delimiter)
|
||||||
|
(ruby-mode-syntax-table, ruby-parse-partial, ruby-beginning-of-indent):
|
||||||
|
merge from Emacs.
|
||||||
|
|
||||||
|
* misc/ruby-mode.el (ruby-calculate-indent): fix indentation of
|
||||||
|
argument lines in parentheses. [Bug #5140]
|
||||||
|
|
||||||
Mon Dec 3 07:52:41 2012 Eric Hodel <drbrain@segment7.net>
|
Mon Dec 3 07:52:41 2012 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
* lib/rdoc/parser.rb: Improved modeline support. Patch by nobu.
|
* lib/rdoc/parser.rb: Improved modeline support. Patch by nobu.
|
||||||
|
@ -104,7 +104,7 @@
|
|||||||
(regexp-opt (append ruby-modifier-beg-keywords ruby-block-op-keywords))
|
(regexp-opt (append ruby-modifier-beg-keywords ruby-block-op-keywords))
|
||||||
"Regexp to match hanging block modifiers.")
|
"Regexp to match hanging block modifiers.")
|
||||||
|
|
||||||
(defconst ruby-block-end-re "\\<end\\>")
|
(defconst ruby-block-end-re "\\_<end\\_>")
|
||||||
|
|
||||||
(defconst ruby-here-doc-beg-re
|
(defconst ruby-here-doc-beg-re
|
||||||
"\\(<\\)<\\(-\\)?\\(\\([a-zA-Z0-9_]+\\)\\|[\"]\\([^\"]+\\)[\"]\\|[']\\([^']+\\)[']\\)")
|
"\\(<\\)<\\(-\\)?\\(\\([a-zA-Z0-9_]+\\)\\|[\"]\\([^\"]+\\)[\"]\\|[']\\([^']+\\)[']\\)")
|
||||||
@ -132,9 +132,9 @@
|
|||||||
(concat "-?\\([\"']\\|\\)" contents "\\1"))))))
|
(concat "-?\\([\"']\\|\\)" contents "\\1"))))))
|
||||||
|
|
||||||
(defconst ruby-delimiter
|
(defconst ruby-delimiter
|
||||||
(concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\<\\("
|
(concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\_<\\("
|
||||||
ruby-block-beg-re
|
ruby-block-beg-re
|
||||||
"\\)\\>\\|" ruby-block-end-re
|
"\\)\\_>\\|" ruby-block-end-re
|
||||||
"\\|^=begin\\|" ruby-here-doc-beg-re)
|
"\\|^=begin\\|" ruby-here-doc-beg-re)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -190,6 +190,7 @@
|
|||||||
(modify-syntax-entry ?$ "." ruby-mode-syntax-table)
|
(modify-syntax-entry ?$ "." ruby-mode-syntax-table)
|
||||||
(modify-syntax-entry ?? "_" ruby-mode-syntax-table)
|
(modify-syntax-entry ?? "_" ruby-mode-syntax-table)
|
||||||
(modify-syntax-entry ?_ "_" ruby-mode-syntax-table)
|
(modify-syntax-entry ?_ "_" ruby-mode-syntax-table)
|
||||||
|
(modify-syntax-entry ?: "_" ruby-mode-syntax-table)
|
||||||
(modify-syntax-entry ?< "." ruby-mode-syntax-table)
|
(modify-syntax-entry ?< "." ruby-mode-syntax-table)
|
||||||
(modify-syntax-entry ?> "." ruby-mode-syntax-table)
|
(modify-syntax-entry ?> "." ruby-mode-syntax-table)
|
||||||
(modify-syntax-entry ?& "." ruby-mode-syntax-table)
|
(modify-syntax-entry ?& "." ruby-mode-syntax-table)
|
||||||
@ -601,7 +602,7 @@ Also ignores spaces after parenthesis when 'space."
|
|||||||
(setq nest (cons (cons nil pnt) nest))
|
(setq nest (cons (cons nil pnt) nest))
|
||||||
(setq depth (1+ depth))))
|
(setq depth (1+ depth))))
|
||||||
(goto-char (match-end 0)))
|
(goto-char (match-end 0)))
|
||||||
((looking-at (concat "\\<\\(" ruby-block-beg-re "\\)\\>"))
|
((looking-at (concat "\\_<\\(" ruby-block-beg-re "\\)\\_>"))
|
||||||
(and
|
(and
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(or (not (looking-at (concat "do" ruby-keyword-end-re)))
|
(or (not (looking-at (concat "do" ruby-keyword-end-re)))
|
||||||
@ -731,6 +732,9 @@ Also ignores spaces after parenthesis when 'space."
|
|||||||
(cond ((and (eq deep t) (eq (car (nth 1 state)) paren))
|
(cond ((and (eq deep t) (eq (car (nth 1 state)) paren))
|
||||||
(skip-syntax-backward " ")
|
(skip-syntax-backward " ")
|
||||||
(setq indent (1- (current-column))))
|
(setq indent (1- (current-column))))
|
||||||
|
((eq deep 'space)
|
||||||
|
(goto-char (cdr (nth 1 state)))
|
||||||
|
(setq indent (1+ (current-column))))
|
||||||
((let ((s (ruby-parse-region (point) ruby-indent-point)))
|
((let ((s (ruby-parse-region (point) ruby-indent-point)))
|
||||||
(and (nth 2 s) (> (nth 2 s) 0)
|
(and (nth 2 s) (> (nth 2 s) 0)
|
||||||
(or (goto-char (cdr (nth 1 s))) t)))
|
(or (goto-char (cdr (nth 1 s))) t)))
|
||||||
@ -890,12 +894,12 @@ Also ignores spaces after parenthesis when 'space."
|
|||||||
With argument, do this that many times.
|
With argument, do this that many times.
|
||||||
Returns t unless search stops due to end of buffer."
|
Returns t unless search stops due to end of buffer."
|
||||||
(interactive "p")
|
(interactive "p")
|
||||||
(and (re-search-backward (concat "^\\(" ruby-block-beg-re "\\)\\b")
|
(and (re-search-backward (concat "^\\(" ruby-block-beg-re "\\)\\_>")
|
||||||
nil 'move (or arg 1))
|
nil 'move (or arg 1))
|
||||||
(progn (beginning-of-line) t)))
|
(progn (beginning-of-line) t)))
|
||||||
|
|
||||||
(defun ruby-beginning-of-indent ()
|
(defun ruby-beginning-of-indent ()
|
||||||
(and (re-search-backward (concat "^\\(" ruby-indent-beg-re "\\)\\b")
|
(and (re-search-backward (concat "^\\(" ruby-indent-beg-re "\\)\\_>")
|
||||||
nil 'move)
|
nil 'move)
|
||||||
(progn
|
(progn
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
@ -1373,7 +1377,7 @@ buffer position `limit' or the end of the buffer."
|
|||||||
1 font-lock-function-name-face)
|
1 font-lock-function-name-face)
|
||||||
;; keywords
|
;; keywords
|
||||||
(cons (concat
|
(cons (concat
|
||||||
"\\(^\\|[^_:.@$]\\|\\.\\.\\)\\b\\(defined\\?\\|"
|
"\\(^\\|[^_:.@$]\\|\\.\\.\\)\\_<\\(defined\\?\\|"
|
||||||
(regexp-opt
|
(regexp-opt
|
||||||
'("alias"
|
'("alias"
|
||||||
"and"
|
"and"
|
||||||
@ -1418,7 +1422,7 @@ buffer position `limit' or the end of the buffer."
|
|||||||
;; here-doc beginnings
|
;; here-doc beginnings
|
||||||
(list ruby-here-doc-beg-re 0 'font-lock-string-face)
|
(list ruby-here-doc-beg-re 0 'font-lock-string-face)
|
||||||
;; variables
|
;; variables
|
||||||
'("\\(^\\|[^_:.@$]\\|\\.\\.\\)\\b\\(nil\\|self\\|true\\|false\\)\\>"
|
'("\\(^\\|[^_:.@$]\\|\\.\\.\\)\\_<\\(nil\\|self\\|true\\|false\\)\\>"
|
||||||
2 font-lock-variable-name-face)
|
2 font-lock-variable-name-face)
|
||||||
;; variables
|
;; variables
|
||||||
'("\\(\\$\\([^a-zA-Z0-9 \n]\\|[0-9]\\)\\)\\W"
|
'("\\(\\$\\([^a-zA-Z0-9 \n]\\|[0-9]\\)\\)\\W"
|
||||||
@ -1434,7 +1438,7 @@ buffer position `limit' or the end of the buffer."
|
|||||||
'("\\(^\\|[[ \t\n<+(,=]\\)\\(%[xrqQwW]?\\([^<[{(a-zA-Z0-9 \n]\\)[^\n\\\\]*\\(\\\\.[^\n\\\\]*\\)*\\(\\3\\)\\)"
|
'("\\(^\\|[[ \t\n<+(,=]\\)\\(%[xrqQwW]?\\([^<[{(a-zA-Z0-9 \n]\\)[^\n\\\\]*\\(\\\\.[^\n\\\\]*\\)*\\(\\3\\)\\)"
|
||||||
(2 font-lock-string-face))
|
(2 font-lock-string-face))
|
||||||
;; constants
|
;; constants
|
||||||
'("\\(^\\|[^_]\\)\\b\\([A-Z]+\\(\\w\\|_\\)*\\)"
|
'("\\(^\\|[^_]\\)\\_<\\([A-Z]+\\(\\w\\|_\\)*\\)"
|
||||||
2 font-lock-type-face)
|
2 font-lock-type-face)
|
||||||
;; symbols
|
;; symbols
|
||||||
'("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
|
'("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
|
||||||
|
@ -165,5 +165,17 @@ class TestRubyMode
|
|||||||
| end
|
| end
|
||||||
|')
|
|')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_spread_arguments
|
||||||
|
assert_indent('
|
||||||
|
|foo(1,
|
||||||
|
| 2,
|
||||||
|
| 3)
|
||||||
|
|', '
|
||||||
|
|foo(1,
|
||||||
|
| 2,
|
||||||
|
| 3)
|
||||||
|
|')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end if TestRubyMode::EMACS
|
end if TestRubyMode::EMACS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user