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

Re: [jasspa] How can I insert a time mark

Expand Messages
  • Thomas Hundt
    Yes. Note that the &add function takes two parameters, so there s no way it would have worked had it not been wrapped. -Th
    Message 1 of 9 , May 23, 2005
      Yes. Note that the &add function takes two parameters, so there's no
      way it would have worked had it not been wrapped.

      -Th



      > Short question: The line marked with ** ...is this a wrap around of
      > the previous line ?

      >> insert-string &mid "JanFebMarAprMayJunJulAugSepOctNovDec" &add 0
      > **> &mul 3 &sub &mid $time 7 2 1 3 ; MMM
    • Meino Christian Cramer
      From: Thomas Hundt Subject: Re: [jasspa] How can I insert a time mark Date: Mon, 23 May 2005 10:04:20 -0700 Hi Thomas! Short question to one
      Message 2 of 9 , May 23, 2005
        From: Thomas Hundt <thundt@...>
        Subject: Re: [jasspa] How can I insert a time mark
        Date: Mon, 23 May 2005 10:04:20 -0700

        Hi Thomas!

        Short question to one line of your macro:

        The line
        insert-string &add 0 &mid $time 9 1 ; make space into '0'
        inserts a "0" to make a "05" of the " 5"...but what happens if
        it is Christmas? Will I get "02" from "12" then? Or i sthere any
        magic I currently do not understand?

        (NO! cristism...I am only curious whether I understand the code right...)

        Keep microemacsing!
        Meino



        > Here's an example of a function to insert a date, in format 22-May-05.
        > Maybe it will get you started:
        >
        > ;------------------------------------------------------------
        > ; insert-date: as 01-Oct-99
        > ;------------------------------------------------------------
        > define-macro insert-date
        > insert-string &add 0 &mid $time 9 1 ; make space into '0'
        > insert-string &mid $time 10 1
        > insert-string "-"
        > insert-string &mid "JanFebMarAprMayJunJulAugSepOctNovDec" &add 0
        > &mul 3 &sub &mid $time 7 2 1 3 ; MMM
        > insert-string "-"
        > insert-string &mid $time 2 2 ; YY
        > !emacro ; insert-date
        > global-bind-key insert-date "esc @"
        >
        >
        >
        >
        > Jon Green wrote:
        > > Meino Christian Cramer wrote:
        > >
        > >>Hi,
        > >>
        > >> may be this is a rsq(tm) [real simple question ], but...
        > >>
        > >> I just want a macro to insert the string, a time mark,
        > >>
        > >>
        > >> /* CHANGED <YYYY-MM-DD:hhmmss, _mcc> */
        > >>
        > >> into a C source file at the place, where the cursor is.
        > >>
        > >> But....
        > >>
        > >>
        > >> I got very funny things like
        > >>
        > >>
        > >> /* CHANGED <$timestamp, _mcc> */
        > >>
        > >> ...
        > >>
        > >>
        > >> Any hint is very appreciated :)
        > >>
        > >> Happy microemacsing!
        > >> Meino
        > >>
        > >>
        > >
        > >
        > > I assume that you are writing a macro. Note that $timestamp defines
        > > the automatic time stamp search string and does not contain the time.
        > > See insdate.emf (a bit hairy) for something that constructs the time
        > > string in an appropriate format using $time(5).
        > >
        > > Guess is that you did:-
        > >
        > > insert-string "$timestamp"
        > >
        > > rather than
        > >
        > > insert-string $timestamp
        > >
        > > i.e. you inserted a literal string rather than the value. Both of which
        > > are wrong if you actually want the time. Extract the components of time
        > > from $time using &lef/&rig/&mid and then use &spr to form the string
        > > ready for insert-string.
        > >
        > > Jon.
        > >
        > >
        > > __________________________________________________________________________
        > >
        > > 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
        > >
        > >
        > >
        > >
        > >
        >
        > --
        > Thomas Hundt <tom@...> +1-415-867-6698
        >
        >
        > __________________________________________________________________________
        >
        > 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
        >
        >
        >
        >
        >
        >
      • Jon Green
        ... &mid $time 9 1 is the MSB of the day ( D ) not month ( M ) in YYYYCCCMMDD. Character 0 is the first character in &mid i.e. &mid 0 1 = Y &mid 1 1 = Y
        Message 3 of 9 , May 23, 2005
          Meino Christian Cramer wrote:
          > From: Thomas Hundt <thundt@...>
          > Subject: Re: [jasspa] How can I insert a time mark
          > Date: Mon, 23 May 2005 10:04:20 -0700
          >
          > Hi Thomas!
          >
          > Short question to one line of your macro:
          >
          > The line
          > insert-string &add 0 &mid $time 9 1 ; make space into '0'
          > inserts a "0" to make a "05" of the " 5"...but what happens if
          > it is Christmas? Will I get "02" from "12" then? Or i sthere any
          > magic I currently do not understand?

          &mid $time 9 1 is the MSB of the day ("D") not month ("M") in
          YYYYCCCMMDD. Character 0 is the first character in &mid i.e.

          &mid 0 1 = "Y"
          &mid 1 1 = "Y"
          &mid 2 1 = "Y"
          &mid 3 1 = "Y"
          &mid 4 1 = "C"
          &mid 5 1 = "C"
          &mid 6 1 = "C"
          &mid 7 1 = "M"
          &mid 8 1 = "M"
          &mid 9 1 = "D"
          &mid 10 1 = "D"
          etc.

          Also note

          &mid 0 4 = "YYYY"
          &mid 4 3 = "CCC"
          &mid 7 2 = "MM"
          &mid 9 2 = "DD"

          >
          > (NO! cristism...I am only curious whether I understand the code right...)
          >

          Thomas has been rather clever here. Using &add then he has basically
          turned a character into a number. &add is a math operation therefore
          will only accept digits, if you give it a letter then you get 0 (or
          FALSE). To understand this then put the following in your *scratch*
          buffer and execute it (M-x execute-buffer):-

          2000 ml-write &spr "%d" "a"

          What you get one the mode line is '0' because %d wants a digit and has
          got an 'a' which is tuned into zero. So going back to your question....

          If "&mid $time 9 1" == " " (space) then you get

          &add 0 " "

          which is "0"

          If "&mid $time 9 1" == "1" then you get

          &add 0 "1"

          which is "1"

          Very nice - probably why he added the comment to point out this trick.



          To play with &mid in *scratch* could execute the following (DD is the
          result):-

          2000 ml-write &spr "%s" &mid "YYYYCCCMMDD" 9 2


          Jon.
          > Keep microemacsing!
          > Meino
        • Meino Christian Cramer
          From: Jon Green Subject: Re: [jasspa] How can I insert a time mark Date: Mon, 23 May 2005 19:35:01 +0100 Hi Jon, Thanky A LOT for this
          Message 4 of 9 , May 23, 2005
            From: Jon Green <jnaught@...>
            Subject: Re: [jasspa] How can I insert a time mark
            Date: Mon, 23 May 2005 19:35:01 +0100

            Hi Jon,

            Thanky A LOT for this explanations!
            Thats clarifies much...

            Have a nice day!
            Keep microemacsing! :)
            Meino

            > Meino Christian Cramer wrote:
            > > From: Thomas Hundt <thundt@...>
            > > Subject: Re: [jasspa] How can I insert a time mark
            > > Date: Mon, 23 May 2005 10:04:20 -0700
            > >
            > > Hi Thomas!
            > >
            > > Short question to one line of your macro:
            > >
            > > The line
            > > insert-string &add 0 &mid $time 9 1 ; make space into '0'
            > > inserts a "0" to make a "05" of the " 5"...but what happens if
            > > it is Christmas? Will I get "02" from "12" then? Or i sthere any
            > > magic I currently do not understand?
            >
            > &mid $time 9 1 is the MSB of the day ("D") not month ("M") in
            > YYYYCCCMMDD. Character 0 is the first character in &mid i.e.
            >
            > &mid 0 1 = "Y"
            > &mid 1 1 = "Y"
            > &mid 2 1 = "Y"
            > &mid 3 1 = "Y"
            > &mid 4 1 = "C"
            > &mid 5 1 = "C"
            > &mid 6 1 = "C"
            > &mid 7 1 = "M"
            > &mid 8 1 = "M"
            > &mid 9 1 = "D"
            > &mid 10 1 = "D"
            > etc.
            >
            > Also note
            >
            > &mid 0 4 = "YYYY"
            > &mid 4 3 = "CCC"
            > &mid 7 2 = "MM"
            > &mid 9 2 = "DD"
            >
            > >
            > > (NO! cristism...I am only curious whether I understand the code right...)
            > >
            >
            > Thomas has been rather clever here. Using &add then he has basically
            > turned a character into a number. &add is a math operation therefore
            > will only accept digits, if you give it a letter then you get 0 (or
            > FALSE). To understand this then put the following in your *scratch*
            > buffer and execute it (M-x execute-buffer):-
            >
            > 2000 ml-write &spr "%d" "a"
            >
            > What you get one the mode line is '0' because %d wants a digit and has
            > got an 'a' which is tuned into zero. So going back to your question....
            >
            > If "&mid $time 9 1" == " " (space) then you get
            >
            > &add 0 " "
            >
            > which is "0"
            >
            > If "&mid $time 9 1" == "1" then you get
            >
            > &add 0 "1"
            >
            > which is "1"
            >
            > Very nice - probably why he added the comment to point out this trick.
            >
            >
            >
            > To play with &mid in *scratch* could execute the following (DD is the
            > result):-
            >
            > 2000 ml-write &spr "%s" &mid "YYYYCCCMMDD" 9 2
            >
            >
            > Jon.
            > > Keep microemacsing!
            > > Meino
            >
            >
            > __________________________________________________________________________
            >
            > 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
            >
            >
            >
            >
            >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.