unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: help-gnu-emacs@gnu.org
Subject: Re: create large menu on the fly
Date: Fri, 07 Jun 2013 07:50:03 +0200	[thread overview]
Message-ID: <51B1748B.9000803@easy-emacs.de> (raw)
In-Reply-To: <CABX3oxZ-=QEmykLGz-G5EQ=PYR1XtjSEqDB3zriCWVXFqFM77A@mail.gmail.com>

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



  parent reply	other threads:[~2013-06-07  5:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51B1748B.9000803@easy-emacs.de \
    --to=andreas.roehler@easy-emacs.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).