LQWiki trick cnee macro to launch preview from emacs


 * Edit your wiki articles in emacs and press F12 from there to launch a preview.

=The core of it=

If you like to edit wiki code in your favorite text editor you will find that manually copy-pasting from your text editor to the LQWiki edition box each time you want to get a preview can be very tedious and time consuming. This trick allows you to do all the required operations to get a preview by just pressing the F12 function key.

This is how you would do your wiki editing in emacs ( you can of course easily adapt the cnee macro to make it work with your favorite text editor ) :


 * 1) You insert the "#############" delimiters to seperate your edits by pressing Ctrl-Return (see define-key definitions).
 * 2) In the LQWiki edition page you do a Alt+, and Ctrl-a and then paste the whole text in emacs with a Ctrl-y.
 * 3) You do some editing...
 * 4) You press F12 to get a fast preview.
 * 5) If the preview is satisfactory you save, if not you go back to some emacs editing.


 * Ctrl-Alt-k copies the text being edited delimited by the "#############" string(s) to the X selection ( to the kill ring too ).

The cnee macro is highly dependent on your working environment since it reproduces low level X events. For instance it will reproduce keycodes, not symbol names, so if your keyboard layout is different from the us one you will probably have to adapt the macro to reflect that, especially for the "," key for instance. The keyboard shortcuts used in the macro will also have to be bound to the same software functions as those of the environment it was intended for.

You have to be a Alt-Tab away from your firefox window, which is displaying the LQWiki editing page of the corresponding article. Be carefull pasting two pages of text in the wrong window ( say a root xterm ) could be a bad idea...

The Firefox window is full screen with a screen resolution of 1280x1024. This can be important if you want the cnee macro to mouse-paste at the right position. Adapt the mouse coordinates in the cnee macro according to your screen configuration.

The F12 key is bound to the "cnee --replay" command thanks to the xbindkeys daemon.

When you press F12, the cnee macro simulates the pressure of the Ctrl-Alt-k key combination, followed by Alt-Tab to get to firefox, then clears the LQWiki edition box, pastes your emacs edited text in it, and launches the preview. This is very fast.

Please give feedback in case of problems.

=Elisp code to put in your .emacs= =Install cnee= =Set up xbindkeys= =Set up the cnee macro=

= How was it recorded? = For your information here is the command that was run to record the initial macro :

beepf=/usr/share/sounds/KDE_Beep_Yo.wav && sleep 7s && play "$beepf" && cnee --record --time 0 --events-to-record 150 --delivered-event-range 2-6 -o ~/tmp/xnee.rec && play "$beepf"

Once done you can end the recording by moving your mouse around to get past the limit of events to record (150) and later delete those extra motion events (MotionNotify=6 in the second column). The last column has of course been edited for better timings, you could also try to change the speed rate by playing with the --speed-percent option ( buggy ? ).

=Other elisp code : Navigate through your edits, kill a whole edit=