2018-03-09 ___E_d_i_t_i_n_g__g_o_p_h_e_r__p_o_s_t_s__w_i_t_h__s_a_m_____________ As I have written yesterday[0], I like to use the sam editor for editing files on my machines. Sam is really an ed(1) instance on steroids as it features a powerful command language while providing a graphical interface and it is really really fast with a lot of open files. Until today I have totally neglected another neat feature of sam: remote editing. This works like this: sam is split between an editor part (sam) and a terminal frontend (samterm). Both communicate via a simple unix domain socket. This socket can be created by a small wrapper program forwarding everything through ssh(1) to a sam instance running on another host. And that's how I edit this post now. It also enables me to run shell commands etc completely within this simple editor. So I have fired up my script for creating a new file template, edit, save and then I call the publishing script. That the terminal is separate from the instance doing all the file I/O is convenient for laggy connections too. I have to have a deeper look into the source code to understand the wire protocol! Note that there are incompatibilities within sam versions around, so if you want to try this for yourself make sure that the sam versions on both sides match. Also make sure that sam is in your path... A quick primer to sam: The white window is the command window. You can open files there with 'B filename', write with 'w', undo with 'u' (unlimited undo!) and quit with 'q'. In deadpixie's fork CTRL-K switches focus from the command window to the text window so that saves you reaching for the mouse for simple commands. For advanced editing (I am still getting comfortable with it myself) see the sam cheatsheet[1]. The entries get formatted with selecting the text body and issuing the command '|fmt -w 69' in the command window. That pipes the selection to the external command and replaces the connection with the output of said command. There is so much more to be said about sam. But there are better descriptions around: The paper[2] and a tutorial[3]. ___References________________________________________________________ [0]: gopher://vernunftzentrum.de/0/ckeen/phlog/2018-03-08-A-mixed-bag-of-random-improvements.md [1]: http://sam.cat-v.org/cheatsheet/sam-refcard.pdf [2]: http://doc.cat-v.org/plan_9/4th_edition/papers/sam/ [3]: http://doc.cat-v.org/bell_labs/sam_lang_tutorial/sam_tut.pdf