Loading ...
Sorry, an error occurred while loading the content.

Multiple templates

Expand Messages
  • Dr. Detlef Groth
    Hello, Sometimes you need various templates for the same programming language. Let s say for perl I have a cgi-template: perl-cgi.etf, a normal template:
    Message 1 of 4 , May 4, 2004
    • 0 Attachment
      Hello,

      Sometimes you need various templates for the same programming language.

      Let's say for perl I have a cgi-template: perl-cgi.etf, a normal
      template: perl.etf and a tk-template perl-tk.etf

      If I want to insert the template I need a helper macro like:

      define-macro cgi-insert
      etfinsrt "perl-cgi"
      !emacro

      However at first I must delete the other template. May be there is a
      possiblity to check for the file extension and the load the appropiate
      template automatically.

      Has anybody done this yet ?

      regards,
      Detlef
    • Steven Phillips
      This has been done, look at fhook-c in hkc.emf, here the macro determines whether the buffer is a header or a source file and then executes buffer-init with an
      Message 2 of 4 , May 4, 2004
      • 0 Attachment
        This has been done, look at fhook-c in hkc.emf, here the macro determines
        whether the buffer is a header or a source file and then executes buffer-init
        with an extra 2nd argument of either "h" or "c" which is the name of the
        template file (without the ".etf") to insert.

        So I would copy the fhook-perl macro into myperl.emf (not nice but the only
        solution I can think of) and make suitable edits to use this feature.

        Steve

        > Subject: [jasspa] Multiple templates
        > From: Dr. Detlef Groth <dgroth@...>
        > Date: Tuesday, May 4, 2004, 2:26:33 PM
        > To: jasspa@yahoogroups.com
        > Hello,

        > Sometimes you need various templates for the same programming language.

        > Let's say for perl I have a cgi-template: perl-cgi.etf, a normal
        > template: perl.etf and a tk-template perl-tk.etf

        > If I want to insert the template I need a helper macro like:

        > define-macro cgi-insert
        > etfinsrt "perl-cgi"
        > !emacro

        > However at first I must delete the other template. May be there is a
        > possiblity to check for the file extension and the load the appropiate
        > template automatically.

        > Has anybody done this yet ?

        > regards,
        > Detlef



        > __________________________________________________________________________

        > This is an unmoderated list. JASSPA is not responsible for the content of
        > any material posted to this list.

        > To unsubscribe, send a mail message to

        > mailto:jasspa-unsubscribe@yahoogroups.com

        > or visit http://groups.yahoo.com/group/jasspa and
        > modify your account settings manually.



        > Yahoo! Groups Links
      • Dr. Detlef Groth
        ... determines ... buffer-init ... the only ... Thx, However I think I will add two, three, four ... small macros to myperl.emf for applying cgi or
        Message 3 of 4 , May 4, 2004
        • 0 Attachment
          --- In jasspa@yahoogroups.com, Steven Phillips <bill@j...> wrote:
          > This has been done, look at fhook-c in hkc.emf, here the macro
          determines
          > whether the buffer is a header or a source file and then executes
          buffer-init
          > with an extra 2nd argument of either "h" or "c" which is the name of the
          > template file (without the ".etf") to insert.
          >
          > So I would copy the fhook-perl macro into myperl.emf (not nice but
          the only
          > solution I can think of) and make suitable edits to use this feature.
          >
          > Steve
          Thx,

          However I think I will add two, three, four ... small macros to myperl.emf

          for applying cgi or tk-templates. This seems easier for me to maintain
          and to extend. So I don't need a perl file `program.tk'.
          But my be this is less redundant with @mc or @ml By getting a list of
          perl*.etf-files.

          define-macro template-cgi-insert
          ; inserting a perl-cgi template
          beginning-of-buffer
          set-mark "p"
          end-of-buffer
          exchange-point-and-mark
          kill-region
          etfinsrt "perl-cgi"
          beginning-of-buffer
          !emacro
          define-macro template-pm-insert
          ; inserting a package template
          beginning-of-buffer
          set-mark "p"
          end-of-buffer
          exchange-point-and-mark
          kill-region
          etfinsrt "perl-pm"
          beginning-of-buffer
          !emacro
          define-macro template-tk-insert
          ; inserting a perlTK template
          beginning-of-buffer
          set-mark "p"
          end-of-buffer
          exchange-point-and-mark
          kill-region
          etfinsrt "perl-tk"
          beginning-of-buffer
          !emacro

          regards,
          Detlef

          > > Subject: [jasspa] Multiple templates
          > > From: Dr. Detlef Groth <dgroth@g...>
          > > Date: Tuesday, May 4, 2004, 2:26:33 PM
          > > To: jasspa@yahoogroups.com
          > > Hello,
          >
          > > Sometimes you need various templates for the same programming
          language.
          >
          > > Let's say for perl I have a cgi-template: perl-cgi.etf, a normal
          > > template: perl.etf and a tk-template perl-tk.etf
          >
          > > If I want to insert the template I need a helper macro like:
          >
          > > define-macro cgi-insert
          > > etfinsrt "perl-cgi"
          > > !emacro
          >
          > > However at first I must delete the other template. May be there is a
          > > possiblity to check for the file extension and the load the appropiate
          > > template automatically.
          >
          > > Has anybody done this yet ?
          >
          > > regards,
          > > Detlef
          >
          >
          >
          > >
          __________________________________________________________________________
          >
          > > This is an unmoderated list. JASSPA is not responsible for the
          content of
          > > any material posted to this list.
          >
          > > To unsubscribe, send a mail message to
          >
          > > mailto:jasspa-unsubscribe@yahoogroups.com
          >
          > > or visit http://groups.yahoo.com/group/jasspa and
          > > modify your account settings manually.
          >
          >
          >
          > > Yahoo! Groups Links
        • Dr. Detlef Groth
          Hello! I end up with the following solution: I have five templates in my microemacs dir: dgroth@mg01-xx /cygdrive/c/WINNT/Profiles/dgroth/Application
          Message 4 of 4 , May 6, 2004
          • 0 Attachment
            Hello!

            I end up with the following solution:

            I have five templates in my microemacs dir:
            dgroth@mg01-xx /cygdrive/c/WINNT/Profiles/dgroth/Application Data/jasspa
            $ ls | grep -E "perl.*.etf$"
            perl-cgi.etf
            perl-console.etf
            perl-package.etf
            perl-tk.etf
            perl.etf

            perl.etf just contains the cvs-header, the other special lib-loading,
            init and procedure stuff.

            In myperl.emf I added:
            set-variable :templates "|console|package|cgi|tk|"
            set-variable :template "console"
            define-macro dg-templates-insert
            set-variable :template @ml19 "Use Template:" :template :templates
            etfinsrt &cat "perl-" :template
            !emacro

            executing this command the right template is inserted after the cvs
            header.

            Seems to be quite usefully not only for perl.

            regards,
            Detlef
          Your message has been successfully submitted and would be delivered to recipients shortly.