emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r112299: * lisp/progmodes/ruby-mode.e


From: Dmitry Gutov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112299: * lisp/progmodes/ruby-mode.el (ruby-beginning-of-defun)
Date: Tue, 16 Apr 2013 03:07:14 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 112299
committer: Dmitry Gutov <address@hidden>
branch nick: trunk
timestamp: Tue 2013-04-16 03:07:14 +0400
message:
  * 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.
modified:
  lisp/ChangeLog
  lisp/progmodes/ruby-mode.el
  test/automated/ruby-mode-tests.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-04-15 19:55:41 +0000
+++ b/lisp/ChangeLog    2013-04-15 23:07:14 +0000
@@ -1,3 +1,16 @@
+2013-04-15  Dmitry Gutov  <address@hidden>
+
+       * 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.
+
 2013-04-15  Stefan Monnier  <address@hidden>
 
        * minibuffer.el (minibuffer-complete): Don't just scroll

=== modified file 'lisp/progmodes/ruby-mode.el'
--- a/lisp/progmodes/ruby-mode.el       2013-03-06 18:56:29 +0000
+++ b/lisp/progmodes/ruby-mode.el       2013-04-15 23:07:14 +0000
@@ -847,22 +847,24 @@
         indent))))
 
 (defun ruby-beginning-of-defun (&optional arg)
-  "Move backward to the beginning of the current top-level defun.
+  "Move backward to the beginning of the current defun.
 With ARG, move backward multiple defuns.  Negative ARG means
 move forward."
   (interactive "p")
-  (and (re-search-backward (concat "^\\s *" ruby-defun-beg-re "\\_>")
-                           nil t (or arg 1))
-       (beginning-of-line)))
+  (let (case-fold-search)
+    (and (re-search-backward (concat "^\\s *" ruby-defun-beg-re "\\_>")
+                             nil t (or arg 1))
+         (beginning-of-line))))
 
-(defun ruby-end-of-defun (&optional arg)
-  "Move forward to the end of the current top-level defun.
-With ARG, move forward multiple defuns.  Negative ARG means
-move backward."
+(defun ruby-end-of-defun ()
+  "Move point to the end of the current defun.
+The defun begins at or after the point.  This function is called
+by `end-of-defun'."
   (interactive "p")
   (ruby-forward-sexp)
-  (when (looking-back (concat "^\\s *" ruby-block-end-re))
-    (forward-line 1)))
+  (let (case-fold-search)
+    (when (looking-back (concat "^\\s *" ruby-block-end-re))
+      (forward-line 1))))
 
 (defun ruby-beginning-of-indent ()
   "Backtrack to a line which can be used as a reference for
@@ -881,6 +883,7 @@
         (depth (or (nth 2 (ruby-parse-region (line-beginning-position)
                                              (line-end-position)))
                    0))
+        case-fold-search
         down done)
     (when (< (* depth signum) 0)
       ;; Moving end -> end or beginning -> beginning.

=== modified file 'test/automated/ruby-mode-tests.el'
--- a/test/automated/ruby-mode-tests.el 2013-03-11 04:07:45 +0000
+++ b/test/automated/ruby-mode-tests.el 2013-04-15 23:07:14 +0000
@@ -487,6 +487,42 @@
     (ruby-beginning-of-block)
     (should (= 1 (line-number-at-pos)))))
 
+(ert-deftest ruby-move-to-block-does-not-fold-case ()
+  (ruby-with-temp-buffer
+      (ruby-test-string
+       "foo do
+       |  Module.to_s
+       |end")
+    (end-of-buffer)
+    (let ((case-fold-search t))
+      (ruby-beginning-of-block))
+    (should (= 1 (line-number-at-pos)))))
+
+(ert-deftest ruby-beginning-of-defun-does-not-fold-case ()
+  (ruby-with-temp-buffer
+      (ruby-test-string
+       "class C
+       |  def bar
+       |    Class.to_s
+       |  end
+       |end")
+    (goto-line 4)
+    (let ((case-fold-search t))
+      (beginning-of-defun))
+    (should (= 2 (line-number-at-pos)))))
+
+(ert-deftest ruby-end-of-defun-skips-to-next-line-after-the-method ()
+  (ruby-with-temp-buffer
+      (ruby-test-string
+       "class D
+       |  def tee
+       |    'ho hum'
+       |  end
+       |end")
+    (goto-line 2)
+    (end-of-defun)
+    (should (= 5 (line-number-at-pos)))))
+
 (provide 'ruby-mode-tests)
 
 ;;; ruby-mode-tests.el ends here


reply via email to

[Prev in Thread] Current Thread [Next in Thread]