% -*- mode: slang; mode: fold; -*- #ifdef macro_description %{{{ [ pgpsign.sl v0.2 (15 Nov 2000) by Tomasz Sienicki, tsca@mailserver.dk ] [ see more @ http://www.geocities.com/tsca.geo/slang.html ] Usage: Save this file as 'pgpsign.sl' to /usr/lib/jed/lib/ (or wherever you store jed macros) and add the following to '.slrnrc': () = evalfile ("pgpsign.sl"); setkey ("pgp_sign (0)","\en"); setkey ("pgp_sign (1)","\e\en"); When editing a file you want to sign, mark a region and press ; if you want to sign the whole buffer, press . #endif %}}} define pgp_sign(all) { variable myprg = "gpg" , % Do you use "pgp" or "gpg"? tmpfile = "/tmp/jedpgptemp", % Where do you want to save temporary files? % YOU DO NEED TO CHANGE ANYTHING BELOW THIS LINE %{{{ % -------------------------------------------------------------------------- % %%%% pk,kk,cmd,pcommand=""; % is program defined? %{{{ if (myprg == "gpg") { pcommand = "gpg --clearsign " ;} if (myprg == "pgp") { pcommand = "pgps -t " ;} if (pcommand == "") { error("PGP program undefined!");} % %}}} !if(all) { !if(is_visible_mark) { error ("No region to sign highlighted! "+ "Use to sign the whole buffer.");} pk=create_user_mark(); pop_mark(); kk=create_user_mark(); } else { bob(); pk=create_user_mark(); eob();kk=create_user_mark(); } goto_user_mark(pk);set_mark_cmd();goto_user_mark(kk); write_region_to_file(tmpfile); goto_user_mark(pk);set_mark_cmd();goto_user_mark(kk);del_region(); % (c) remark: % 'stty' options used in 2 following lines are taken from some code by % Ulli "Framstag" Horlacher's cmd="stty opost icrnl;" +pcommand+tmpfile+";"+ "echo press ENTER; read dummy;stty -opost -icrnl"; % -- Danke schön. ;-) system("rm -f "+tmpfile+".asc; "+cmd); bol();insert_file(tmpfile+".asc");call("redraw");message("Region signed."); } % -- END OF MACRO ----------------------------------------------------- %}}}