help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: create large menu on the fly


From: Andreas Röhler
Subject: Re: create large menu on the fly
Date: Fri, 07 Jun 2013 07:50:03 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5

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



reply via email to

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