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

2638Smart Home Macro

Expand Messages
  • cp200205
    May 5, 2011
    • 0 Attachment
      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
    • Show all 5 messages in this topic