all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* create large menu on the fly
@ 2013-06-06 21:36 daniel
  2013-06-07  1:05 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: daniel @ 2013-06-06 21:36 UTC (permalink / raw)
  To: help-gnu-emacs

hi

I want to create a menu that maps a directory in the filesystem
recursively.  The files would placed as menu itens and the directories as
submenus.

But it is a big overhead to create the complete menu in one time.

So the solution would be to populate each menu only when it is activated.
Any idea how to do this?


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

* Re: create large menu on the fly
  2013-06-06 21:36 create large menu on the fly daniel
@ 2013-06-07  1:05 ` Stefan Monnier
  2013-06-07  5:50 ` Andreas Röhler
  2013-06-07 16:54 ` Michael Heerdegen
  2 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2013-06-07  1:05 UTC (permalink / raw)
  To: help-gnu-emacs

> So the solution would be to populate each menu only when it is activated.
> Any idea how to do this?

Oddly enough, Emacs's current C code can't do that: the C code traverses
the whole menu, turns it into a new data-structure using the format
expected by the UI toolkit, and passes it to the toolkit.

It would be good to change that such that the conversion from Lisp
format to the toolkit format is done incrementally via callbacks, but
it's a longstanding limitation that nobody has felt like tackling yet.


        Stefan




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

* Re: create large menu on the fly
  2013-06-06 21:36 create large menu on the fly daniel
  2013-06-07  1:05 ` Stefan Monnier
@ 2013-06-07  5:50 ` Andreas Röhler
  2013-06-07  9:19   ` daniel
  2013-06-07 16:54 ` Michael Heerdegen
  2 siblings, 1 reply; 10+ messages in thread
From: Andreas Röhler @ 2013-06-07  5:50 UTC (permalink / raw)
  To: help-gnu-emacs

Am 06.06.2013 23:36, schrieb daniel:
> hi
>
> I want to create a menu that maps a directory in the filesystem
> recursively.  The files would placed as menu itens and the directories as
> submenus.
>
> But it is a big overhead to create the complete menu in one time.
>
> So the solution would be to populate each menu only when it is activated.
> Any idea how to do this?
>

 From a first entry call your Build-function.
When created, pass it to the mode-map, i.e. redefine mode-map. Reload mode. Extended menu should appear.
And so on.

Below an example how to create a menu entry from a single known command in python-mode.el.

(defun emen (&optional symbol)
   "Provide menu draft. "
   (interactive "*")
   (let* ((erg (or symbol (car kill-ring)))
          (name (intern-soft erg))
          (doku (if (functionp name)
                    (documentation name)
                  (documentation-property name 'variable-documentation))))
     (switch-to-buffer (current-buffer))
     (save-excursion
       (insert (concat "\n\[\"" (replace-regexp-in-string "-" " " (replace-regexp-in-string "py-" "" erg)) "\" " erg "
  :help \" `" erg "'
\n"))
       (when doku (insert (regexp-quote doku)))

       (insert (concat
                ". \"]\n")))
     (skip-chars-forward "[[:punct:]]")
     (capitalize-word 1)))


HTH,

Andreas



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

* Re: create large menu on the fly
  2013-06-07  5:50 ` Andreas Röhler
@ 2013-06-07  9:19   ` daniel
  2013-06-07 10:13     ` Andreas Röhler
  0 siblings, 1 reply; 10+ messages in thread
From: daniel @ 2013-06-07  9:19 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

2013/6/7 Andreas Röhler <andreas.roehler@easy-emacs.de>

> From a first entry call your Build-function.
> When created, pass it to the mode-map, i.e. redefine mode-map. Reload
> mode. Extended menu should appear.
> And so on.
> Below an example how to create a menu entry from a single known command in
> python-mode.el.
>

I saw your code in devel/python-mode-util.el which is not loaded by default
in python-mode. Don't know how to execute it! Can you give more details?





2013/6/7 Stefan Monnier <monnier@iro.umontreal.ca>

> Oddly enough, Emacs's current C code can't do that: the C code traverses
> the whole menu, turns it into a new data-structure using the format
> expected by the UI toolkit, and passes it to the toolkit.
>

In that case there is no problem because I just optimize my filesystem menu
generation so it is much faster. Anyway, I wish to know!


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

* Re: create large menu on the fly
  2013-06-07  9:19   ` daniel
@ 2013-06-07 10:13     ` Andreas Röhler
  2013-06-07 10:26       ` daniel
  0 siblings, 1 reply; 10+ messages in thread
From: Andreas Röhler @ 2013-06-07 10:13 UTC (permalink / raw)
  To: daniel; +Cc: help-gnu-emacs

Am 07.06.2013 11:19, schrieb daniel:
> 2013/6/7 Andreas Röhler <andreas.roehler@easy-emacs.de>
>
>>  From a first entry call your Build-function.
>> When created, pass it to the mode-map, i.e. redefine mode-map. Reload
>> mode. Extended menu should appear.
>> And so on.
>> Below an example how to create a menu entry from a single known command in
>> python-mode.el.
>>
>
> I saw your code in devel/python-mode-util.el which is not loaded by default
> in python-mode.

That's for developing purposes only. It stores helper functions once used. Not certain it's useful again.

Don't know how to execute it! Can you give more details?
>

Some commands there generate menu resp. parts of it, based on exiting commands.

BTW not quite sure what you need.
IIUC you are looking for a listing of directories in menu, right?


generation so it is much faster. Anyway, I wish to know!
>





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

* Re: create large menu on the fly
  2013-06-07 10:13     ` Andreas Röhler
@ 2013-06-07 10:26       ` daniel
  2013-06-07 10:57         ` Andreas Röhler
  0 siblings, 1 reply; 10+ messages in thread
From: daniel @ 2013-06-07 10:26 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

2013/6/7 Andreas Röhler <andreas.roehler@easy-emacs.de>

> BTW not quite sure what you need.
> IIUC you are looking for a listing of directories in menu, right?
>
>
That was just an example. What I wish is to populate the menu when it is
activated.

That would also be useful when you don't know in advance what will be
displayed in the menu... like a context menu! Suppose you want a submenu in
python-mode called "navigate to method" which shows menu itens for all the
methods in the current file.

As Stefan told, that is not possible as is in Emacs.


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

* Re: create large menu on the fly
  2013-06-07 10:26       ` daniel
@ 2013-06-07 10:57         ` Andreas Röhler
  2013-06-07 11:26           ` daniel
  0 siblings, 1 reply; 10+ messages in thread
From: Andreas Röhler @ 2013-06-07 10:57 UTC (permalink / raw)
  To: daniel; +Cc: help-gnu-emacs

Am 07.06.2013 12:26, schrieb daniel:
> 2013/6/7 Andreas Röhler <andreas.roehler@easy-emacs.de>
>
>> BTW not quite sure what you need.
>> IIUC you are looking for a listing of directories in menu, right?
>>
>>
> That was just an example. What I wish is to populate the menu when it is
> activated.
>
> That would also be useful when you don't know in advance what will be
> displayed in the menu... like a context menu! Suppose you want a submenu in
> python-mode called "navigate to method" which shows menu itens for all the
> methods in the current file.

This is provided by both python-modes already with index, PyIndex in python-mode.el

>
> As Stefan told, that is not possible as is in Emacs.
>

Once an instance exist on your computer, there is a way for Emacs to access it.
Once Emacs accesses, a menu might be created from - and (re)loaded in session.

Andreas



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

* Re: create large menu on the fly
  2013-06-07 10:57         ` Andreas Röhler
@ 2013-06-07 11:26           ` daniel
  2013-06-07 11:59             ` Andreas Röhler
  0 siblings, 1 reply; 10+ messages in thread
From: daniel @ 2013-06-07 11:26 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

2013/6/7 Andreas Röhler <andreas.roehler@easy-emacs.de>

>
>> That would also be useful when you don't know in advance what will be
>> displayed in the menu... like a context menu! Suppose you want a submenu
>> in
>> python-mode called "navigate to method" which shows menu itens for all the
>> methods in the current file.
>>
>
> This is provided by both python-modes already with index, PyIndex in
> python-mode.el


My python-mode doesn't show that index... The menu is always the same.
(python-mode.el or python.el). Can't find much information about pyindex on
the web!



>
>
>> As Stefan told, that is not possible as is in Emacs.
>>
>>
> Once an instance exist on your computer, there is a way for Emacs to
> access it.
> Once Emacs accesses, a menu might be created from - and (re)loaded in
> session.


instance of what? session?
Please  explain better!


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

* Re: create large menu on the fly
  2013-06-07 11:26           ` daniel
@ 2013-06-07 11:59             ` Andreas Röhler
  0 siblings, 0 replies; 10+ messages in thread
From: Andreas Röhler @ 2013-06-07 11:59 UTC (permalink / raw)
  To: help-gnu-emacs

Am 07.06.2013 13:26, schrieb daniel:
> 2013/6/7 Andreas Röhler <andreas.roehler@easy-emacs.de>
>
>>
>>> That would also be useful when you don't know in advance what will be
>>> displayed in the menu... like a context menu! Suppose you want a submenu
>>> in
>>> python-mode called "navigate to method" which shows menu itens for all the
>>> methods in the current file.
>>>
>>
>> This is provided by both python-modes already with index, PyIndex in
>> python-mode.el
>
>
> My python-mode doesn't show that index... The menu is always the same.
> (python-mode.el or python.el).

Seems menu at python.el is broken currently.

Can't find much information about pyindex on
> the web!
>


 From previous bugfixing get quickly for example

https://bugs.launchpad.net/python-mode/+bug/1052180

;;;;;;;;;;;

Please load the current version

https://launchpad.net/python-mode

If bazaar is installed, do

bzr branch lp:python-mode

Make sure, python-mode.el gets loaded before any Python-file.
See INSTALL


>
>
>>
>>
>>> As Stefan told, that is not possible as is in Emacs.
>>>
>>>
>> Once an instance exist on your computer, there is a way for Emacs to
>> access it.
>> Once Emacs accesses, a menu might be created from - and (re)loaded in
>> session.
>
>
> instance of what? session?

Are you aware of Emacs info files?

> Please  explain better!
>

Maybe give a showcase what you are going to perform.
Why the menu, not dired for example.





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

* Re: create large menu on the fly
  2013-06-06 21:36 create large menu on the fly daniel
  2013-06-07  1:05 ` Stefan Monnier
  2013-06-07  5:50 ` Andreas Röhler
@ 2013-06-07 16:54 ` Michael Heerdegen
  2 siblings, 0 replies; 10+ messages in thread
From: Michael Heerdegen @ 2013-06-07 16:54 UTC (permalink / raw)
  To: daniel; +Cc: help-gnu-emacs

Hi Daniel,

as Stefan already said, it's not possible using the ordinary menu bar.

As a makeshift, you could use popup menus that contain e.g. only 3
directory levels, and selecting a directory at the third level pops up
a new popup menu with the next three levels under it etc.


Michael.


> I want to create a menu that maps a directory in the filesystem
> recursively.  The files would placed as menu itens and the directories as
> submenus.
>
> But it is a big overhead to create the complete menu in one time.
>
> So the solution would be to populate each menu only when it is activated.
> Any idea how to do this?





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

end of thread, other threads:[~2013-06-07 16:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-06 21:36 create large menu on the fly daniel
2013-06-07  1:05 ` Stefan Monnier
2013-06-07  5:50 ` Andreas Röhler
2013-06-07  9:19   ` daniel
2013-06-07 10:13     ` Andreas Röhler
2013-06-07 10:26       ` daniel
2013-06-07 10:57         ` Andreas Röhler
2013-06-07 11:26           ` daniel
2013-06-07 11:59             ` Andreas Röhler
2013-06-07 16:54 ` Michael Heerdegen

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.