aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2013-04-16 03:07:14 +0400
committerDmitry Gutov2013-04-16 03:07:14 +0400
commitfb549d640a32fb02bb8329727891de395e691c45 (patch)
tree5078c224de071e5df52bd773f7a538d919b19b1d
parent21e8fe2f857c0d7bb50809bc34d22586dc7da893 (diff)
downloademacs-fb549d640a32fb02bb8329727891de395e691c45.tar.gz
emacs-fb549d640a32fb02bb8329727891de395e691c45.zip
* lisp/progmodes/ruby-mode.el (ruby-beginning-of-defun)
(ruby-end-of-defun, ruby-move-to-block): Bind `case-fold-search' to nil. (ruby-end-of-defun): Remove the unused arg, change the docstring to reflect that this function is only used as the value of `end-of-defun-function'. (ruby-beginning-of-defun): Remove "top-level" from the docstring, to reflect an earlier change that beginning/end-of-defun functions jump between methods in a class definition, as well as top-level functions.
-rw-r--r--lisp/ChangeLog13
-rw-r--r--lisp/progmodes/ruby-mode.el25
-rw-r--r--test/automated/ruby-mode-tests.el36
3 files changed, 63 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f11d332ab0c..87cde39808d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
12013-04-15 Dmitry Gutov <dgutov@yandex.ru>
2
3 * progmodes/ruby-mode.el (ruby-beginning-of-defun)
4 (ruby-end-of-defun, ruby-move-to-block): Bind `case-fold-search'
5 to nil.
6 (ruby-end-of-defun): Remove the unused arg, change the docstring
7 to reflect that this function is only used as the value of
8 `end-of-defun-function'.
9 (ruby-beginning-of-defun): Remove "top-level" from the docstring,
10 to reflect an earlier change that beginning/end-of-defun functions
11 jump between methods in a class definition, as well as top-level
12 functions.
13
12013-04-15 Stefan Monnier <monnier@iro.umontreal.ca> 142013-04-15 Stefan Monnier <monnier@iro.umontreal.ca>
2 15
3 * minibuffer.el (minibuffer-complete): Don't just scroll 16 * minibuffer.el (minibuffer-complete): Don't just scroll
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 6e471d1aa2a..631badac34c 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -847,22 +847,24 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'."
847 indent)))) 847 indent))))
848 848
849(defun ruby-beginning-of-defun (&optional arg) 849(defun ruby-beginning-of-defun (&optional arg)
850 "Move backward to the beginning of the current top-level defun. 850 "Move backward to the beginning of the current defun.
851With ARG, move backward multiple defuns. Negative ARG means 851With ARG, move backward multiple defuns. Negative ARG means
852move forward." 852move forward."
853 (interactive "p") 853 (interactive "p")
854 (and (re-search-backward (concat "^\\s *" ruby-defun-beg-re "\\_>") 854 (let (case-fold-search)
855 nil t (or arg 1)) 855 (and (re-search-backward (concat "^\\s *" ruby-defun-beg-re "\\_>")
856 (beginning-of-line))) 856 nil t (or arg 1))
857 857 (beginning-of-line))))
858(defun ruby-end-of-defun (&optional arg) 858
859 "Move forward to the end of the current top-level defun. 859(defun ruby-end-of-defun ()
860With ARG, move forward multiple defuns. Negative ARG means 860 "Move point to the end of the current defun.
861move backward." 861The defun begins at or after the point. This function is called
862by `end-of-defun'."
862 (interactive "p") 863 (interactive "p")
863 (ruby-forward-sexp) 864 (ruby-forward-sexp)
864 (when (looking-back (concat "^\\s *" ruby-block-end-re)) 865 (let (case-fold-search)
865 (forward-line 1))) 866 (when (looking-back (concat "^\\s *" ruby-block-end-re))
867 (forward-line 1))))
866 868
867(defun ruby-beginning-of-indent () 869(defun ruby-beginning-of-indent ()
868 "Backtrack to a line which can be used as a reference for 870 "Backtrack to a line which can be used as a reference for
@@ -881,6 +883,7 @@ current block, a sibling block, or an outer block. Do that (abs N) times."
881 (depth (or (nth 2 (ruby-parse-region (line-beginning-position) 883 (depth (or (nth 2 (ruby-parse-region (line-beginning-position)
882 (line-end-position))) 884 (line-end-position)))
883 0)) 885 0))
886 case-fold-search
884 down done) 887 down done)
885 (when (< (* depth signum) 0) 888 (when (< (* depth signum) 0)
886 ;; Moving end -> end or beginning -> beginning. 889 ;; Moving end -> end or beginning -> beginning.
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el
index 0ebe6d44e34..23dc45ad509 100644
--- a/test/automated/ruby-mode-tests.el
+++ b/test/automated/ruby-mode-tests.el
@@ -487,6 +487,42 @@ VALUES-PLIST is a list with alternating index and value elements."
487 (ruby-beginning-of-block) 487 (ruby-beginning-of-block)
488 (should (= 1 (line-number-at-pos))))) 488 (should (= 1 (line-number-at-pos)))))
489 489
490(ert-deftest ruby-move-to-block-does-not-fold-case ()
491 (ruby-with-temp-buffer
492 (ruby-test-string
493 "foo do
494 | Module.to_s
495 |end")
496 (end-of-buffer)
497 (let ((case-fold-search t))
498 (ruby-beginning-of-block))
499 (should (= 1 (line-number-at-pos)))))
500
501(ert-deftest ruby-beginning-of-defun-does-not-fold-case ()
502 (ruby-with-temp-buffer
503 (ruby-test-string
504 "class C
505 | def bar
506 | Class.to_s
507 | end
508 |end")
509 (goto-line 4)
510 (let ((case-fold-search t))
511 (beginning-of-defun))
512 (should (= 2 (line-number-at-pos)))))
513
514(ert-deftest ruby-end-of-defun-skips-to-next-line-after-the-method ()
515 (ruby-with-temp-buffer
516 (ruby-test-string
517 "class D
518 | def tee
519 | 'ho hum'
520 | end
521 |end")
522 (goto-line 2)
523 (end-of-defun)
524 (should (= 5 (line-number-at-pos)))))
525
490(provide 'ruby-mode-tests) 526(provide 'ruby-mode-tests)
491 527
492;;; ruby-mode-tests.el ends here 528;;; ruby-mode-tests.el ends here