all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* More imenu questions
@ 2005-11-10 19:23 gamename
  2005-11-10 21:11 ` Peter Dyballa
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: gamename @ 2005-11-10 19:23 UTC (permalink / raw)


Hi,

I'm trying to add menu items in tcl like this:
(setq tcl-imenu-generic-expression
      '((TestCases  "^aetest::testcase -tc_id \\([_-A-Za-z0-9+]+\\)[
]+{" 1)))

When I turn on the major mode (tcl-mode), I get this error:
"Wrong type argument: symbolp, ((TestCases "^aetest::testcase -tc_id
\\([_-A-Za-z0-9+]+\\)[ ]+{" 1))"

What am I doing wrong?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: More imenu questions
  2005-11-10 19:23 More imenu questions gamename
@ 2005-11-10 21:11 ` Peter Dyballa
  2005-11-10 22:00 ` Kevin Rodgers
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Peter Dyballa @ 2005-11-10 21:11 UTC (permalink / raw)
  Cc: help-gnu-emacs


Am 10.11.2005 um 20:23 schrieb gamename:

> When I turn on the major mode (tcl-mode), I get this error:
> "Wrong type argument: symbolp, ((TestCases "^aetest::testcase -tc_id
> \\([_-A-Za-z0-9+]+\\)[ ]+{" 1))"
>
> What am I doing wrong?
>

When you use in a regular expression [_-A...] this can be 
(mis-)interpreted as all characters in the range from _ to A. The 
correct description should be [-_...].

[ ]+ is unnecessarily complicated. ' +' should do the same.

{" 1))" could be misunderstood. Clarification with backslashes might be 
needed.

But I really don't know what you are trying ...

--
Greetings

   Pete

One doesn't expect governments to obey the law because of some
higher moral development.  One expects them to obey the law because
they know that if they don't, those who aren't shot will be hanged.
                                                  --Michael Shirley

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: More imenu questions
  2005-11-10 19:23 More imenu questions gamename
  2005-11-10 21:11 ` Peter Dyballa
@ 2005-11-10 22:00 ` Kevin Rodgers
  2005-11-10 23:55 ` rgb
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Kevin Rodgers @ 2005-11-10 22:00 UTC (permalink / raw)


gamename wrote:
 > I'm trying to add menu items in tcl like this:
 > (setq tcl-imenu-generic-expression
 >       '((TestCases  "^aetest::testcase -tc_id \\([_-A-Za-z0-9+]+\\)[
 > ]+{" 1)))


,----[ C-h v imenu-generic-expression RET ]
| imenu-generic-expression's value is nil
|
| Documentation:
| The regex pattern to use for creating a buffer index.
|
| If non-nil this pattern is passed to `imenu--generic-function'
| to create a buffer index.
|
| The value should be an alist with elements that look like this:
|  (MENU-TITLE REGEXP INDEX)
| or like this:
|  (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...)
| with zero or more ARGUMENTS.  The former format creates a simple 
element in
| the index alist when it matches; the latter creates a special element
| of the form  (NAME POSITION-MARKER FUNCTION ARGUMENTS...)
| with FUNCTION and ARGUMENTS copied from `imenu-generic-expression'.
|
| MENU-TITLE is a string used as the title for the submenu or nil if the
| entries are not nested.
|
| REGEXP is a regexp that should match a construct in the buffer that is
| to be displayed in the menu; i.e., function or variable definitions,
| etc.  It contains a substring which is the name to appear in the
| menu.  See the info section on Regexps for more information.
|
| INDEX points to the substring in REGEXP that contains the name (of the
| function, variable or type) that is to appear in the menu.
|
| The variable is buffer-local.
|
| The variable `imenu-case-fold-search' determines whether or not the
| regexp matches are case sensitive, and `imenu-syntax-alist' can be
| used to alter the syntax table for the search.
|
| For example, see the value of `lisp-imenu-generic-expression' used by
| `fortran-mode' with `imenu-syntax-alist' set locally to give the
| characters which normally have "symbol" syntax "word" syntax
| during matching.
|
| Defined in `imenu'.
`----

 > When I turn on the major mode (tcl-mode), I get this error:
 > "Wrong type argument: symbolp, ((TestCases "^aetest::testcase -tc_id
 > \\([_-A-Za-z0-9+]+\\)[ ]+{" 1))"
 >
 > What am I doing wrong?

You've got an extra level of parentheses:

(setq tcl-imenu-generic-expression
       '(TestCases "^aetest::testcase -tc_id \\([_-A-Za-z0-9+]+\\)[
]+{" 1))

Also, [\n]+ would be more readable than a literal newline.

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: More imenu questions
  2005-11-10 19:23 More imenu questions gamename
  2005-11-10 21:11 ` Peter Dyballa
  2005-11-10 22:00 ` Kevin Rodgers
@ 2005-11-10 23:55 ` rgb
       [not found] ` <mailman.14783.1131660316.20277.help-gnu-emacs@gnu.org>
       [not found] ` <mailman.14778.1131657088.20277.help-gnu-emacs@gnu.org>
  4 siblings, 0 replies; 11+ messages in thread
From: rgb @ 2005-11-10 23:55 UTC (permalink / raw)



gamename wrote:
> Hi,
>
> I'm trying to add menu items in tcl like this:
> (setq tcl-imenu-generic-expression
>       '((TestCases  "^aetest::testcase -tc_id \\([_-A-Za-z0-9+]+\\)[
> ]+{" 1)))
>
> When I turn on the major mode (tcl-mode), I get this error:
> "Wrong type argument: symbolp, ((TestCases "^aetest::testcase -tc_id
> \\([_-A-Za-z0-9+]+\\)[ ]+{" 1))"
> 
> What am I doing wrong?

Put "TestCases" in quotes.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: More imenu questions
       [not found] ` <mailman.14783.1131660316.20277.help-gnu-emacs@gnu.org>
@ 2005-11-11  0:15   ` rgb
  0 siblings, 0 replies; 11+ messages in thread
From: rgb @ 2005-11-11  0:15 UTC (permalink / raw)



Kevin Rodgers wrote:
> gamename wrote:
>  > I'm trying to add menu items in tcl like this:
>  > (setq tcl-imenu-generic-expression
>  >       '((TestCases  "^aetest::testcase -tc_id \\([_-A-Za-z0-9+]+\\)[
>  > ]+{" 1)))
>
>  > When I turn on the major mode (tcl-mode), I get this error:
>  > "Wrong type argument: symbolp, ((TestCases "^aetest::testcase -tc_id
>  > \\([_-A-Za-z0-9+]+\\)[ ]+{" 1))"
>  >
>  > What am I doing wrong?
>
> You've got an extra level of parentheses:

That's the syntax for supplying several menu levels or regexp's.
The fact that only one is being supplied doesn't preclude use of
the extra level.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: More imenu questions
       [not found] ` <mailman.14778.1131657088.20277.help-gnu-emacs@gnu.org>
@ 2005-11-11  1:57   ` gamename
  2005-11-11 16:43     ` rgb
  0 siblings, 1 reply; 11+ messages in thread
From: gamename @ 2005-11-11  1:57 UTC (permalink / raw)


Hi Peter,

Thanks for the regex pointers. That helps.  I'll have to give you a
little background to explain what I'm trying.

I have an in-house developed tcl package with code blocks in the
following format:

aetest::testcase -tc_id rekey {
    aetest::subtest -subtc_id test1 {
        aetest::section setup {        }
        aetest::section test {        }
        aetest::section cleanup {        }
    }
    aetest::subtest -subtc_id test2 {
        aetest::section setup {        }
        aetest::section test {        }
        aetest::section cleanup {        }
    }
    etc ...
}

So, I'm trying to create an imenu menu hierarchy which will allow me to
put them in some kind of logical order.  Here is what I have:

(setq tcl-imenu-generic-expression
 '(("Testcase"  "aetest::testcase +-tc_id +\\([-_A-Za-z0-9+]+\\) +{" 1)
 ("SubTest"  "aetest::subtest +-subtc_id +\\([-_A-Za-z0-9+]+\\) +{" 2)
 ("Section"  "aetest::section +\\([-_A-Za-z0-9+]+\\) +{" 3)))

(add-hook 'tcl-mode-hook
   (function (lambda ()
         (setq imenu-generic-expression
tcl-imenu-generic-expression))))

I hope this clarifies what I'm trying to do.  Is this the correct way
to approach it?  

TIA,

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: More imenu questions
  2005-11-11  1:57   ` gamename
@ 2005-11-11 16:43     ` rgb
  2005-11-11 17:04       ` Drew Adams
                         ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: rgb @ 2005-11-11 16:43 UTC (permalink / raw)


gamename wrote:
> Hi Peter,
>
> Thanks for the regex pointers. That helps.  I'll have to give you a
> little background to explain what I'm trying.
>
> I have an in-house developed tcl package with code blocks in the
> following format:
>
> aetest::testcase -tc_id rekey {
>     aetest::subtest -subtc_id test1 {
>         aetest::section setup {        }
>         aetest::section test {        }
>         aetest::section cleanup {        }
>     }
>     aetest::subtest -subtc_id test2 {
>         aetest::section setup {        }
>         aetest::section test {        }
>         aetest::section cleanup {        }
>     }
>     etc ...
> }
>
> So, I'm trying to create an imenu menu hierarchy which will allow me to
> put them in some kind of logical order.  Here is what I have:
>
> (setq tcl-imenu-generic-expression
>  '(("Testcase"  "aetest::testcase +-tc_id +\\([-_A-Za-z0-9+]+\\) +{" 1)
>  ("SubTest"  "aetest::subtest +-subtc_id +\\([-_A-Za-z0-9+]+\\) +{" 2)
>  ("Section"  "aetest::section +\\([-_A-Za-z0-9+]+\\) +{" 3)))
>
> (add-hook 'tcl-mode-hook
>    (function (lambda ()
>          (setq imenu-generic-expression
> tcl-imenu-generic-expression))))
>
> I hope this clarifies what I'm trying to do.  Is this the correct way
> to approach it?

I wish someone would tell me I'm wrong but imenu doesn't support any
kind of heirarchy.  You're getting a "Section" menu that contains a
bunch of "setup" entries without any indication of which subtest it
belongs to right?

AFAIK, the best you can do is to specify () or nil for the menu names
and include the testcase/subtest/section keyword in your match group.
Obviously, then, you can't use any sorting on the imenu index because
it's only the position in the list that gives you an idea of what
groups your entities belong to.

I've been trying to find time to enhance imenu myself because I have
several modes that need hierarchy support but it's just not happening.
If someone else has done something I'll be downloading it right away
but I've not seen anything.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: More imenu questions
  2005-11-11 16:43     ` rgb
@ 2005-11-11 17:04       ` Drew Adams
  2005-11-11 23:58       ` Donal K. Fellows
  2005-11-12 17:20       ` gamename
  2 siblings, 0 replies; 11+ messages in thread
From: Drew Adams @ 2005-11-11 17:04 UTC (permalink / raw)


    I wish someone would tell me I'm wrong but imenu doesn't support any
    kind of heirarchy.  You're getting a "Section" menu that contains a
    bunch of "setup" entries without any indication of which subtest it
    belongs to right?

    AFAIK, the best you can do is to specify () or nil for the menu names
    and include the testcase/subtest/section keyword in your match group.
    Obviously, then, you can't use any sorting on the imenu index because
    it's only the position in the list that gives you an idea of what
    groups your entities belong to.

    I've been trying to find time to enhance imenu myself because I have
    several modes that need hierarchy support but it's just not happening.
    If someone else has done something I'll be downloading it right away
    but I've not seen anything.

I haven't been following this thread, so I'm not sure what you mean by
"hierarchy". If you're looking for how to make an imenu menu with submenus,
you might look at library `imenu+.el' for an example:
http://www.emacswiki.org/cgi-bin/wiki/imenu%2b.el.

HTH,

  Drew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: More imenu questions
  2005-11-11 16:43     ` rgb
  2005-11-11 17:04       ` Drew Adams
@ 2005-11-11 23:58       ` Donal K. Fellows
  2005-11-14 22:24         ` Bruce Stephens
  2005-11-12 17:20       ` gamename
  2 siblings, 1 reply; 11+ messages in thread
From: Donal K. Fellows @ 2005-11-11 23:58 UTC (permalink / raw)


rgb wrote:
> I've been trying to find time to enhance imenu myself because I have
> several modes that need hierarchy support but it's just not happening.
> If someone else has done something I'll be downloading it right away
> but I've not seen anything.

If you find anything, I'd appreciate knowing too. :-)

Donal.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: More imenu questions
  2005-11-11 16:43     ` rgb
  2005-11-11 17:04       ` Drew Adams
  2005-11-11 23:58       ` Donal K. Fellows
@ 2005-11-12 17:20       ` gamename
  2 siblings, 0 replies; 11+ messages in thread
From: gamename @ 2005-11-12 17:20 UTC (permalink / raw)



Thanks rgb,

At least it keeps me from wasting more time on this.

-T

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: More imenu questions
  2005-11-11 23:58       ` Donal K. Fellows
@ 2005-11-14 22:24         ` Bruce Stephens
  0 siblings, 0 replies; 11+ messages in thread
From: Bruce Stephens @ 2005-11-14 22:24 UTC (permalink / raw)


"Donal K. Fellows" <donal.k.fellows@manchester.ac.uk> writes:

> rgb wrote:
>> I've been trying to find time to enhance imenu myself because I have
>> several modes that need hierarchy support but it's just not happening.
>> If someone else has done something I'll be downloading it right away
>> but I've not seen anything.
>
> If you find anything, I'd appreciate knowing too. :-)

Speedbar provides a hierarchical framework into which you can put
things.  Semantic (or maybe cedet) provides a menu which behaves very
like imenu but is hierarchical (in that it's split into categories).

I doubt that either is quite as easy to set up as imenu, but I'd guess
speedbar would have something pretty easy.  I can't believe it would
be *that* hard to produce a custom hierarchical menu for Tcl code.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-11-14 22:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-10 19:23 More imenu questions gamename
2005-11-10 21:11 ` Peter Dyballa
2005-11-10 22:00 ` Kevin Rodgers
2005-11-10 23:55 ` rgb
     [not found] ` <mailman.14783.1131660316.20277.help-gnu-emacs@gnu.org>
2005-11-11  0:15   ` rgb
     [not found] ` <mailman.14778.1131657088.20277.help-gnu-emacs@gnu.org>
2005-11-11  1:57   ` gamename
2005-11-11 16:43     ` rgb
2005-11-11 17:04       ` Drew Adams
2005-11-11 23:58       ` Donal K. Fellows
2005-11-14 22:24         ` Bruce Stephens
2005-11-12 17:20       ` gamename

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.