0

I'm a little surprised that I haven't found anything on the web about this, but I've got a Ruby file and its private methods aren't listed by imenu.

Given the following class:

class Blub
  def hi
    "Hi!"
  end
  def bye
    "Bye!"
  end

  private
  
  def hiding
    "You can't see me"
  end
end

you I can reproduce this by running M-x imenu, which doesn't show hiding, while hi and bye are there.

This is the case whether I start emacs normally or with --no-init.

Any ideas?

In larger buffers where I want to navigate within it, this would be a valuable fix.

Here's the version info my emacs. I'm on arch linux.

$ emacs --version
GNU Emacs 27.2
Copyright (C) 2021 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

Update

I've gotten a bit further. The original version of my sample class was incorrect, which is why @Dmitry and @Étienne weren't able to reproduce the problem.

When we use inline access modifiers, as in the example below, the problem should be reproducible when emacs is started with either the -q or -Q option.

class Blub
  def hi
    "Hi!"
  end

  def bye
    "Bye!"
  end

  private def hiding
    "You can't see me"
  end
end

I'm still not sure how to fix this though. A quick look into the imenu source makes me think it has to do with the imenu-create-index-function, which I'd guess has to be defined for each language, but that's as far as I've gotten at this point.

6
  • Works for me here. Which Emacs version is this?
    – Dmitry
    Aug 13 '21 at 13:26
  • It also works for me. Looking at the code it is very straightforward and does not do anything about private methods. At least for the default ruby-mode. Maybe do you use another mode on top of it?
    – Étienne
    Aug 13 '21 at 14:44
  • Weird. I've updated the question. The version is 27.2 on arch linux.
    – flooose
    Aug 13 '21 at 20:22
  • I see you have tried it with emacs -q. Can you try emacs -Q instead? That would also disable extra Lisp installed by the system.
    – Dmitry
    Aug 13 '21 at 23:22
  • See the update I've posted. Sorry, the original version of my example class was not correct :(
    – flooose
    Aug 16 '21 at 10:29
0

This is now fixed in ruby-mode on master, for the upcoming Emacs 28.

If you are staying on a release version, you can apply this patch locally: https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=9e2cc406d3bc1a1f2f6008059091b9c1b8f12acf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.