jed-users mailing list

[2003 Date Index] [2003 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: Namespaces for modes?


On Tue, Aug 12, 2003 at 09:52:11PM +0000, Joerg Sommer wrote:
> begin  Günter Milde <milde@xxxxxxxxxxxxxxxxxxxx> wrote:
> > On Sun, Jul 20, 2003 at 05:09:45PM +0200, Paul Boekholt wrote:
> >> On Tue, Jul 15, 2003 at 09:47:03AM +0200, Guenter Milde wrote:
> >> > Functions that are only used by the same mode or derived modes can be
> >> > in the named namespace. ...
> >> > This also works for functions to be bound to the modes keymap 
> >> > or menu entries with e.g.
> >> >   definekey("mode->fun", Key_F11);

> >> The next version of cal.sl will have a function mark_diary_entries() that
> >> will highlight dates for which you have diary entries. Users may want their
> >> appointments highlighted on starting the calendar with some lines in their
> >> .jedrc:
> >> 
> >> autoload("mark_diary_entries", "cal");
> >> define calendar_mode_hook()
> >> {
> >>    mark_diary_entries();
> >> }
> >> 
> >> If mark_diary_entries() were static this wouldn't be possible - you would
> >> have to require("cal") which is 600 lines.

However, you could do
 define calendar_mode_hook()
 {
    eval("cal->mark_diary_entries()");
 }
.

> > I have to admit, that named namespaces have some drawbacks too... I use
> > them for functions I don't want the average user to access directly.
 
> Where is the drawback? You can also do this in a namespace with public.

I have to clarify: putting functions in a named namespace has currently some
drawbacks when the function shall be accessible to end-users. The drawbacks
in the current implementation are

  - no autoload("mode->fun", "mode")
  - no fun_p = __get_reference("mode->fun")
    and hence no runhooks("mode->fun")
  - apropos will not show the existence of the function.
    (The intrinsic function _apropos can show functions in namespaces, but
    you have to provide the name -- this will not help much if you are
    browsing for existing functions. There should be something like 
    list_namespaces().)

> ... But I see a
> great advantage with autoload. Usually one namespace is in excatly one
> file. If autoload would support namespaces, you have to call autoload
> only one time for a mode.
> 
> autoload("latex->", "latex.sl");

This would indeed be a nice thing to have (however, I fear it is not
easily done)!

Günter

-- 
Milde at ife.et.tu-dresden.de

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2003 date index] [2003 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]