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

20589[Clip] Re: Clipboard boilerplate for cn_le

Expand Messages
  • diodeom
    Apr 20, 2010
      loro <tabbie@...> wrote:
      > Since you like it you may want a clip I removed when I posted it
      > before. It pasts all collected snips in a new document. I find it
      > easier to remove unwanted snip-clips and then paste it all than the
      > other way around.

      Here's yet another approach to agglomerate all processed clippings:

      H="Paste all"
      ^!Menu File/New
      ^!InsertFile ^$GetLibraryFileName$
      ^!Replace "(?s).+?^H\=";Text.+?\R+" >> "" WRS
      ^!Replace "(\R)?\K(?(1)\R+)^H\=.++\R+" >> "---------------\r\n" WARS

      But for my needs, to selectively remove from the library either already distributed clips or any junk ones, I found this (working-for-me rough draft) more practical:

      H="Remove selected clips"
      ^!Open "^$GetLibraryFileName$" /J=-1
      ^!Set %bot%=^$GetRow$:^$GetCol$
      ^!Find "^H\=";Text.++\R\K" WRS
      ^!SelectTo ^%bot%
      ^!SetListDelimiter |
      ^!Set %del%=^$GetDocMatchAll("^H\=\"\K(.+?)(?=\"$)")$
      ^!SetArray %del%=^?{(T=A;H=50)=^%del%}
      ^!Set %n%=0
      ^!Inc %n%
      ^!If ^%n%>^%del0% Done
      ;Long line start
      ^!Replace "\R\R\K\R*^H\=\"\Q^%del^%n%%\E\"$(?s).+?(?=(^H\=\"|\R*\Z))" >> "" WRS
      ;Long line end
      ^!Goto Del
      ^!Replace "\R+\Z" >> "\r\n" WRS
      ^!Close Save
      ^!ClearVariable %bot%
      ^!ClearVariable %del%
      ^!ClearVariable %n%

      A word of caution: the patterns here look for capitalized "H" for headers, not lowercase like in your original OnClipboardChange clip.

      And I omitted provisions for headers not being unique. I'd opt for not permitting duplicate names right when clippings are created and processed (in my case quite extensively). Also, some executable clip code in headers can mess things up (I'm speaking from regretable experience :) -- unless similarly addressed beforehand.
    • Show all 24 messages in this topic