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

Re: Smart Home Macro

Expand Messages
  • cp200205
    I made the macro more complex than necessary. Below is a simpler version with a few qwirks fixed... ==== BEGIN ==== ; Go to the first non-blank character on
    Message 1 of 5 , May 6, 2011
    • 0 Attachment
      I made the macro more complex than necessary. Below is a simpler version with a few qwirks fixed...

      ==== BEGIN ====
      ; Go to the first non-blank character on the current line. If already there,
      ; go to column 1
      define-macro smart-home
      set-variable #l0 $window-acol

      beginning-of-line

      !while &sin @wc " \t"
      !force forward-char
      !done

      !if &equal $window-acol #l0
      beginning-of-line
      !end
      !emacro
      ==== END ====

      You can get the updated version on my github repo with other items as well, https://github.com/jcowgar/dotmicroemacs

      Jeremy
    • vae_ik
      Hi There is a macro with such functionality in MicroEmacs distribution already. Look for contrib/bol_eol.emf Regards Ilija
      Message 2 of 5 , May 9, 2011
      • 0 Attachment
        Hi

        There is a macro with such functionality in MicroEmacs distribution already. Look for contrib/bol_eol.emf

        Regards
        Ilija



        --- In jasspa@yahoogroups.com, "cp200205" <jeremy@...> wrote:
        >
        > I just wrote a smart home macro. When executing it will move the cursor to the first non-blank location in the current line. If the cursor was already there, however, it then moves the cursor to the first column. An example, assuming . is leading space and ^ is the cursor:
        >
        > ....John^Doe : execute smart-home and it will become:
        > ....^John Doe : execute smart-home again and it becomes:
        > ^....John Doe : execute again and it becomes:
        > ....^John Doe : each hit cycles between the two locations.
        >
        > The source is included here and also available from my dotmicroemacs github repo (as well as other macros and my configs): https://github.com/jcowgar/dotmicroemacs
        >
        > ======== BEGIN ========
        > ; Go to the first non-blank character on the current line. If already there,
        > ; go to column 1
        > define-macro smart-home
        > set-variable #l1 $window-acol
        >
        > beginning-of-line
        >
        > !repeat
        > !force forward-char
        > !if $status
        > !if ¬ &sin @wc " \t"
        > set-variable #l0 1
        > !endif
        > !else
        > set-variable #l0 1
        > !endif
        > !until #l0
        >
        > !if &equal $window-acol #l1
        > beginning-of-line
        > !end
        > !emacro
        > global-bind-key smart-home "home"
        > ======== END ========
        >
        > Jeremy Cowgar
        > http://jeremy.cowgar.com
        >
      • cp200205
        Opps :-/ Didn t intentionally reinvent the wheel. Jeremy
        Message 3 of 5 , May 12, 2011
        • 0 Attachment
          Opps :-/ Didn't intentionally reinvent the wheel.

          Jeremy

          --- In jasspa@yahoogroups.com, "vae_ik" <ilijak@...> wrote:
          >
          >
          > Hi
          >
          > There is a macro with such functionality in MicroEmacs distribution already. Look for contrib/bol_eol.emf
          >
        • vae_ik
          ... Better two than nill. And even simple, it a good exercise. As for reinventing, I have reinvented it twice: 1st in C, then as a macro. cheers Ilija
          Message 4 of 5 , May 12, 2011
          • 0 Attachment
            --- In jasspa@yahoogroups.com, "cp200205" <jeremy@...> wrote:
            >
            > Opps :-/ Didn't intentionally reinvent the wheel.

            Better two than nill. And even simple, it'a good exercise.
            As for reinventing, I have reinvented it twice: 1st in C, then as a macro.

            cheers
            Ilija


            >
            > Jeremy
            >
            > --- In jasspa@yahoogroups.com, "vae_ik" <ilijak@> wrote:
            > >
            > >
            > > Hi
            > >
            > > There is a macro with such functionality in MicroEmacs distribution already. Look for contrib/bol_eol.emf
            > >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.