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

Re: [jasspa] Passing value of varaiable from command line to the start-up macro

Expand Messages
  • Jon Green
    ... Hi Ian, VarName needs to be a MicroEmacs variable i.e. $foo so you will do: ne -v $foo=MONTH= somefile Then in your start-up macro you reference the
    Message 1 of 8 , Jan 27, 2011
    • 0 Attachment
      On 27/01/2011 20:58, igcain wrote:
      > Hi there
      >
      > I want to invoke the ne editor such that when it starts it goes to a specified line of text ready for over typing. My start-up macro in ne.emf looks something like;
      >
      > define-macro start-up
      > 19 buffer-mode "over"
      > !force search-buffer "M" "MONTH= "
      > end-of-line
      > !macro
      >
      > unfortunately my start-up macro (as currently written) only ever goes to the string constant "MONTH= ". But what I really would like to do is execute the command line with;
      >
      > ne -vVarName="MONTH= " somefile
      >
      > where VarName can be substituted for any string that happens to be present in the file to be ediited. Only thing is how do I reference the variable VarName within the start-up macro?
      >
      > Any help, much appreciated
      > Ian
      >

      Hi Ian,

      VarName needs to be a MicroEmacs variable i.e. $foo so you will do:

      ne -v"$foo=MONTH= " somefile

      Then in your start-up macro you reference the variable $foo.

      search-buffer "M" $foo

      You will need to be careful about how you quote the argument on the command
      line if there are any special characters or spaces. This will depend on the
      operating system you are using.

      Before you test the start-up macro probably best to play with starting the
      editor with the variable setting on the command line and checking that the
      variable is coming through correctly with a

      esc-x describe-variable $foo

      This will show you the variable value. If it is OK then you can work on the
      start-up.

      Regards
      Jon
    • igcain
      ... Jon thanks for the reply. One question how do I know which variable I can use? Ian
      Message 2 of 8 , Jan 28, 2011
      • 0 Attachment
        --- In jasspa@yahoogroups.com, Jon Green <jon@...> wrote:
        >
        > On 27/01/2011 20:58, igcain wrote:
        > > Hi there
        > >
        > > I want to invoke the ne editor such that when it starts it goes to a specified line of text ready for over typing. My start-up macro in ne.emf looks something like;
        > >
        > > define-macro start-up
        > > 19 buffer-mode "over"
        > > !force search-buffer "M" "MONTH= "
        > > end-of-line
        > > !macro
        > >
        > > unfortunately my start-up macro (as currently written) only ever goes to the string constant "MONTH= ". But what I really would like to do is execute the command line with;
        > >
        > > ne -vVarName="MONTH= " somefile
        > >
        > > where VarName can be substituted for any string that happens to be present in the file to be ediited. Only thing is how do I reference the variable VarName within the start-up macro?
        > >
        > > Any help, much appreciated
        > > Ian
        > >
        >
        > Hi Ian,
        >
        > VarName needs to be a MicroEmacs variable i.e. $foo so you will do:
        >
        > ne -v"$foo=MONTH= " somefile
        >
        > Then in your start-up macro you reference the variable $foo.
        >
        > search-buffer "M" $foo
        >
        > You will need to be careful about how you quote the argument on the command
        > line if there are any special characters or spaces. This will depend on the
        > operating system you are using.
        >
        > Before you test the start-up macro probably best to play with starting the
        > editor with the variable setting on the command line and checking that the
        > variable is coming through correctly with a
        >
        > esc-x describe-variable $foo
        >
        > This will show you the variable value. If it is OK then you can work on the
        > start-up.
        >
        > Regards
        > Jon
        >
        Jon

        thanks for the reply. One question how do I know which variable I can use?

        Ian
      • Jon Green
        ... Hi Ian, You can use any variable that is *NOT* listed in esc-x list-variables These are ME s variables that are used by macros. Also avoid any environment
        Message 3 of 8 , Jan 28, 2011
        • 0 Attachment
          On 28/01/2011 17:36, igcain wrote:
          >
          > --- In jasspa@yahoogroups.com, Jon Green<jon@...> wrote:
          >> On 27/01/2011 20:58, igcain wrote:
          >>> Hi there
          >>>
          >>> I want to invoke the ne editor such that when it starts it goes to a specified line of text ready for over typing. My start-up macro in ne.emf looks something like;
          >>>
          >>> define-macro start-up
          >>> 19 buffer-mode "over"
          >>> !force search-buffer "M" "MONTH= "
          >>> end-of-line
          >>> !macro
          >>>
          >>> unfortunately my start-up macro (as currently written) only ever goes to the string constant "MONTH= ". But what I really would like to do is execute the command line with;
          >>>
          >>> ne -vVarName="MONTH= " somefile
          >>>
          >>> where VarName can be substituted for any string that happens to be present in the file to be ediited. Only thing is how do I reference the variable VarName within the start-up macro?
          >>>
          >>> Any help, much appreciated
          >>> Ian
          >>>
          >> Hi Ian,
          >>
          >> VarName needs to be a MicroEmacs variable i.e. $foo so you will do:
          >>
          >> ne -v"$foo=MONTH= " somefile
          >>
          >> Then in your start-up macro you reference the variable $foo.
          >>
          >> search-buffer "M" $foo
          >>
          >> You will need to be careful about how you quote the argument on the command
          >> line if there are any special characters or spaces. This will depend on the
          >> operating system you are using.
          >>
          >> Before you test the start-up macro probably best to play with starting the
          >> editor with the variable setting on the command line and checking that the
          >> variable is coming through correctly with a
          >>
          >> esc-x describe-variable $foo
          >>
          >> This will show you the variable value. If it is OK then you can work on the
          >> start-up.
          >>
          >> Regards
          >> Jon
          >>
          > Jon
          >
          > thanks for the reply. One question how do I know which variable I can use?
          >
          > Ian
          >
          Hi Ian,

          You can use any variable that is *NOT* listed in

          esc-x list-variables

          These are ME's variables that are used by macros.
          Also avoid any environment variable (i.e. $DISPLAY as used on UNIX).

          So something like $arg1 would be a sensible choice i.e.
          -v$arg1=This -v$arg2=and -v$arg3=that

          Regards
          Jon.
        • igcain
          ... Thanks for the advice Jon. Unfortunately $arg1 doesn t work all I get is arg1: Undefined variable when I use the command line ne -v$arg1= Hello
          Message 4 of 8 , Jan 29, 2011
          • 0 Attachment
            --- In jasspa@yahoogroups.com, Jon Green <jon@...> wrote:
            >
            > On 28/01/2011 17:36, igcain wrote:
            > >
            > > --- In jasspa@yahoogroups.com, Jon Green<jon@> wrote:
            > >> On 27/01/2011 20:58, igcain wrote:
            > >>> Hi there
            > >>>
            > >>> I want to invoke the ne editor such that when it starts it goes to a specified line of text ready for over typing. My start-up macro in ne.emf looks something like;
            > >>>
            > >>> define-macro start-up
            > >>> 19 buffer-mode "over"
            > >>> !force search-buffer "M" "MONTH= "
            > >>> end-of-line
            > >>> !macro
            > >>>
            > >>> unfortunately my start-up macro (as currently written) only ever goes to the string constant "MONTH= ". But what I really would like to do is execute the command line with;
            > >>>
            > >>> ne -vVarName="MONTH= " somefile
            > >>>
            > >>> where VarName can be substituted for any string that happens to be present in the file to be ediited. Only thing is how do I reference the variable VarName within the start-up macro?
            > >>>
            > >>> Any help, much appreciated
            > >>> Ian
            > >>>
            > >> Hi Ian,
            > >>
            > >> VarName needs to be a MicroEmacs variable i.e. $foo so you will do:
            > >>
            > >> ne -v"$foo=MONTH= " somefile
            > >>
            > >> Then in your start-up macro you reference the variable $foo.
            > >>
            > >> search-buffer "M" $foo
            > >>
            > >> You will need to be careful about how you quote the argument on the command
            > >> line if there are any special characters or spaces. This will depend on the
            > >> operating system you are using.
            > >>
            > >> Before you test the start-up macro probably best to play with starting the
            > >> editor with the variable setting on the command line and checking that the
            > >> variable is coming through correctly with a
            > >>
            > >> esc-x describe-variable $foo
            > >>
            > >> This will show you the variable value. If it is OK then you can work on the
            > >> start-up.
            > >>
            > >> Regards
            > >> Jon
            > >>
            > > Jon
            > >
            > > thanks for the reply. One question how do I know which variable I can use?
            > >
            > > Ian
            > >
            > Hi Ian,
            >
            > You can use any variable that is *NOT* listed in
            >
            > esc-x list-variables
            >
            > These are ME's variables that are used by macros.
            > Also avoid any environment variable (i.e. $DISPLAY as used on UNIX).
            >
            > So something like $arg1 would be a sensible choice i.e.
            > -v$arg1=This -v$arg2=and -v$arg3=that
            >
            > Regards
            > Jon.
            >
            Thanks for the advice Jon. Unfortunately $arg1 doesn't work all I get is "arg1: Undefined variable" when I use the command line
            ne -v$arg1="Hello" greeting.dat

            Do you think the fact I am using nanoEmacs is an issue?
          • Jon Green
            ... Hi Ian, Should not be a problem. Problem is what O/S you are running. So I am running on Sun Solaris at the moment and I can do: orac% ne -v $arg1=Hello
            Message 5 of 8 , Jan 29, 2011
            • 0 Attachment
              On 29/01/2011 09:58, igcain wrote:
              >
              >
              > --- In jasspa@yahoogroups.com, Jon Green<jon@...> wrote:
              >>
              >> On 28/01/2011 17:36, igcain wrote:
              >>>
              >>> --- In jasspa@yahoogroups.com, Jon Green<jon@> wrote:
              >>>> On 27/01/2011 20:58, igcain wrote:
              >>>>> Hi there
              >>>>>
              >>>>> I want to invoke the ne editor such that when it starts it goes to a specified line of text ready for over typing. My start-up macro in ne.emf looks something like;
              >>>>>
              >>>>> define-macro start-up
              >>>>> 19 buffer-mode "over"
              >>>>> !force search-buffer "M" "MONTH= "
              >>>>> end-of-line
              >>>>> !macro
              >>>>>
              >>>>> unfortunately my start-up macro (as currently written) only ever goes to the string constant "MONTH= ". But what I really would like to do is execute the command line with;
              >>>>>
              >>>>> ne -vVarName="MONTH= " somefile
              >>>>>
              >>>>> where VarName can be substituted for any string that happens to be present in the file to be ediited. Only thing is how do I reference the variable VarName within the start-up macro?
              >>>>>
              >>>>> Any help, much appreciated
              >>>>> Ian
              >>>>>
              >>>> Hi Ian,
              >>>>
              >>>> VarName needs to be a MicroEmacs variable i.e. $foo so you will do:
              >>>>
              >>>> ne -v"$foo=MONTH= " somefile
              >>>>
              >>>> Then in your start-up macro you reference the variable $foo.
              >>>>
              >>>> search-buffer "M" $foo
              >>>>
              >>>> You will need to be careful about how you quote the argument on the command
              >>>> line if there are any special characters or spaces. This will depend on the
              >>>> operating system you are using.
              >>>>
              >>>> Before you test the start-up macro probably best to play with starting the
              >>>> editor with the variable setting on the command line and checking that the
              >>>> variable is coming through correctly with a
              >>>>
              >>>> esc-x describe-variable $foo
              >>>>
              >>>> This will show you the variable value. If it is OK then you can work on the
              >>>> start-up.
              >>>>
              >>>> Regards
              >>>> Jon
              >>>>
              >>> Jon
              >>>
              >>> thanks for the reply. One question how do I know which variable I can use?
              >>>
              >>> Ian
              >>>
              >> Hi Ian,
              >>
              >> You can use any variable that is *NOT* listed in
              >>
              >> esc-x list-variables
              >>
              >> These are ME's variables that are used by macros.
              >> Also avoid any environment variable (i.e. $DISPLAY as used on UNIX).
              >>
              >> So something like $arg1 would be a sensible choice i.e.
              >> -v$arg1=This -v$arg2=and -v$arg3=that
              >>
              >> Regards
              >> Jon.
              >>
              > Thanks for the advice Jon. Unfortunately $arg1 doesn't work all I get is "arg1: Undefined variable" when I use the command line
              > ne -v$arg1="Hello" greeting.dat
              >
              > Do you think the fact I am using nanoEmacs is an issue?
              >

              Hi Ian,

              Should not be a problem. Problem is what O/S you are running.
              So I am running on Sun Solaris at the moment and I can do:

              orac% ne -v'$arg1=Hello'

              ne runs up as normal

              Then I can do a

              esc-x describe-variable $arg1

              and it is says "Hello" which is what I expect because that is what I passed.

              On UNIX then I have to protect the $arg1 from the shell (zsh in my case) so I
              have protected it with single quotes which stops the shell from expanding it.

              If I do *NOT* quote it then the command shell complains i.e.

              orac% ne -v$arg1=Hello
              ne Error: Cannot set variable [] from the command-line

              My best guess is that this is probably what you are seeing. So I think you are
              currently fighting with your command shell and not ne. Protect the string with
              a single quote pair (on UNIX/Linux/BSD), possibly it is a double quotes pair on
              Windows (do not quote me on Windows as I am not an expert and a infrequent user).

              I have to admit that I do not use "ne" at all now as it does not carry all of
              the baggage that I need, specifically the directory listing stuff. The only
              time I have really used ne in the past is in bringing up systems where I need
              an editor quickly and can FTP/HTTP the image onto the machine or where I need
              to admin a system but do not want to install any packages. Given that disk
              space memory is not such a problem these days then I much prefer the fully
              featured "me" with UK/US spelling dictionaries installed and use the Zero
              install image (http://www.jasspa.com/zeroinst.html) with a customised macro
              file bundle which includes the spelling dictionaries and my extended file
              template macros. The end result is that the file is much bigger but I still
              have a single executable image "me" that I do not need to install and can just
              run. Even on something like the EEE-PC where disk space is tight then I still
              find the zero install image better. On such a space constrained device it uses
              a much smaller footprint than a standard me install with the macro files
              individually separately installed because the archive extension uses
              compression and you do not suffer from the disk block size losses of each
              individual small file.

              Regards
              Jon.
            • igcain
              ... Jon The single quotes did it! (can t think why I hadn t tried that before) Thanks for all the help. Ian
              Message 6 of 8 , Jan 30, 2011
              • 0 Attachment
                --- In jasspa@yahoogroups.com, Jon Green <jon@...> wrote:
                >
                > On 29/01/2011 09:58, igcain wrote:
                > >
                > >
                > > --- In jasspa@yahoogroups.com, Jon Green<jon@> wrote:
                > >>
                > >> On 28/01/2011 17:36, igcain wrote:
                > >>>
                > >>> --- In jasspa@yahoogroups.com, Jon Green<jon@> wrote:
                > >>>> On 27/01/2011 20:58, igcain wrote:
                > >>>>> Hi there
                > >>>>>
                > >>>>> I want to invoke the ne editor such that when it starts it goes to a specified line of text ready for over typing. My start-up macro in ne.emf looks something like;
                > >>>>>
                > >>>>> define-macro start-up
                > >>>>> 19 buffer-mode "over"
                > >>>>> !force search-buffer "M" "MONTH= "
                > >>>>> end-of-line
                > >>>>> !macro
                > >>>>>
                > >>>>> unfortunately my start-up macro (as currently written) only ever goes to the string constant "MONTH= ". But what I really would like to do is execute the command line with;
                > >>>>>
                > >>>>> ne -vVarName="MONTH= " somefile
                > >>>>>
                > >>>>> where VarName can be substituted for any string that happens to be present in the file to be ediited. Only thing is how do I reference the variable VarName within the start-up macro?
                > >>>>>
                > >>>>> Any help, much appreciated
                > >>>>> Ian
                > >>>>>
                > >>>> Hi Ian,
                > >>>>
                > >>>> VarName needs to be a MicroEmacs variable i.e. $foo so you will do:
                > >>>>
                > >>>> ne -v"$foo=MONTH= " somefile
                > >>>>
                > >>>> Then in your start-up macro you reference the variable $foo.
                > >>>>
                > >>>> search-buffer "M" $foo
                > >>>>
                > >>>> You will need to be careful about how you quote the argument on the command
                > >>>> line if there are any special characters or spaces. This will depend on the
                > >>>> operating system you are using.
                > >>>>
                > >>>> Before you test the start-up macro probably best to play with starting the
                > >>>> editor with the variable setting on the command line and checking that the
                > >>>> variable is coming through correctly with a
                > >>>>
                > >>>> esc-x describe-variable $foo
                > >>>>
                > >>>> This will show you the variable value. If it is OK then you can work on the
                > >>>> start-up.
                > >>>>
                > >>>> Regards
                > >>>> Jon
                > >>>>
                > >>> Jon
                > >>>
                > >>> thanks for the reply. One question how do I know which variable I can use?
                > >>>
                > >>> Ian
                > >>>
                > >> Hi Ian,
                > >>
                > >> You can use any variable that is *NOT* listed in
                > >>
                > >> esc-x list-variables
                > >>
                > >> These are ME's variables that are used by macros.
                > >> Also avoid any environment variable (i.e. $DISPLAY as used on UNIX).
                > >>
                > >> So something like $arg1 would be a sensible choice i.e.
                > >> -v$arg1=This -v$arg2=and -v$arg3=that
                > >>
                > >> Regards
                > >> Jon.
                > >>
                > > Thanks for the advice Jon. Unfortunately $arg1 doesn't work all I get is "arg1: Undefined variable" when I use the command line
                > > ne -v$arg1="Hello" greeting.dat
                > >
                > > Do you think the fact I am using nanoEmacs is an issue?
                > >
                >
                > Hi Ian,
                >
                > Should not be a problem. Problem is what O/S you are running.
                > So I am running on Sun Solaris at the moment and I can do:
                >
                > orac% ne -v'$arg1=Hello'
                >
                > ne runs up as normal
                >
                > Then I can do a
                >
                > esc-x describe-variable $arg1
                >
                > and it is says "Hello" which is what I expect because that is what I passed.
                >
                > On UNIX then I have to protect the $arg1 from the shell (zsh in my case) so I
                > have protected it with single quotes which stops the shell from expanding it.
                >
                > If I do *NOT* quote it then the command shell complains i.e.
                >
                > orac% ne -v$arg1=Hello
                > ne Error: Cannot set variable [] from the command-line
                >
                > My best guess is that this is probably what you are seeing. So I think you are
                > currently fighting with your command shell and not ne. Protect the string with
                > a single quote pair (on UNIX/Linux/BSD), possibly it is a double quotes pair on
                > Windows (do not quote me on Windows as I am not an expert and a infrequent user).
                >
                > I have to admit that I do not use "ne" at all now as it does not carry all of
                > the baggage that I need, specifically the directory listing stuff. The only
                > time I have really used ne in the past is in bringing up systems where I need
                > an editor quickly and can FTP/HTTP the image onto the machine or where I need
                > to admin a system but do not want to install any packages. Given that disk
                > space memory is not such a problem these days then I much prefer the fully
                > featured "me" with UK/US spelling dictionaries installed and use the Zero
                > install image (http://www.jasspa.com/zeroinst.html) with a customised macro
                > file bundle which includes the spelling dictionaries and my extended file
                > template macros. The end result is that the file is much bigger but I still
                > have a single executable image "me" that I do not need to install and can just
                > run. Even on something like the EEE-PC where disk space is tight then I still
                > find the zero install image better. On such a space constrained device it uses
                > a much smaller footprint than a standard me install with the macro files
                > individually separately installed because the archive extension uses
                > compression and you do not suffer from the disk block size losses of each
                > individual small file.
                >
                > Regards
                > Jon.
                >
                Jon

                The single quotes did it! (can't think why I hadn't tried that before)

                Thanks for all the help.

                Ian
              Your message has been successfully submitted and would be delivered to recipients shortly.