ruby-add-log-current-method: Reduce the use of 'nreverse'
* lisp/progmodes/ruby-mode.el (ruby-add-log-current-method): Reduce the use of 'nreverse' (bug#62761). * test/lisp/progmodes/ruby-mode-tests.el (ruby-add-log-current-method-singleton-referencing-outer): New test.
This commit is contained in:
parent
17d803d0a7
commit
a22eb9ae0f
2 changed files with 18 additions and 2 deletions
|
@ -1905,13 +1905,13 @@ See `add-log-current-defun-function'."
|
||||||
(progn
|
(progn
|
||||||
(unless (string-equal "self" (car mn)) ; def self.foo
|
(unless (string-equal "self" (car mn)) ; def self.foo
|
||||||
;; def C.foo
|
;; def C.foo
|
||||||
(let ((ml (nreverse mlist)))
|
(let ((ml (reverse mlist)))
|
||||||
;; If the method name references one of the
|
;; If the method name references one of the
|
||||||
;; containing modules, drop the more nested ones.
|
;; containing modules, drop the more nested ones.
|
||||||
(while ml
|
(while ml
|
||||||
(if (string-equal (car ml) (car mn))
|
(if (string-equal (car ml) (car mn))
|
||||||
(setq mlist (nreverse (cdr ml)) ml nil))
|
(setq mlist (nreverse (cdr ml)) ml nil))
|
||||||
(or (setq ml (cdr ml)) (nreverse mlist))))
|
(setq ml (cdr ml))))
|
||||||
(if mlist
|
(if mlist
|
||||||
(setcdr (last mlist) (butlast mn))
|
(setcdr (last mlist) (butlast mn))
|
||||||
(setq mlist (butlast mn))))
|
(setq mlist (butlast mn))))
|
||||||
|
|
|
@ -567,6 +567,22 @@ VALUES-PLIST is a list with alternating index and value elements."
|
||||||
(search-backward "_")
|
(search-backward "_")
|
||||||
(should (string= (ruby-add-log-current-method) "C::D#foo"))))
|
(should (string= (ruby-add-log-current-method) "C::D#foo"))))
|
||||||
|
|
||||||
|
(ert-deftest ruby-add-log-current-method-singleton-referencing-outer ()
|
||||||
|
(ruby-with-temp-buffer (ruby-test-string
|
||||||
|
"module M
|
||||||
|
| module N
|
||||||
|
| module C
|
||||||
|
| class D
|
||||||
|
| def C.foo
|
||||||
|
| _
|
||||||
|
| end
|
||||||
|
| end
|
||||||
|
| end
|
||||||
|
| end
|
||||||
|
|end")
|
||||||
|
(search-backward "_")
|
||||||
|
(should (string= (ruby-add-log-current-method) "M::N::C.foo"))))
|
||||||
|
|
||||||
(ert-deftest ruby-add-log-current-method-after-inner-class ()
|
(ert-deftest ruby-add-log-current-method-after-inner-class ()
|
||||||
(ruby-with-temp-buffer (ruby-test-string
|
(ruby-with-temp-buffer (ruby-test-string
|
||||||
"module M
|
"module M
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue