[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 9e2cc40: ruby-mode imenu: Support methods with modifiers
From: |
Dmitry Gutov |
Subject: |
master 9e2cc40: ruby-mode imenu: Support methods with modifiers |
Date: |
Mon, 16 Aug 2021 21:07:30 -0400 (EDT) |
branch: master
commit 9e2cc406d3bc1a1f2f6008059091b9c1b8f12acf
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
ruby-mode imenu: Support methods with modifiers
* lisp/progmodes/ruby-mode.el (ruby-imenu-create-index-in-block):
Support methods with modifiers (visibility or otherwise)
(bug#50079).
---
lisp/progmodes/ruby-mode.el | 4 ++--
test/lisp/progmodes/ruby-mode-tests.el | 22 ++++++++++++++++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 74b48ca..c09f007 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -679,7 +679,7 @@ It is used when `ruby-encoding-magic-comment-style' is set
to `custom'."
(let ((index-alist '()) (case-fold-search nil)
name next pos decl sing)
(goto-char beg)
- (while (re-search-forward "^\\s *\\(\\(class\\s +\\|\\(class\\s *<<\\s
*\\)\\|module\\s +\\)\\([^(<\n ]+\\)\\|\\(def\\|alias\\)\\s +\\([^(\n ]+\\)\\)"
end t)
+ (while (re-search-forward "^\\s *\\(\\(class\\s +\\|\\(class\\s *<<\\s
*\\)\\|module\\s +\\)\\([^(<\n
]+\\)\\|\\(\\(?:\\(?:private\\|protected\\|public\\) +\\)?def\\|alias\\)\\s
+\\([^(\n ]+\\)\\)" end t)
(setq sing (match-beginning 3))
(setq decl (match-string 5))
(setq next (match-end 0))
@@ -689,7 +689,7 @@ It is used when `ruby-encoding-magic-comment-style' is set
to `custom'."
((string= "alias" decl)
(if prefix (setq name (concat prefix name)))
(push (cons name pos) index-alist))
- ((string= "def" decl)
+ ((not (null decl))
(if prefix
(setq name
(cond
diff --git a/test/lisp/progmodes/ruby-mode-tests.el
b/test/lisp/progmodes/ruby-mode-tests.el
index e2ea0d9..8bdfdc3 100644
--- a/test/lisp/progmodes/ruby-mode-tests.el
+++ b/test/lisp/progmodes/ruby-mode-tests.el
@@ -875,6 +875,28 @@ VALUES-PLIST is a list with alternating index and value
elements."
(ruby-mode-set-encoding)
(should (string= "# coding: iso-8859-15\nⓇ" (buffer-string))))))
+(ert-deftest ruby-imenu-with-private-modifier ()
+ (ruby-with-temp-buffer
+ (ruby-test-string
+ "class Blub
+ | def hi
+ | 'Hi!'
+ | end
+ |
+ | def bye
+ | 'Bye!'
+ | end
+ |
+ | private def hiding
+ | 'You can't see me'
+ | end
+ |end")
+ (should (equal (mapcar #'car (ruby-imenu-create-index))
+ '("Blub"
+ "Blub#hi"
+ "Blub#bye"
+ "Blub#hiding")))))
+
(ert-deftest ruby--indent/converted-from-manual-test ()
:tags '(:expensive-test)
;; Converted from manual test.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 9e2cc40: ruby-mode imenu: Support methods with modifiers,
Dmitry Gutov <=