[Top][All Lists]

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

bug#19285: 24.4; ruby-imenu-create-index-in-block gets confused by regul

From: Moritz Bunkus
Subject: bug#19285: 24.4; ruby-imenu-create-index-in-block gets confused by regular expression in source code
Date: Fri, 05 Dec 2014 22:01:15 +0100


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:


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

  def func2

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'

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

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

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

Recent messages:
Wrote /home/mosu/tmp/bla.rb
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

Load-path shadows:
/home/mosu/.emacs.d/site-start.d/libs/paredit hides 
/home/mosu/.emacs.d/site-start.d/libs/buff-menu hides 
/usr/share/emacs/site-lisp/flim/hex-util hides 
/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 
/home/mosu/.emacs.d/site-start.d/libs/cc-align hides 
/home/mosu/.emacs.d/site-start.d/libs/cc-defs hides 
/home/mosu/.emacs.d/site-start.d/libs/cc-mode hides 
/home/mosu/.emacs.d/site-start.d/libs/cc-fonts hides 
/home/mosu/.emacs.d/site-start.d/libs/cc-styles hides 
/home/mosu/.emacs.d/site-start.d/libs/cc-vars hides 
/home/mosu/.emacs.d/site-start.d/libs/cc-menus hides 
/home/mosu/.emacs.d/site-start.d/libs/cc-cmds hides 
/home/mosu/.emacs.d/site-start.d/libs/cc-awk hides 
/home/mosu/.emacs.d/elpa/flymake-0.4.16/flymake hides 
/home/mosu/.emacs.d/site-start.d/libs/cc-compat hides 
/home/mosu/.emacs.d/site-start.d/libs/cc-engine hides 
/home/mosu/.emacs.d/site-start.d/libs/cfengine hides 
/home/mosu/.emacs.d/site-start.d/libs/cperl-mode/cperl-mode hides 
/home/mosu/.emacs.d/site-start.d/libs/cc-bytecomp hides 
/home/mosu/.emacs.d/site-start.d/libs/cc-guess hides 
/usr/share/emacs/site-lisp/flim/sasl-digest hides 
/usr/share/emacs/site-lisp/flim/hmac-def hides 
/usr/share/emacs/site-lisp/flim/sasl-cram hides 
/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/site-lisp/flim/sasl-ntlm hides 
/usr/share/emacs/site-lisp/semi/smime hides 
/home/mosu/.emacs.d/site-start.d/libs/cl-lib hides 
/usr/share/emacs/site-lisp/semi/pgg-parse hides 
/usr/share/emacs/site-lisp/semi/pgg-pgp5 hides 
/usr/share/emacs/site-lisp/semi/pgg-def hides 
/usr/share/emacs/site-lisp/semi/pgg-gpg hides 
/usr/share/emacs/site-lisp/semi/pgg hides 
/usr/share/emacs/site-lisp/semi/pgg-pgp hides 

(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))

reply via email to

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