Subject: bug#19285: closed (Re: bug#19285: 24.4; ruby-imenu-create-index-in-block gets confused by regular expression in source code)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 09 Mar 2015 03:59:02 +0000

Your bug report

#19285: 24.4; ruby-imenu-create-index-in-block gets confused by regular expression in source code

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
19285: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19285
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#19285: 24.4; ruby-imenu-create-index-in-block gets confused by regular expression in source code
From: Dmitry Gutov <[email-masked]>
To: Moritz Bunkus <[email-masked]>
Cc: [email-masked]
Date: Mon, 09 Mar 2015 05:58:07 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 25.1

Moritz Bunkus <[email-masked]> writes:

> If I have certain Ruby code inside my source file then
> ruby-imenu-create-index-in-block (which is `imenu-create-index-function'
> is set to in ruby-mode) then imenu only sees the definitions that occur
> before said regular expression.

The problem was rather with detection of regexps after `!' (you could
see it was not highlighted).

Should be fixed in master now, thanks for the report.

Subject: 24.4; ruby-imenu-create-index-in-block gets confused by regular expression in source code
From: Moritz Bunkus <[email-masked]>
To: [email-masked]
Date: Fri, 05 Dec 2014 22:01:15 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hey,

If I have certain Ruby code inside my source file then
ruby-imenu-create-index-in-block (which is `imenu-create-index-function'
is set to in ruby-mode) then imenu only sees the definitions that occur
before said regular expression.

The smallest test case I've come up with is the following snippet:

--------------------------------------------------
#!/usr/bin/ruby

class TestMe
  def func1
    if ! /class\s+.*?\s+<\s+Test/.match(content)
      true
    end
  end

  def func2
  end
end
--------------------------------------------------

In this source file imenu only offers `TestMe#func1' and `TestMe' itself
but not `TestMe#func2'. If I remove the content of `func` (or change the
`if' clause to something simpler) then `imenu` does see `TestMe#func2'
again.

I've verified this with »emacs -Q test_file.rb« followed by M-x imenu
RET

This is ruby-mode.el from Emacs itself:

;;; ruby-mode.el --- Major mode for editing Ruby files

;; Copyright (C) 1994-2014 Free Software Foundation, Inc.

;; Authors: Yukihiro Matsumoto
;;	Nobuyoshi Nakada
;; URL: http://www.emacswiki.org/cgi-bin/wiki/RubyMode
;; Created: Fri Feb  4 14:49:13 JST 1994
;; Keywords: languages ruby
;; Version: 1.2

How to reproduce:

- Write the aforementioned snippet into a file.
- emacs -Q thatfile.rb
- Enable `ruby-mode' if it isn't enabled already, load `imenu' if it
  hasn't been loaded alread
- M-x imenu RET
- Observe described behavior

In GNU Emacs 24.4.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.3)
 of 2014-10-21 on bitzer.hoetzel.info
Configured using:
 `configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 --param=ssp-buffer-size=4' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'

Important settings:
  value of $LC_COLLATE: de_DE.UTF-8
  value of $LC_CTYPE: de_DE.UTF-8
  value of $LC_MONETARY: de_DE.UTF-8
  value of $LC_NUMERIC: de_DE.UTF-8
  value of $LC_TIME: de_DE.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Ruby

Minor modes in effect:
  flymake-mode: t
  hi-lock-mode: t
  ido-everywhere: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  diff-auto-refine-mode: t
  global-edit-server-edit-mode: t
  which-function-mode: t
  global-hl-line-mode: t
  show-paren-mode: t
  winner-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-p C-p C-n C-k C-x C-s ESC i C-g C-k C-k C-x C-s ESC
i C-g C-k C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-n C-p C-p C-p C-k C-x C-s ESC i C-g C-_ C-_ C-n C-@
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-w ESC p ESC RET
C-k C-p C-p ESC RET t r u e C-x C-s ESC i C-g C-p ESC
O D ESC O D C-d C-x C-s ESC i C-g SPC C-x C-s C-p ESC
f ESC f ESC b ESC DEL ESC d ESC d ESC d f u n c 1 C-n
C-n C-n C-n C-n C-n ESC DEL ESC d f u n c 1 C-x C-s
DEL 2 C-x C-s ESC i C-a ESC x r e C-g C-g C-g ESC x
r e p o r t - e m a c s RET r u b y - m o d e ' s SPC
i n d DEL DEL DEL C-g C-h v r u b y - m a k e DEL DEL
DEL DEL i m e n u C-g C-h v i m e n u - C-g C-h f r
u b y C-@ i m e n u C-g ESC x ESC O A RET r u b y -
i e DEL m e n ESC ' ESC b C-e SPC g e t s SPC c o n
f u s e d SPC b y SPC r e g u l a r SPC e x p r e s
s i o n SPC i n SPC s o u r c e SPC c o d e RET ESC
O A ESC O A ESC x ESC O A RET

Recent messages:
Wrote /home/mosu/tmp/bla.rb
Auto-saving...done
Saving file /home/mosu/tmp/bla.rb...
Wrote /home/mosu/tmp/bla.rb
Saving file /home/mosu/tmp/bla.rb...
Wrote /home/mosu/tmp/bla.rb
completing-read-default: Command attempted to use minibuffer while in minibuffer
Quit [7 times]
Scanning for dabbrevs...done
Waiting for process to die...done
Quit

Load-path shadows:
/home/mosu/.emacs.d/site-start.d/libs/paredit hides /home/mosu/.emacs.d/elpa/paredit-20140128.1248/paredit
/home/mosu/.emacs.d/site-start.d/libs/buff-menu hides /usr/share/emacs/24.4/lisp/buff-menu
/usr/share/emacs/site-lisp/flim/hex-util hides /usr/share/emacs/24.4/lisp/hex-util
/usr/share/emacs/site-lisp/flim/md4 hides /usr/share/emacs/24.4/lisp/md4
/home/mosu/.emacs.d/site-start.d/libs/cc-langs hides /usr/share/emacs/24.4/lisp/progmodes/cc-langs
/home/mosu/.emacs.d/site-start.d/libs/cc-align hides /usr/share/emacs/24.4/lisp/progmodes/cc-align
/home/mosu/.emacs.d/site-start.d/libs/cc-defs hides /usr/share/emacs/24.4/lisp/progmodes/cc-defs
/home/mosu/.emacs.d/site-start.d/libs/cc-mode hides /usr/share/emacs/24.4/lisp/progmodes/cc-mode
/home/mosu/.emacs.d/site-start.d/libs/cc-fonts hides /usr/share/emacs/24.4/lisp/progmodes/cc-fonts
/home/mosu/.emacs.d/site-start.d/libs/cc-styles hides /usr/share/emacs/24.4/lisp/progmodes/cc-styles
/home/mosu/.emacs.d/site-start.d/libs/cc-vars hides /usr/share/emacs/24.4/lisp/progmodes/cc-vars
/home/mosu/.emacs.d/site-start.d/libs/cc-menus hides /usr/share/emacs/24.4/lisp/progmodes/cc-menus
/home/mosu/.emacs.d/site-start.d/libs/cc-cmds hides /usr/share/emacs/24.4/lisp/progmodes/cc-cmds
/home/mosu/.emacs.d/site-start.d/libs/cc-awk hides /usr/share/emacs/24.4/lisp/progmodes/cc-awk
/home/mosu/.emacs.d/elpa/flymake-0.4.16/flymake hides /usr/share/emacs/24.4/lisp/progmodes/flymake
/home/mosu/.emacs.d/site-start.d/libs/cc-compat hides /usr/share/emacs/24.4/lisp/progmodes/cc-compat
/home/mosu/.emacs.d/site-start.d/libs/cc-engine hides /usr/share/emacs/24.4/lisp/progmodes/cc-engine
/home/mosu/.emacs.d/site-start.d/libs/cfengine hides /usr/share/emacs/24.4/lisp/progmodes/cfengine
/home/mosu/.emacs.d/site-start.d/libs/cperl-mode/cperl-mode hides /usr/share/emacs/24.4/lisp/progmodes/cperl-mode
/home/mosu/.emacs.d/site-start.d/libs/cc-bytecomp hides /usr/share/emacs/24.4/lisp/progmodes/cc-bytecomp
/home/mosu/.emacs.d/site-start.d/libs/cc-guess hides /usr/share/emacs/24.4/lisp/progmodes/cc-guess
/usr/share/emacs/site-lisp/flim/sasl-digest hides /usr/share/emacs/24.4/lisp/net/sasl-digest
/usr/share/emacs/site-lisp/flim/hmac-def hides /usr/share/emacs/24.4/lisp/net/hmac-def
/usr/share/emacs/site-lisp/flim/sasl-cram hides /usr/share/emacs/24.4/lisp/net/sasl-cram
/usr/share/emacs/site-lisp/flim/ntlm hides /usr/share/emacs/24.4/lisp/net/ntlm
/usr/share/emacs/site-lisp/flim/sasl hides /usr/share/emacs/24.4/lisp/net/sasl
/usr/share/emacs/site-lisp/flim/hmac-md5 hides /usr/share/emacs/24.4/lisp/net/hmac-md5
/usr/share/emacs/site-lisp/flim/sasl-ntlm hides /usr/share/emacs/24.4/lisp/net/sasl-ntlm
/usr/share/emacs/site-lisp/semi/smime hides /usr/share/emacs/24.4/lisp/gnus/smime
/home/mosu/.emacs.d/site-start.d/libs/cl-lib hides /usr/share/emacs/24.4/lisp/emacs-lisp/cl-lib
/usr/share/emacs/site-lisp/semi/pgg-parse hides /usr/share/emacs/24.4/lisp/obsolete/pgg-parse
/usr/share/emacs/site-lisp/semi/pgg-pgp5 hides /usr/share/emacs/24.4/lisp/obsolete/pgg-pgp5
/usr/share/emacs/site-lisp/semi/pgg-def hides /usr/share/emacs/24.4/lisp/obsolete/pgg-def
/usr/share/emacs/site-lisp/semi/pgg-gpg hides /usr/share/emacs/24.4/lisp/obsolete/pgg-gpg
/usr/share/emacs/site-lisp/semi/pgg hides /usr/share/emacs/24.4/lisp/obsolete/pgg
/usr/share/emacs/site-lisp/semi/pgg-pgp hides /usr/share/emacs/24.4/lisp/obsolete/pgg-pgp

Features:
(shadow mail-extr emacsbug autoconf autoconf-mode m4-mode flymake
ruby-mode novice eieio-opt speedbar sb-image ezimage dframe find-func
ack-and-a-half smerge-mode dabbrev vc-git hi-lock hideshow cc-subword
cc-mode cc-fonts cc-awk cc-guess cc-menus cc-cmds cc-styles cc-align
cc-engine cc-langs cc-vars cc-defs cc-bytecomp tabify jka-compr dns-mode
bookmark pp rect sort tramp-cmds tramp-sh conf-mode tramp-cache footnote
flyspell ispell sh-script smie executable misearch multi-isearch xterm f
s paredit two-column 70-perl cperl-mode etags man 70-ido ido magit-blame
dired-x dired-sort-map dired-single dired magit-key-mode magit view
tramp tramp-compat auth-source gnus-util password-cache tramp-loaddefs
trampver shell pcomplete grep compile comint epa epg diff-mode
autorevert filenotify ansi-color git-rebase-mode thingatpt
git-commit-mode server log-edit message idna sendmail format-spec rfc822
mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mailabbrev mail-utils gmm-utils
mailheader pcvs-util add-log solarized-light-theme solarized-definitions
70-html-xml rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse
rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode nxml-outln
nxml-rap nxml-util nxml-glyph nxml-enc xmltok saveplace buff-menu+
buff-menu edit-server 70-helpers which-func imenu dash-functional dash
browse-kill-ring hl-line time-date paren 70-text 70-tabs filladapt
winner ring 01-version-test my-site-start yasnippet advice help-fns
derived easy-mmode edmacro kmacro help-mode ack-and-a-half-autoloads
ag-autoloads clojure-test-mode-autoloads cider-autoloads
dash-functional-autoloads elixir-mode-autoloads expand-region-autoloads
f-autoloads dash-autoloads flymake-autoloads flymake-yaml-autoloads
flymake-easy-autoloads gist-autoloads finder-inf gh-autoloads eieio
byte-opt bytecomp byte-compile cconv eieio-core logito-autoloads info
easymenu magit-autoloads git-rebase-mode-autoloads
git-commit-mode-autoloads markdown-mode-autoloads nrepl-autoloads
clojure-mode-autoloads paredit-autoloads pcache-autoloads
pkg-info-autoloads epl-autoloads s-autoloads tracwiki-mode-autoloads
xml-rpc-autoloads yaml-mode-autoloads package epg-config cl-macs cl gv
cl-loaddefs cl-lib tooltip electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 560044 79106)
 (symbols 48 40437 18)
 (miscs 40 6094 4560)
 (strings 32 90842 16542)
 (string-bytes 1 2716159)
 (vectors 16 46859)
 (vector-slots 8 1778267 27228)
 (floats 8 1723 1962)
 (intervals 56 19763 781)
 (buffers 960 113)
 (heap 1024 41786 3167))