diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9a0a85 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +conf/emacs.d/session* +*~ diff --git a/conf/emacs.d/ac-comphist.dat b/conf/emacs.d/ac-comphist.dat new file mode 100644 index 0000000..b0c2d5b --- /dev/null +++ b/conf/emacs.d/ac-comphist.dat @@ -0,0 +1,1652 @@ +((("run" . + [1 0 0]) + ("league" . + [1 0 0 0 0 3]) + ("underline" . + [0 0 1 0 0 0 0 0 0]) + ("license" . + [2 0 0 0 1 0 0]) + ("Contract" . + [5 0 0 0 0 0 0 2]) + ("ForeignKey" . + [0 0 2 2 1 0 0 0 0 0]) + ("office" . + [7 0 0 0 0 0]) + ("contract" . + [2 0 0 0 0 0 0 0]) + ("office_data" . + [5 0 0 0 0 0 0 0 0 1 0]) + ("max_time" . + [0 0 0 0 0 1 0 0]) + ("min_time" . + [1 0 0 0 0 0 0 0]) + ("max" . + [1 0 0]) + ("5" . + [2]) + ("second" . + [3 0 0 0 0 0]) + ("timedelta" . + [1 0 0 0 0 0 0 0 0]) + ("time" . + [8 0 0 0]) + ("this_day_esteghlal" . + [0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]) + ("esteghlal_data" . + [2 0 0 0 0 0 0 0 0 0 0 0 0 0]) + ("esteghlal" . + [0 0 0 0 0 0 0 0 4]) + ("day" . + [2 0 0]) + ("get_day" . + [2 0 0 0 0 0 1]) + ("contracts" . + [1 0 0 0 0 0 0 0 0]) + ("last_entry" . + [0 0 0 0 0 0 0 0 0 1]) + ("call_counter" . + [1 0 0 0 0 0 0 0 0 0 0 0]) + ("crecord" . + [1 0 0 0 0 0 2]) + ("exclude" . + [1 0 0 0 0 0 0]) + ("converted" . + [0 0 0 0 0 0 0 0 1]) + ("file_" . + [1 0 0 0 0]) + ("EsteglalFileParser" . + [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]) + ("control" . + [1 0 0 0 0 0 0]) + ("convert" . + [1 0 0 0 0 0 0]) + ("File" . + [1 0 0 0]) + ("EsteghlalFile" . + [0 0 0 0 0 0 0 0 0 0 0 0 2]) + ("tbody" . + [1 0 0 0 0]) + ("even" . + [1 0 0 0]) + ("nth-child" . + [0 0 0 1 0 0 0 0 0]) + ("odd" . + [2 0 0]) + ("aaaaac" . + [1 0 0 0 0 0]) + ("thead" . + [3 0 0 0 0]) + ("tr" . + [3 0]) + ("td" . + [3 0]) + ("th" . + [3 0]) + ("800px" . + [1 0 0 0 0]) + ("field_instance" . + [0 0 0 0 0 0 0 0 1 0 0 0 0 0]) + ("field" . + [4 0 0 0 0]) + ("parse_model" . + [1 0 0 0 0 0 0 0 0 0 0]) + ("Form" . + [3 0 0 0]) + ("models_iter" . + [2 0 0 0 0 0 0 0 0 0 0]) + ("iter" . + [3 0 0 0]) + ("ADMINS" . + [1 0 0 0 0 0]) + ("ROOT" . + [1 0 0 0]) + ("CreditForm" . + [0 0 0 0 1 0 0 0 0 0]) + ("text-shadow" . + [0 0 0 0 0 0 1 0 0 0 0]) + ("vertical-align" . + [0 0 0 0 0 0 0 0 0 1 0 0 0 0]) + ("bottom" . + [1 0 0 0 1 0]) + ("150px" . + [2 0 0 0 0]) + ("25px" . + [1 0 0 0]) + ("input" . + [0 0 0 0 1]) + ("300px" . + [1 0 0 0 0]) + ("textarea" . + [0 0 0 0 0 1 0 0]) + ("get_file" . + [1 0 0 0 0 0 0 0]) + ("pool" . + [2 0 0 0]) + ("pkg" . + [1 0 0]) + ("console" . + [1 0 0 0 0 0 0]) + ("Install" . + [1 0 0 0 0 0 0]) + ("global-hl-line-mode" . + [0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]) + ("border-right" . + [2 0 0 0 0 0 0 0 0 0 0 0]) + ("padding-left" . + [0 0 0 0 0 0 0 0 0 0 1 0]) + ("15%" . + [1 0 0]) + ("dddddb" . + [0 0 0 0 0 2]) + ("header" . + [2 0 0 0 0 0]) + ("green" . + [0 0 1 0 0]) + ("1px" . + [11 0 0]) + ("ccccca" . + [0 0 0 0 0 1]) + ("ModelAdmin" . + [0 0 0 0 0 0 1 0 0 0]) + ("Profile" . + [1 0 1 1 0 0 1]) + ("topics" . + [1 0 0 0 0 0]) + ("topic" . + [12 0 0 0 0]) + ("T" . + [5]) + ("Topic" . + [9 0 0 0 0]) + ("forum_index" . + [2 0 0 0 0 0 0 0 0 0 0]) + ("forum" . + [8 0 0 0 0]) + ("BaseCommand" . + [1 0 0 0 0 0 0 1 0 0 0]) + ("panel" . + [1 0 0 0 0]) + ("undefined" . + [0 0 0 0 0 1 0 0 0]) + ("fadeOut" . + [1 0 0 0 0 0 0]) + ("attr" . + [1 0 0 0]) + ("fadeIn" . + [2 0 0 0 0 0]) + ("top" . + [2 0 0]) + ("Button" . + [0 0 0 0 0 1]) + ("taxi" . + [1 0 0 0]) + ("_name" . + [2 0 0 0 0]) + ("Customer" . + [1 0 0 0 0 0 0 0]) + ("osv" . + [2 0 0]) + ("PoC" . + [1 0 0]) + ("cr" . + [1 0]) + ("func_name" . + [0 0 0 0 1 1 1 0 0]) + ("re" . + [1 0]) + ("attrs" . + [2 0 0 0 0]) + ("100" . + [3 0 0]) + ("range" . + [1 0 0 0 0]) + ("commandmark" . + [1 0 0 0 0 0 0 0 1 0 0]) + ("startswith" . + [0 0 0 0 0 0 2 0 0 0]) + ("msg_" . + [1 0 0 0]) + ("ircpass" . + [3 0 0 0 0 0 0]) + ("ircuser" . + [3 0 0 0 0 0 0]) + ("div" . + [1 0 0]) + ("sender" . + [4 0 0 0 0 0]) + ("reactor" . + [0 0 0 0 1 0 0]) + ("LogBot" . + [1 0 0 0 0 0]) + ("pinstance" . + [2 0 0 0 0 0 0 0 0]) + ("factory" . + [1 0 0 0 0 0 0]) + ("tcpfactory" . + [0 0 0 1 0 0 0 0 0 0]) + ("irc" . + [6 0 0]) + ("I" . + [1]) + ("IRC" . + [1 0 0]) + ("bot" . + [1 0 0]) + ("unixfactory" . + [0 0 0 0 1 0 1 0 0 0 0]) + ("Message" . + [1 0 0 1 0 0 0]) + ("Factory" . + [1 0 0 0 0 0 0]) + ("unixsocket" . + [0 0 0 0 0 0 0 0 0 1]) + ("UnixServer" . + [0 0 2 1 0 0 0 0 0 2]) + ("change" . + [2 0 0 0 0 0]) + ("help" . + [0 0 0 1]) + ("language" . + [1 0 0 0 0 0 0 0]) + ("help_text" . + [1 0 0 0 0 3 2 0 1]) + ("40" . + [2 0]) + ("weight" . + [3 0 0 1 0 1]) + ("Member" . + [2 0 0 0 0 1]) + ("MemberDetail" . + [0 0 0 0 0 0 0 1 0 0 0 0]) + ("queryset" . + [0 0 0 0 0 1 0 0]) + ("DetailAdmin" . + [0 0 0 0 0 0 0 1 0 0 0]) + ("member" . + [2 0 0 0 0 0]) + ("creator" . + [1 0 0 0 0 1 0]) + ("loads" . + [1 0 0 0 0]) + ("_obj" . + [1 0 0 0]) + ("traceback" . + [2 0 0 0 0 0 0 0 0]) + ("new_e" . + [1 0 0 0 0]) + ("cPickle" . + [1 0 0 3 2 0 0]) + ("tiny_socket" . + [0 0 0 0 0 0 0 0 0 0 1]) + ("resource" . + [10 0 0 0 0 0 0 0]) + ("protocol" . + [5 0 0 0 0 0 0 1]) + ("release" . + [1 0 0 0 0 0 0]) + ("write" . + [1 0 0 0 0]) + ("group" . + [4 0 0 0 0]) + ("_sock" . + [1 0 0 0 0]) + ("CORBAService" . + [0 0 0 0 0 0 0 0 2 0 0 0]) + ("CORBASession" . + [0 0 0 0 0 0 0 1 0 0 0 0]) + ("sock" . + [6 0 0 0]) + ("execute" . + [4 0 0 0 0 0 0]) + ("res" . + [4 0 0]) + ("passwd" . + [3 0 0 0 0 0]) + ("uname" . + [3 0 0 0 0]) + ("login" . + [2 0 0 0 0]) + ("Execute" . + [1 0 0 0 0 0 0]) + ("_gw" . + [5 0 0]) + ("_protocol" . + [0 0 0 0 2 0 0 0 0]) + ("elif" . + [2 0 0 0]) + ("lst" . + [2 0 0]) + ("Any" . + [1 0 0]) + ("any" . + [2 0 0]) + ("RPCInterface" . + [0 0 0 0 1 0 0 0 0 0 0 0]) + ("TeccoCORBA__POA" . + [0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]) + ("RPC" . + [1 0 0]) + ("TeccoCORBA" . + [0 0 0 0 0 0 0 1 0 0]) + ("msg" . + [15 0 0]) + ("type" . + [8 0 0 0]) + ("example_echo_idl" . + [0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]) + ("corba" . + [1 0 0 0 0]) + ("teccoerp" . + [1 0 0 0 0 0 0 0]) + ("Example__POA" . + [3 0 0 0 0 0 0 0 1 0 0 0]) + ("modules" . + [1 0 0 0 0 0 0]) + ("SAMEER" . + [1 0 0 0 0 0]) + ("cpid" . + [2 0 0 0]) + ("ppid" . + [3 0 0 0]) + ("child" . + [1 0 0 1 0]) + ("last_request" . + [0 0 0 1 0 0 0 0 1 0 0 1]) + ("remote_is_up" . + [1 0 0 0 0 0 0 1 0 0 1 0]) + ("SIGUSR1" . + [1 0 0 0 0 0 0]) + ("remote_reached" . + [0 0 0 0 0 0 0 0 0 1 0 0 0 1]) + ("signal" . + [3 0 0 0 1 0]) + ("remote" . + [1 0 0 0 0 0]) + ("fork_checker_process" . + [0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]) + ("TEXT_DIR_RTL" . + [2 0 0 0 0 0 0 0 0 0 0 0]) + ("Base" . + [1 0 0 0]) + ("gtk" . + [3 0 0]) + ("pygtk" . + [0 0 0 0 1]) + ("methodname" . + [1 0 0 0 0 0 0 0 0 1]) + ("functionPath" . + [0 0 0 0 1 0 1 0 1 0 0 0]) + ("headerName" . + [1 0 0 0 0 0 0 0 0 0]) + ("shutdown" . + [1 0 0 0 0 0 0 0]) + ("data1" . + [1 0 0 0 0]) + ("2048" . + [2 0 0 0]) + ("8" . + [1]) + ("break" . + [1 0 0 0 0]) + ("close" . + [1 0 0 0 0]) + ("conn" . + [4 0 0 0]) + ("recv" . + [3 0 0 0]) + ("SHOST" . + [1 0 0 0 0]) + ("client" . + [7 0 0 0 0 0]) + ("CHOST" . + [1 0 0 0 0]) + ("8070" . + [2 0 0 0]) + ("10" . + [3 0]) + ("socket" . + [3 0 0 0 0 0]) + ("with-current-buffer" . + [0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]) + ("set-text-properties" . + [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]) + ("start-process-shell-command" . + [0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]) + ("switch-to-buffer" . + [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]) + ("sep3" . + [1 0 0 0]) + ("python/gethelp" . + [0 0 0 0 0 0 0 2 0 0 0 0 0 0]) + ("cleanup" . + [1 0 0 0 0 0 0]) + ("beginning-of-buffer" . + [1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]) + ("set-mark" . + [1 0 0 0 0 0 0 0]) + ("erase-buffer" . + [1 0 0 0 0 1 0 0 0 0 0 0]) + ("switch-to-buffer-other-window" . + [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]) + ("window-margins" . + [0 0 0 0 0 0 0 0 0 1 0 0 0 0]) + ("split-window-horizontally" . + [0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]) + ("here" . + [2 0 0 0]) + ("footer" . + [2 0 0 0 0 0]) + ("indent" . + [0 0 0 1 0 0]) + ("98%" . + [1 0 0]) + ("absolute" . + [2 0 0 0 0 0 0 0]) + ("min-height" . + [0 0 1 0 1 0 0 1 0 0]) + ("33" . + [1 0]) + ("1%" . + [1 0]) + ("padding-right" . + [0 0 0 0 0 0 0 0 0 0 2 0 0]) + ("yellow" . + [0 0 0 0 0 3]) + ("Background" . + [3 0 2 2 6 0 0 0 0 0]) + ("fff" . + [1 0 0]) + ("5px" . + [9 0 0]) + ("sep" . + [1 0 0]) + ("banner" . + [2 0 0 0 0 0]) + ("inherit" . + [0 0 0 0 1 0 0]) + ("block" . + [0 1 1 0 0]) + ("display" . + [1 0 0 0 1 1 0]) + ("hide" . + [3 0 0 0]) + ("20%" . + [1 0 0]) + ("relative" . + [0 0 4 1 0 0 0 0]) + ("position" . + [0 0 0 0 5 1 0 0]) + ("250px" . + [3 0 0 0 0]) + ("100%" . + [11 0 0 0]) + ("left" . + [2 0 1 1]) + ("ltr" . + [0 1 0]) + ("direction" . + [0 0 0 0 1 0 0 0 0]) + ("dest" . + [1 0 0 0]) + ("size" . + [1 0 0 0]) + ("ufile" . + [4 0 0 0 0]) + ("hashlib" . + [1 0 0 0 0 0 0]) + ("fname" . + [3 0 0 0 0]) + ("UPLOAD_ROOT" . + [1 0 0 1 0 0 0 0 0 0 0]) + ("pjoin" . + [1 0 0 0 0]) + ("conf" . + [3 0 0 0]) + ("MEDIA_ROOT" . + [0 0 0 0 0 0 0 0 0 1]) + ("map" . + [4 0 0]) + ("and" . + [2 0 0]) + ("o" . + [4]) + ("lambda" . + [0 0 0 1 1 0]) + ("_media" . + [0 0 1 0 0 0]) + ("pre_register" . + [0 0 0 0 1 0 0 0 0 0 0 0]) + ("Authentication" . + [0 0 0 0 1 0 0 0 0 0 0 0 0 0]) + ("Fields" . + [1 0 0 0 0 0]) + ("this" . + [1 0 0 0]) + ("fields" . + [5 0 0 0 0 0]) + ("require_once" . + [0 0 0 0 0 0 0 0 0 0 0 1]) + ("pid" . + [4 0 0]) + ("server" . + [32 0 0 0 0 0]) + ("hbeat" . + [4 0 1 0 0]) + ("HeartBeat" . + [1 0 0 0 1 0 0 0 1]) + ("sys" . + [7 0 0]) + ("white" . + [6 0 0 1 0]) + ("999999" . + [3 0 0 0 0 0]) + ("669999" . + [2 0 1 0 0 2]) + ("003333" . + [3 0 1 0 0 0]) + ("000" . + [1 0 0]) + ("0" . + [16]) + ("eeeeec" . + [4 0 0 3 2 0]) + ("join" . + [4 0 0 0]) + ("path" . + [11 0 0 0]) + ("rr" . + [6 0]) + ("home" . + [2 0 0 0]) + ("as" . + [10 0]) + ("editable" . + [1 0 0 1 0 1 0 0]) + ("sms_type" . + [1 0 0 0 0 0 0 0]) + ("tmpmodel" . + [0 0 1 2 0 0 0 0]) + ("recipients" . + [0 0 0 0 0 0 0 0 0 1]) + ("SMS" . + [3 0 0]) + ("max_length" . + [1 0 0 0 2 0 1 0 0 6]) + ("param" . + [3 0 0 0 0]) + ("parameters" . + [0 0 0 0 0 0 1 0 0 0]) + ("normal" . + [2 0 0 0 0 0]) + ("Classes" . + [1 0 0 1 0 0 0]) + ("or" . + [12 0]) + ("messageClasses" . + [0 0 0 0 0 0 0 0 1 0 0 0 0 0]) + ("body" . + [4 0 0 0]) + ("isinstance" . + [4 0 0 0 0 0 1 0 0 0]) + ("is" . + [5 0]) + ("recipient" . + [0 0 0 0 0 0 0 0 4]) + ("service" . + [1 0 0 0 0 0 0]) + ("send" . + [7 0 0 0]) + ("debug" . + [8 0 0 0 1]) + ("object" . + [5 0 1 0 0 0]) + ("BooleanField" . + [0 0 0 0 0 1 0 1 1 0 0 0]) + ("forms" . + [14 0 0 0 0]) + ("name" . + [24 0 0 0]) + ("Repositories" . + [1 0 0 0 0 0 0 0 0 0 0 0]) + ("Item" . + [0 0 1 0]) + ("P" . + [1]) + ("SecondaryGroup" . + [0 0 0 1 0 0 0 0 0 0 1 0 0 0]) + ("Product" . + [0 0 0 1 0 0 2]) + ("items" . + [1 0 0 0 0]) + ("Secondary" . + [0 0 0 0 0 0 0 1 0]) + ("sec" . + [5 0 0]) + ("r" . + [8]) + ("PrimaryGroup" . + [0 0 0 1 0 0 0 0 0 0 0 0]) + ("prim" . + [4 0 0 0]) + ("trigger" . + [1 0 0 0 0 1 0]) + ("options" . + [16 0 0 0 0 0 2]) + ("index" . + [3 0 0 0 0]) + ("value" . + [8 0 0 0 0]) + ("response" . + [6 0 0 0 1 0 0 0]) + ("html" . + [5 0 0 0]) + ("val" . + [4 0 0]) + ("ajaxelement" . + [0 0 0 0 0 1 0 0 0 0 0]) + ("document" . + [0 0 0 1 0 0 0 0]) + ("window" . + [2 0 0 0 0 0]) + ("var" . + [6 0 0]) + ("objects" . + [18 0 0 0 0 0 0]) + ("alert" . + [9 0 0 0 0]) + ("function403" . + [0 0 0 0 0 0 0 0 0 1 0]) + ("element" . + [17 0 0 1 1 1 0]) + ("ajaxsuccess" . + [0 0 0 0 0 1 0 0 0 0 0]) + ("function" . + [11 0 0 0 0 0 0 0]) + ("else" . + [19 0 0 0]) + ("request" . + [28 0 0 1 0 0 7]) + ("Post" . + [3 0 0 0]) + ("content" . + [5 0 0 0 0 0 0]) + ("Model" . + [5 0 0 0 0]) + ("class" . + [22 0 0 0 0]) + ("setup_vpkg" . + [1 0 0 0 1 0 0 0 0 0]) + ("count" . + [1 0 0 0 0]) + ("item" . + [5 0 0 0]) + ("price" . + [6 0 0 0 0]) + ("product" . + [4 0 0 0 0 0 0]) + ("models" . + [45 0 0 0 0 2]) + ("all" . + [3 0 0]) + ("Store" . + [1 0 0 0 0]) + ("db" . + [27 0]) + ("staticmethod" . + [3 0 0 0 0 0 1 1 0 0 0 0]) + ("\n" . + [1]) + ("app" . + [1 0 0]) + ("appname" . + [1 0 0 0 0 0 0]) + ("settings" . + [4 0 0 0 0 0 0 1]) + ("charge" . + [0 0 0 0 0 1]) + ("user" . + [24 0 0 0]) + ("connection" . + [2 0 0 0 1 0 0 0 0 1]) + ("_metadata" . + [0 0 0 1 0 0 0 0 0]) + ("data" . + [26 0 0 0]) + ("func" . + [4 0 0 0]) + ("command" . + [2 0 0 0 0 0 2]) + ("args" . + [25 0 0 0]) + ("install" . + [4 0 0 0 0 0 0]) + ("interactive" . + [1 0 0 0 0 0 0 0 0 0 1]) + ("defun" . + [1 0 0 0 0]) + ("message" . + [3 0 0 0 0 0 0]) + ("project-path" . + [0 0 0 0 0 0 0 0 0 0 1 0]) + ("replace-regexp-in-string" . + [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]) + ("commands" . + [6 0 0 0 0 0 0 0]) + ("setq" . + [7 0 0 0]) + ("None" . + [13 0 0 0]) + ("tmplist" . + [1 0 0 0 0 0 0]) + ("url" . + [32 0 0]) + ("views" . + [1 0 0 0 0]) + ("a" . + [10]) + ("update" . + [4 0 0 0 0 0]) + ("e" . + [9]) + ("application_name" . + [2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]) + ("application_instance" . + [1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 2]) + ("view" . + [4 0 0 1]) + ("next" . + [1 0 0 0]) + ("current_url" . + [1 0 0 0 0 0 0 0 0 0 1]) + ("generator" . + [0 0 0 0 0 1 0 0 0]) + ("append" . + [11 0 0 0 0 1]) + ("t" . + [8]) + ("tmp" . + [3 0 0]) + ("in" . + [33 0]) + ("for" . + [24 0 0]) + ("list" . + [10 0 0 0]) + ("urls" . + [9 0 0 1]) + ("def" . + [58 0 0]) + ("package" . + [8 0 0 0 0 0 0]) + ("self" . + [246 0 0 1]) + ("dir" . + [10 0 0]) + ("print" . + [145 0 0 0 1]) + ("_registery" . + [0 0 0 1 0 1 0 0 0 0]) + ("application" . + [2 0 0 0 0 0 0 0 0 0 2]) + ("str" . + [11 0 0]) + ("pkg_path" . + [0 0 1 1 0 0 0 0]) + ("return" . + [53 0 0 0 2 1]) + ("package_path" . + [2 0 0 0 0 0 0 0 1 0 0 0]) + ("if" . + [65 0]) + ("issubclass" . + [0 0 0 0 0 1 0 0 0 0]) + ("application_class" . + [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2]) + ("BaseApplication" . + [0 0 0 0 0 2 0 0 0 0 0 0 0 0 0]) + ("not" . + [12 0 0]) + ("raise" . + [15 0 0 0 0]) + ("s" . + [54]) + ("from" . + [41 0 0 0]) + ("import" . + [68 0 0 0 0 2]) + ("apps" . + [1 0 0 0]) + ("apps_list" . + [1 0 0 0 0 0 0 0 0]) + ("/home/lxsameer/" . + [0 0 0 0 0 0 0 0 0 1 0 0 0 0 0]) + ("/home/lxsameer/src/debbox/" . + [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0]) + ("/home/lxsameer/src/debbox/debbox/" . + [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0]) + ("/home/lxsameer/src/debbox/debbox/settings.py" . + [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0]) + ("myfile" . + [1 0 0 0 0 0]) + ("file" . + [5 0 0 0]) + ("number" . + [7 0 0 0 0 2]) + ("string" . + [2 0 0 0 0 0]) + ("to" . + [4 0]) + ("pass" . + [27 0 0 0]) + ("utils" . + [8 0 0 0 0]) + ("urllib" . + [3 0 0 0 0 2]) + ("req" . + [3 0 0]) + ("urlencode" . + [1 0 0 0 0 0 0 0 0]) + ("admin" . + [3 0 0 0 0]) + ("params" . + [8 0 0 0 0 0]) + ("opener" . + [1 0 0 0 0 0]) + ("urllib2" . + [1 0 0 0 1 0 0]) + ("result" . + [49 0 0 1 2 3]) + ("git" . + [1 0 0]) + ("GitRepository" . + [0 0 0 0 1 0 0 0 0 0 0 0 1]) + ("repository" . + [2 0 0 0 0 0 0 0 0 2]) + ("repositor" . + [0 0 0 0 0 0 0 0 1]) + ("repo" . + [7 0 0 0]) + ("repository_drivers" . + [0 0 0 0 1 1 1 0 0 0 0 0 0 1 0 0 0 2]) + ("repos" . + [2 0 0 0 0]) + ("repositories" . + [1 0 0 0 0 1 0 1 0 0 1 2]) + ("repository_instances_lis" . + [0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]) + ("vpkg" . + [2 0 0 0]) + ("load_repositories" . + [0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]) + ("__init__" . + [6 0 0 0 0 0 1 2]) + ("argc" . + [1 0 0 1]) + ("kwargs" . + [4 0 2 2 5 1]) + ("__class__" . + [0 0 0 0 1 0 0 0 0]) + ("__name__" . + [1 0 0 0 0 0 1 0]) + ("lines" . + [1 0 0 0 0]) + ("strip" . + [5 0 0 0 0]) + ("line" . + [12 0 0 0]) + ("get_package" . + [0 0 0 0 0 0 1 0 0 0 1]) + ("Invalid" . + [1 0 0 0 0 0 0]) + ("pkg_name" . + [1 0 0 0 0 0 0 0]) + ("pkg_list" . + [0 0 0 0 0 1 0 0]) + ("InvalidPackage" . + [0 0 0 0 0 0 0 1 1 0 0 0 0 1]) + ("i" . + [12]) + ("base" . + [1 0 0 0]) + ("try" . + [18 0 0]) + ("except" . + [11 0 0 1 2 3]) + ("get_user_credit" . + [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]) + ("credit" . + [3 0 0 0 0 0]) + ("django" . + [15 0 0 0 0 3]) + ("http" . + [1 0 0 0]) + ("HttpResponse" . + [2 0 0 0 1 0 0 0 0 0 0 1]) + ("xmlrpc" . + [0 0 0 0 0 1]) + ("json" . + [1 0 0 0]) + ("_priorities" . + [0 0 1 0 0 0 0 0 0 0 0]) + ("Page" . + [2 0 0 0]) + ("False" . + [13 0 0 0 1]) + ("True" . + [12 0 0 0]) + ("return_codes" . + [0 0 0 0 0 0 1 0 0 0 0 0]) + ("with" . + [1 0 0 0]) + ("code" . + [2 0 0 0]) + ("sent" . + [1 0 0 0]) + ("choices" . + [3 0 0 0 0 0 2]) + ("INOUT" . + [1 0 0 0 0]) + ("inout" . + [1 0 0 0 0]) + ("get_sms" . + [2 0 0 0 0 0 0]) + ("report" . + [3 0 0 0 0 0]) + ("get_delivery" . + [0 0 0 0 0 0 0 1 0 0 0 0]) + ("GET" . + [5 0 0]) + ("get" . + [15 0 0]) + ("page" . + [3 0 0 0]) + ("status" . + [3 0 0 0 0 1]) + ("mid" . + [2 0 0]) + ("date" . + [14 0 0 0]) + ("PageStatus" . + [0 0 0 0 1 2 0 0 0 1]) + ("SMSNumbers" . + [0 0 0 0 2 0 0 0 0 0]) + ("sms" . + [1 0 0]) + ("message_id" . + [1 0 0 0 0 0 0 0 0 0]) + ("pstatus" . + [1 0 0 3 0 0 0]) + ("page_number" . + [0 0 0 0 0 0 0 0 1 0 0]) + ("int" . + [10 0 0]) + ("save" . + [10 0 0 0]) + ("DateTimeField" . + [0 0 0 0 0 1 0 0 0 0 0 1 1]) + ("set_date" . + [1 0 0 0 0 0 0 0]) + ("date_string" . + [0 0 0 0 0 0 1 0 0 0 0]) + ("split" . + [5 0 0 0 0]) + ("datetime" . + [8 0 0 0 0 0 0 2]) + ("get_number" . + [1 0 0 0 0 0 0 0 0 0]) + ("auto" . + [21 3 1 0]) + ("20px" . + [18 0 0 0]) + ("copyright" . + [0 0 0 3 1 0 0 0 0]) + ("center" . + [7 2 0 0 0 0]) + ("margin-left" . + [1 0 0 2 0 0 0 0 2 2 1]) + ("margin-right" . + [1 0 0 2 1 0 0 0 6 3 0 1]) + ("text-decoration" . + [0 0 0 0 0 0 0 2 2 0 0 0 0 0 0]) + ("lang" . + [4 0 0 0]) + ("ff3333" . + [0 0 0 0 3 1]) + ("none" . + [5 0 0 0]) + ("hover" . + [1 0 0 0 0]) + ("color" . + [6 0 0 0 0]) + ("text-align" . + [0 0 0 0 0 0 4 1 1 1]) + ("0px" . + [14 0 0]) + ("margin-bottom" . + [0 0 1 0 0 0 0 0 5 2 0 0 0]) + ("margin-top" . + [2 0 0 1 1 2 0 1 2 1]) + ("x" . + [1]) + ("10px" . + [21 0 0 0]) + ("80%" . + [1 0 0]) + ("main" . + [3 0 0 0]) + ("padding" . + [2 0 0 0 0 0 0]) + ("h2" . + [1 0]) + ("h3" . + [3 0]) + ("padding-bottom" . + [0 0 0 0 0 0 0 0 0 0 2 0 0 0]) + ("margin" . + [2 0 0 0 0 0]) + ("span" . + [3 0 0 0]) + ("70%" . + [2 0 0]) + ("30px" . + [5 0 0 0]) + ("HeartBeatDaemon" . + [4 0 0 0 0 0 0 0 0 0 1 0 0 0 0]) + ("action" . + [5 0 0 0 0 0]) + ("os" . + [3 0]) + ("chown" . + [1 0 0 0 0]) + ("mpid" . + [1 0 0 0]) + ("uid" . + [8 0 0]) + ("gid" . + [1 0 0]) + ("f" . + [5]) + ("logging" . + [4 0 0 0 0 0 0]) + ("logger" . + [6 0 0 1 0 0]) + ("getLogger" . + [1 0 0 0 0 0 0 0 0]) + ("handler" . + [6 0 0 0 0 0 1]) + ("d" . + [9]) + ("client_address" . + [0 0 0 1 0 0 0 0 0 0 0 0 0 0]) + ("__dict__" . + [6 0 0 0 0 0 0 0]) + ("UDPHandler" . + [2 0 1 1 0 0 0 0 0 0]) + ("host" . + [10 0 0 0]) + ("port" . + [12 0 0 0]) + ("info" . + [6 0 0 0]) + ("hosts" . + [1 0 0 0 0]) + ("readlines" . + [1 0 0 0 0 0 0 0 0]) + ("OSError" . + [0 0 1 0 0 0 0]) + ("Error" . + [2 0 0 0 0]) + ("exit" . + [4 0 0 0]) + ("TCPServer" . + [1 0 1 1 0 0 0 0 2]) + ("SocketServer" . + [0 0 0 0 2 0 0 0 0 0 0 0]) + ("super" . + [6 0 0 0 0]) + ("TCPHandler" . + [0 0 0 0 0 0 0 0 0 2]) + ("k" . + [2]) + ("address" . + [1 0 0 0 0 0 0]) + ("del" . + [1 0 0]) + ("secret" . + [0 0 0 1 0 0]) + ("1" . + [10]) + ("1024" . + [2 0 0 0]) + ("w" . + [1]) + ("len" . + [10 0 0]) + ("target" . + [5 0 0 0 0 0]) + ("Group" . + [4 0 0 0 0]) + ("numbers" . + [6 0 0 0 0 0 0]) + ("Person" . + [2 0 0 0 0 0]) + ("members" . + [4 0 0 0 0 0 0]) + ("phones" . + [5 0 0 0 0 0]) + ("continue" . + [2 0 0 0 0 1 0 0]) + ("filter" . + [10 0 0 0 0 0]) + ("__unicode__" . + [3 0 0 0 0 0 0 0 0 0 0]) + ("fullname" . + [1 0 1 0 0 0 0 0]) + ("selector" . + [1 0 0 0 0 0 0 0]) + ("phone_set" . + [1 0 0 0 0 0 0 0 0]) + ("number_type" . + [0 0 0 0 0 0 0 0 0 0 1]) + ("extend" . + [2 0 0 0 0 0]) + ("translation" . + [0 0 0 0 0 2 0 2 0 0 1]) + ("ugettext" . + [0 0 1 4 0 0 0 0]) + ("label" . + [1 0 0 0 0]) + ("property" . + [0 0 0 0 1 0 0 0]) + ("widget" . + [1 0 0 1 0 0]) + ("AjaxWidget" . + [1 0 0 1 0 1 0 0 0 0]) + ("SMTP" . + [1 0 0 0]) + ("SMTP_FROM" . + [1 0 0 0 0 0 0 0 0]) + ("Verification" . + [2 0 0 1 0 0 0 0 0 0 0 0]) + ("days" . + [1 0 0 0]) + ("SUPPORT_MAIL" . + [1 0 0 0 0 0 1 0 0 0 0 0]) + ("verbose_name" . + [2 0 0 0 0 0 0 0 1 0 0 17]) + ("A" . + [1]) + ("CharField" . + [0 0 0 0 8 0 0 0 0]) + ("LEVELS" . + [1 0 0 0 0 0]) + ("IntegerField" . + [0 0 0 0 2 0 0 0 0 0 0 1]) + ("xrange" . + [2 0 0 0 0 0]) + ("raw_input" . + [0 0 0 1 0 0 0 0 0]) + ("sum" . + [1 0 0]) + ("advertise" . + [0 0 0 0 0 0 0 0 1]) + ("category" . + [1 0 0 0 0 0 0 3]) + ("Category" . + [0 0 0 0 1 0 0 2]) + ("AdvertiseForm" . + [0 0 0 0 0 0 0 0 0 0 1 0 0]) + ("id" . + [18 0]) + ("parent" . + [1 0 0 0 0 0]) + ("State" . + [1 0 0 0 0]) + ("categories" . + [0 0 0 0 2 0 0 0 0 0]) + ("state" . + [2 0 0 0 0]) + ("city" . + [2 0 0 0]) + ("form" . + [15 0 0 0]) + ("context" . + [1 0 0 0 0 0 3]) + ("initialize" . + [1 0 0 0 0 0 0 0 0 0]) + ("ad" . + [2 0]) + ("subcategory" . + [1 0 0 0 0 0 0 0 0 0 0]) + ("FILES" . + [1 0 1 1 0]) + ("&optional" . + [1 0 0 0 0 0 0 0 0]) + ("async" . + [1 0 0 0 0]) + ("let" . + [2 0 0]) + ("current-buffer-address" . + [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 1 0 0 0]) + ("bufferp" . + [0 0 0 0 1 0 0]) + ("buffer-end" . + [2 0 0 0 0 0 0 0 0 0]) + ("current" . + [3 0 0 0 0 0 0]) + ("buffer-file-name" . + [0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]) + ("eq" . + [1 0]) + ("nil" . + [5 0 0]) + ("progn" . + [3 0 0 0 0]) + ("save-buffer" . + [0 0 0 0 0 0 0 0 0 0 1]) + ("current-fill-column" . + [0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]) + ("pybuffer" . + [3 0 1 0 3 0 0 0]) + ("fullcommand" . + [1 0 0 0 0 1 1 1 0 0 1]) + ("stringp" . + [1 0 0 0 0 0 0]) + ("current-buffer" . + [0 0 0 0 0 0 0 0 0 0 0 0 0 2]) + ("extended-py-execute-buffer" . + [0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]) + ("default-directory" . + [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]) + ("cd" . + [3 0]) + ("cwd" . + [4 0 0]) + ("current-buffer-dir" . + [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1]) + ("make-comint-in-buffer" . + [2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0]) + ("echo" . + [4 0 0 0]) + ("your" . + [1 0 0 0]) + ("read" . + [4 0 0 0]) + ("conf/dotemacs" . + [1 0 0 0 0 0 0 0 0 0 0 0 0]) + ("sed" . + [4 0 0]) + ("mkdir" . + [1 0 0 0 0]) + ("-p" . + [1 0]) + ("addr" . + [2 0 0 0]) + ("conf/bin/" . + [0 0 0 0 0 0 1 0 0]) + ("conf/bin/pyemacs.sh" . + [0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]) + ("-rv" . + [1 0 0]) + ("other-window" . + [1 0 0 0 0 0 0 0 0 0 0 0]) + ("require" . + [0 0 0 1 0 0 0]) + ("python" . + [1 0 0 0 0 0]) + ("python-describe-symbol" . + [0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]) + ("cword" . + [2 0 0 0 0]) + ("c" . + [6]) + ("concat" . + [1 0 0 0 0 0]) + ("*python*" . + [1 0 0 0 0 0 0 0]) + ("Site" . + [1 0 0 0]) + ("HamsterRPC" . + [0 0 0 0 0 0 0 0 0 1]) + ("Hamster" . + [0 0 0 0 0 0 1]) + ("hamster_server" . + [1 0 0 0 0 0 0 0 0 0 0 0 0 0]) + ("VERSION" . + [1 0 0 1 0 0 0]) + ("__version__" . + [1 0 0 0 0 0 0 0 0 0 0]) + ("USAGE" . + [1 0 0 0 0]) + ("version" . + [1 0 0 0 0 0 0]) + ("OptionParser" . + [0 0 1 0 0 0 0 0 0 0 0 0]) + ("parser" . + [1 0 0 0 0 0]) + ("allow" . + [1 0 0 0 0]) + ("allowNone" . + [2 0 0 0 2 0 2 0 2]) + ("XMLRPC" . + [0 0 0 2 0 2]) + ("server_url" . + [1 0 0 0 0 0 1 2 0 1]) + ("Proxy" . + [0 0 0 0 1]) + ("u" . + [3]) + ("method" . + [8 0 0 0 0 0]) + ("getChild" . + [0 0 0 0 1 0 0 0]) + ("Rendering" . + [0 0 0 1 0 0 0 0 0]) + ("render_POST" . + [0 0 0 0 0 0 0 1 0 0 0]) + ("p" . + [8]) + ("xmlrpclib" . + [3 0 0 0 0 0 0 0 2]) + ("dumps" . + [2 0 0 0 0]) + ("xmldata" . + [1 0 0 0 0 0 0]) + ("httplib" . + [1 0 0 0 0 0 0]) + ("200" . + [2 0 0]) + ("rstrip" . + [1 0 0 0 0 0]) + ("Exception" . + [0 0 0 1 0 1 0 0 1]) + ("allow_none" . + [1 0 0 0 0 0 0 1 0 0]) + ("config" . + [1 0 0 0 0 0]) + ("cache_config" . + [2 0 0 0 0 0 0 0 0 0 0 0]) + ("dict" . + [3 0 0 0]) + ("cache" . + [2 0 0 0 0]) + ("server_status" . + [1 0 0 0 0 0 0 0 0 0 0 0 0]) + ("__builtin__" . + [0 0 0 0 0 0 1 0 0 0 0]) + ("Console" . + [1 0 0 0 0 0 0]) + ("printf" . + [1 0 0 0 0 0]) + ("_" . + [1]) + ("l" . + [1]) + ("obj" . + [16 0 0]) + ("_passwd" . + [1 0 0 0 0 0 0]) + ("n" . + [1]) + ("mbox" . + [1 0 0 0]) + ("666665" . + [0 0 0 1 0 0]) + ("email" . + [1 0 0 0 0]) + ("slug" . + [10 0 0 0]) + ("book" . + [2 0 0 0]) + ("Book" . + [2 0 0 0]) + ("Http404" . + [2 0 1 0 0 1 1]) + ("cover" . + [1 0 0 0 0]) + ("2" . + [2]) + ("-" . + [2]) + ("20" . + [2 0]) + ("border" . + [3 0 1 0 1 0]) + ("cccccd" . + [0 0 0 0 0 1]) + ("solid" . + [1 0 1 3 1]) + ("border-radius" . + [0 0 0 0 1 0 0 0 0 4 1 0 0]) + ("font-size" . + [0 0 1 1 0 5 0 0 0]) + ("line-height" . + [0 0 0 0 0 0 0 1 0 0 0]) + ("download" . + [2 0 0 0 0 0 0 0]) + ("75px" . + [1 0 0 0]) + ("200px" . + [2 0 0 0 0]) + ("3" . + [3]) + ("40px" . + [1 0 0 0]) + ("font-weight" . + [0 0 0 0 0 0 0 1 0 0 0]) + ("50px" . + [2 0 0 0]) + ("text-indent" . + [1 0 0 0 0 0 0 2 0 0 0]) + ("text" . + [1 0 0 0]) + ("static" . + [1 0 0 0 0 0]) + ("image" . + [1 0 0 0 0]) + ("no-repeat" . + [0 0 0 0 0 0 0 0 1]) + ("scroll" . + [0 0 0 0 0 1]) + ("transparent" . + [0 0 0 0 0 0 0 0 0 0 1]) + ("height" . + [0 0 0 7 1 1]) + ("48px" . + [1 0 0 0]) + ("icon" . + [1 0 0 0]) + ("100px" . + [2 0 0 0 0]) + ("64" . + [2 0]) + ("Name" . + [1 0 0 0]) + ("URLField" . + [1 0 0 0 0 0 0 0]) + ("Home" . + [1 0 0 0]) + ("blank" . + [1 0 0 0 0]) + ("null" . + [3 0 0 0]) + ("project" . + [8 0 0 0 0 0 0]) + ("Project" . + [3 0 0 0 0 0 2]) + ("DoesNotExist" . + [0 0 0 0 3 1 0 0 0 0 0 1]) + ("project_view" . + [1 0 0 0 0 0 0 0 0 0 0 0]) + ("Repository" . + [0 0 0 0 0 0 0 0 0 1]) + ("order_by" . + [2 0 0 0 0 0 0 0]) + ("vcs" . + [4 0 0]) + ("VCS" . + [1 0 0]) + ("vcsdict" . + [1 0 0 0 0 1 0]) + ("article" . + [1 0 0 0 0 0 0]) + ("irc_repr" . + [0 0 0 0 0 0 0 1]) + ("title" . + [1 0 0 0 0]) + ("model" . + [10 0 0 0 0]) + ("m" . + [1]) + ("content_type" . + [1 0 0 0 0 0 0 0 0 0 0 0]) + ("destination" . + [1 0 0 0 0 0 0 0 0 0 1]) + ("_columns" . + [1 0 0 0 0 0 0 0]) + ("dumpvar" . + [1 0 0 0 0 0 0]) + ("Open" . + [1 0 0 0]) + ("70px" . + [2 0 0 0]) + ("li" . + [1 0]) + ("loginform" . + [0 0 0 0 0 2 1 0 0]) + ("12px" . + [1 0 0 0]) + ("black" . + [3 0 0 0 0]) + ("ul" . + [1 0]) + ("width" . + [0 0 0 1 1]) + ("searchbar" . + [1 0 0 0 0 0 0 0 0]) + ("default" . + [5 0 0 0 0 0 0]) + ("Forum" . + [8 0 0 0 0]) + ("NewTopicForum" . + [0 0 0 3 0 0 0 0 0 0 0 0 0]) + ("new" . + [2 0 0]) + ("255" . + [1 0 0]) + ("lablel" . + [1 0 0 0 0 0]) + ("forum_id" . + [4 0 0 0 0 0 0 0]) + ("contrib" . + [1 0 0 0 0 0 0]) + ("auth" . + [1 0 0 0]) + ("decorators" . + [0 0 0 0 1 0 0 0 0 0]) + ("login_required" . + [0 0 0 0 0 1 0 0 0 0 0 0 0 0]) + ("POST" . + [4 0 0 0]) + ("reverse" . + [1 0 0 0 0 0 1]) + ("post" . + [12 0 0 0]) + ("cleaned_data" . + [1 0 0 1 0 2 0 0 0 0 0 0]) + ("last_post" . + [0 0 0 0 0 0 0 0 1]) + ("user_ip" . + [1 0 0 0 0 0 0]) + ("HttpResponseRedirect" . + [0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]) + ("global-linum-mode" . + [0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0]) + ("of" . + [1 0]) + ("template" . + [1 0 0 0 0 0 0 0]) + ("RequestContext" . + [1 0 0 0 0 0 0 0 0 0 0 0 0 0]) + ("box" . + [1 0 0]) + ("ballowin" . + [0 0 0 1 0 0 0 0]) + ("Shadow" . + [0 0 0 0 0 1]) + ("border-bottom" . + [1 0 0 0 0 0 0 0 0 0 0 0 0]) + ("float" . + [1 0 0 0 0]) + ("cgroup" . + [1 0 0 0 0 0]) + ("Esteghlal" . + [0 0 0 0 1 0 0 0 4]) + ("duration" . + [2 0 4 1 1 0 0 3]) + ("Car" . + [1 0 0]) + ("is_valid" . + [1 0 0 0 0 0 0 0]) + ("month" . + [3 0 0 0 0]) + ("year" . + [3 0 0 0]) + ("get_month" . + [0 0 0 0 1 0 0 0 0]) + ("internal" . + [1 0 0 0 0 0 0 0]) + ("ConversationsBetweenUrban" . + [0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2]) + ("tell_called" . + [0 0 0 0 1 0 0 0 0 0 0]) + ("description" . + [1 0 0 0 0 0 0 0 0 0 0]) + ("phone_number" . + [1 0 0 0 0 0 0 0 0 0 0 0]) + ("PhoneContract" . + [0 0 0 0 0 0 1 0 0 0 0 0 2]) + ("cabin" . + [2 0 0 0 0]) + ("starting_time" . + [2 0 0 0 0 0 0 0 0 1 0 0 0]) + ("end_time" . + [1 0 0 0 0 0 0 0]) + ("Starting" . + [0 0 0 0 0 0 1 0]) + ("end" . + [3 0 0]) + ("tdelta" . + [1 0 0 0 0 0]) + ("Conflicts" . + [1 0 0 0 0 0 0 0 0]) + ("Office" . + [1 0 0 0 0 0]) + ("call" . + [2 0 0 0]) + ("conflict" . + [0 0 0 0 0 0 0 1]) + ("CONFLICT_TYPE" . + [1 0 0 0 1 0 0 0 0 0 0 0 1]) + ("cost" . + [2 0 0 0]) + ("BigIntegerField" . + [0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]) + ("Meta" . + [1 0 0 0]) + ("ordering" . + [1 0 0 0 0 0 0 0]) + ("auto_now" . + [0 0 0 0 0 0 0 1]) + ("auto_now_add" . + [0 0 0 0 0 0 0 0 0 0 0 1]) + ("Markaz" . + [1 0 0 0 0 0]) + ("32" . + [2 0]) + ("CALL_TYPE" . + [0 0 0 0 0 1 0 0 0]) + ("TimeField" . + [1 0 0 0 0 0 0 0 0]) + ("format" . + [1 0 0 0 0 0]))) diff --git a/conf/emacs.d/auto-complete-clang.el b/conf/emacs.d/auto-complete-clang.el new file mode 100644 index 0000000..eca6fe9 --- /dev/null +++ b/conf/emacs.d/auto-complete-clang.el @@ -0,0 +1,151 @@ +(eval-when-compile (require 'cl)) + +(defvar clang-executable "clang") +(defvar clang-completion-doc-table (make-hash-table :test 'equal)) + +;; faces +(defface clang-completion-plain-face + '((t (:inherit default :family "Verdana"))) + "clang completion hint base font" :group 'clang-completion-faces) + +(defface clang-completion-type-face + '((t (:inherit 'clang-completion-plain-face :foreground "#729FCF" :weight bold :family "Verdana"))) + "clang completion hint font for types" :group 'clang-completion-faces) + +(defface clang-completion-variable-face + '((t (:inherit 'clang-completion-plain-face :foreground "#73D216" :family "Verdana"))) + "clang completion hint font for variables" :group 'clang-completion-faces) + +;; extra flags +(defvar clang-completion-pch nil) +(defvar clang-completion-flags nil) +(defvar clang-completion-suppress-error nil) + +(defun clang-process-exec (command) + (with-output-to-string + (with-current-buffer standard-output + (unless (or (eq (apply 'call-process (car command) nil '(t ".clang-completion-error") nil (cdr command)) 0) clang-completion-suppress-error) + (let ((last-command compile-command)) + (compile "cat .clang-completion-error") + (setq compile-command last-command)))))) + +(defun clang-parse-completion-line (line) + (cond ((string-match "^COMPLETION: Pattern" line) nil) ;; exclude patterns + ((string-match "^COMPLETION: \\([^ ]*\\)\\(?: : \\([^\"]*\\)\\)$" line) + (list (match-string 1 line) (match-string 2 line))) + ((string-match "^OVERRIDE: \\([^ ]*\\)\\(?: : \\([^\"]*\\)\\)$" line) + (list (match-string 1 line) (match-string 2 line))) + (t nil)) + ) + +(defun clang-process (buffer point) + (unless (buffer-file-name buffer) + (return "")) + (let* ((filename (buffer-file-name buffer)) + (col (1+ (- point (point-at-bol)))) + (row (count-lines point (point-min))) + (cmd (list clang-executable "-cc1" + filename "-fsyntax-only" "-code-completion-at" + (format "%s:%s:%s" filename row col)))) + + ;; eval the config file under buffer locations + (let* ((filedir (file-name-directory filename)) + (config-filename (concat filedir ".clang-completion-config.el"))) + (when (file-readable-p config-filename) + (with-temp-buffer + (insert-file-contents config-filename) + (eval-buffer)))) + + (when (listp clang-completion-flags) + (setq cmd (append cmd clang-completion-flags))) + (when (stringp clang-completion-pch) + (setq cmd (append cmd (list "-include-pch" clang-completion-pch)))) + (message (format "complete at %s:%s:%s" filename row col)) + (clang-process-exec cmd))) + +(defun clang-get-process-result (string) + (let* ((completion-lines (split-string string "\n"))) + (delq nil (mapcar 'clang-parse-completion-line completion-lines)))) + +(defun clang-get-process-completion-result (string) + (mapcar 'car (clang-get-process-result string))) + +(defun clang-get-process-prototype-table (string) + (let* ((lines (clang-get-process-result string)) + (result-table (make-hash-table :test 'equal))) + (dolist (line lines) + (let* ((key (first line)) + (value (gethash key result-table))) + (setq value (append value (list (second line)))) + (puthash key value result-table)) + ) + (setq clang-completion-doc-table result-table))) + +(defun clang-get-completions (&optional buffer point) + ;; save all modified buffers + (or buffer (setq buffer (current-buffer))) + (or point (setq point (point))) + (save-some-buffers t) + (let* ((output (clang-process buffer point))) + (clang-get-process-prototype-table output) + (clang-get-process-completion-result output))) + +(defun filter-doc-buffer () + (while (re-search-backward "\\[#.*?::#\\]" nil t) + (replace-match "")) + (goto-char (point-max)) + + (while (re-search-backward "\\[#\\|#\\]" nil t) + (replace-match " ")) + (goto-char (point-max)) + (while (re-search-backward "{#\\|#}\\|<#\\|#>" nil t) + (replace-match "")) + ) + +(defun clang-get-doc (symbol) + ;;(setq symbol (symbol-name (intern-soft symbol))) + (let ((reslist (gethash symbol clang-completion-doc-table))) + (with-temp-buffer + (font-lock-add-keywords nil '(("\\[#\\(.*?\\)#\\]" 1 + 'clang-completion-type-face t))) + (font-lock-add-keywords nil '(("<#\\(.*?\\)#>" 1 + 'clang-completion-variable-face t))) + (font-lock-add-keywords nil '(("\\(.*\\)" 1 + 'clang-completion-plain-face t))) + (font-lock-mode t) + + (insert (reduce '(lambda (x y) (concat x "\n" y)) reslist)) + (font-lock-fontify-buffer) + (filter-doc-buffer) + + (message (buffer-string)))) + ;;(with-temp-buffer + ;; (dolist (proto reslist) + ;; (insert proto) + ;; (insert "\n\n")) + ;; (filter-doc-buffer) + ;; (buffer-string)) + ;; display nothing + (return nil)) + +(defvar ac-source-clang-complete + '((candidates . (clang-get-completions nil ac-point)) + (prefix "[^a-zA-Z0-9_]\\(\\(?:[a-zA-Z_][a-zA-Z0-9_]*\\)?\\)" nil 1) + (document . clang-get-doc) + (requires . 0) + (symbol . "C") + (cache))) + +;;(defvar ac-source-clang-static-complete +;; '((candidates . (clang-get-completions nil ac-point)) +;; (prefix "::\\(\\(?:[a-zA-Z_][a-zA-Z0-9_]*\\)?\\)" nil 1) +;; ;;(document . 'clang-get-doc) +;; (requires . 0) +;; (symbol . "M") +;; (cache))) + +(defun ac-complete-clang () + (interactive) + (auto-complete '(ac-source-clang-complete))) + +(provide 'auto-complete-clang) diff --git a/conf/emacs.d/doctest-mode.el b/conf/emacs.d/doctest-mode.el new file mode 100644 index 0000000..75bd9cd --- /dev/null +++ b/conf/emacs.d/doctest-mode.el @@ -0,0 +1,2061 @@ +;;; doctest-mode.el --- Major mode for editing Python doctest files + +;; Copyright (C) 2004-2007 Edward Loper + +;; Author: Edward Loper +;; Maintainer: edloper@alum.mit.edu +;; Created: Aug 2004 +;; Keywords: python doctest unittest test docstring + +(defconst doctest-version "0.5 alpha" + "`doctest-mode' version number.") + +;; This software is provided as-is, without express or implied +;; warranty. Permission to use, copy, modify, distribute or sell this +;; software, without fee, for any purpose and by any individual or +;; organization, is hereby granted, provided that the above copyright +;; notice and this paragraph appear in all copies. + +;; This is a major mode for editing text files that contain Python +;; doctest examples. Doctest is a testing framework for Python that +;; emulates an interactive session, and checks the result of each +;; command. For more information, see the Python library reference: +;; + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Table of Contents +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; 1. Customization: use-editable variables to customize +;; doctest-mode. +;; +;; 2. Fonts: defines new font-lock faces. +;; +;; 3. Constants: various consts (mainly regexps) used by the rest +;; of the code. +;; +;; 4. Syntax Highlighting: defines variables and functions used by +;; font-lock-mode to perform syntax highlighting. +;; +;; 5. Source code editing & indentation: commands used to +;; automatically indent, dedent, & handle prompts. +;; +;; 6. Code Execution: commands used to start doctest processes, +;; and handle their output. +;; +;; 7. Markers: functions used to insert markers at the start of +;; doctest examples. These are used to keep track of the +;; correspondence between examples in the source buffer and +;; results in the output buffer. +;; +;; 8. Navigation: commands used to navigate between failed examples. +;; +;; 9. Replace Output: command used to replace a doctest example's +;; expected output with its actual output. +;; +;; 10. Helper functions: various helper functions used by the rest +;; of the code. +;; +;; 11. Emacs compatibility functions: defines compatible versions of +;; functions that are defined for some versions of emacs but not +;; others. +;; +;; 12. Doctest Results Mode: defines doctest-results-mode, which is +;; used for the output generated by doctest. +;; +;; 13. Doctest Mode: defines doctest-mode itself. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Customizable Constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defgroup doctest nil + "Support for the Python doctest framework" + :group 'languages + :prefix "doctest-") + +(defcustom doctest-default-margin 4 + "The default pre-prompt margin for doctest examples." + :type 'integer + :group 'doctest) + +(defcustom doctest-avoid-trailing-whitespace t + "If true, then delete trailing whitespace when inserting a newline." + :type 'boolean + :group 'doctest) + +(defcustom doctest-temp-directory + (let ((ok '(lambda (x) + (and x + (setq x (expand-file-name x)) ; always true + (file-directory-p x) + (file-writable-p x) + x)))) + (or (funcall ok (getenv "TMPDIR")) + (funcall ok "/usr/tmp") + (funcall ok "/tmp") + (funcall ok "/var/tmp") + (funcall ok ".") + (error (concat "Couldn't find a usable temp directory -- " + "set `doctest-temp-directory'")))) + "Directory used for temporary files created when running doctest. +By default, the first directory from this list that exists and that you +can write into: the value (if any) of the environment variable TMPDIR, +/usr/tmp, /tmp, /var/tmp, or the current directory." + :type 'string + :group 'doctest) + +(defcustom doctest-hide-example-source nil + "If true, then don't display the example source code for each +failure in the results buffer." + :type 'boolean + :group 'doctest) + +(defcustom doctest-python-command "python" + "Shell command used to start the python interpreter" + :type 'string + :group 'doctest) + +(defcustom doctest-results-buffer-name "*doctest-output (%N)*" + "The name of the buffer used to store the output of the doctest +command. This name can contain the following special sequences: + %n -- replaced by the doctest buffer's name. + %N -- replaced by the doctest buffer's name, with '.doctest' + stripped off. + %f -- replaced by the doctest buffer's filename." + :type 'string + :group 'doctest) + +(defcustom doctest-optionflags '() + "Option flags for doctest" + :group 'doctest + :type '(repeat (choice (const :tag "Select an option..." "") + (const :tag "Normalize whitespace" + "NORMALIZE_WHITESPACE") + (const :tag "Ellipsis" + "ELLIPSIS") + (const :tag "Don't accept True for 1" + "DONT_ACCEPT_TRUE_FOR_1") + (const :tag "Don't accept " + "DONT_ACCEPT_BLANKLINE") + (const :tag "Ignore Exception detail" + "IGNORE_EXCEPTION_DETAIL") + (const :tag "Report only first failure" + "REPORT_ONLY_FIRST_FAILURE") + ))) + +(defcustom doctest-async t + "If true, then doctest will be run asynchronously." + :type 'boolean + :group 'doctest) + +(defcustom doctest-trim-exceptions t + "If true, then any exceptions inserted by doctest-replace-output +will have the stack trace lines trimmed." + :type 'boolean + :group 'doctest) + +(defcustom doctest-highlight-strings t + "If true, then highlight strings. If you find that doctest-mode +is responding slowly when you type, turning this off might help." + :type 'boolean + :group 'doctest) + +(defcustom doctest-follow-output t + "If true, then when doctest is run asynchronously, the output buffer +will scroll to display its output as it is generated. If false, then +the output buffer not scroll." + :type 'boolean + :group 'doctest) + +(defvar doctest-mode-hook nil + "Hook called by `doctest-mode'.") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Fonts +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defface doctest-prompt-face + '((((class color) (background dark)) + (:foreground "#68f")) + (t (:foreground "#226"))) + "Face for Python prompts in doctest examples." + :group 'doctest) + +(defface doctest-output-face + '((((class color) (background dark)) + (:foreground "#afd")) + (t (:foreground "#262"))) + "Face for the output of doctest examples." + :group 'doctest) + +(defface doctest-output-marker-face + '((((class color) (background dark)) + (:foreground "#0f0")) + (t (:foreground "#080"))) + "Face for markers in the output of doctest examples." + :group 'doctest) + +(defface doctest-output-traceback-face + '((((class color) (background dark)) + (:foreground "#f88")) + (t (:foreground "#622"))) + "Face for traceback headers in the output of doctest examples." + :group 'doctest) + +(defface doctest-results-divider-face + '((((class color) (background dark)) + (:foreground "#08f")) + (t (:foreground "#00f"))) + "Face for dividers in the doctest results window." + :group 'doctest) + +(defface doctest-results-loc-face + '((((class color) (background dark)) + (:foreground "#0f8")) + (t (:foreground "#084"))) + "Face for location headers in the doctest results window." + :group 'doctest) + +(defface doctest-results-header-face + '((((class color) (background dark)) + (:foreground "#8ff")) + (t (:foreground "#088"))) + "Face for sub-headers in the doctest results window." + :group 'doctest) + +(defface doctest-results-selection-face + '((((class color) (background dark)) + (:foreground "#ff0" :background "#008")) + (t (:background "#088" :foreground "#fff"))) + "Face for selected failure's location header in the results window." + :group 'doctest) + +(defface doctest-selection-face + '((((class color) (background dark)) + (:foreground "#ff0" :background "#00f" :bold t)) + (t (:foreground "#f00"))) + "Face for selected example's prompt" + :group 'doctest) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defconst doctest-prompt-re + "^\\(?:\\([ \t]*\\)\\(>>> ?\\|[.][.][.] ?\\)\\([ \t]*\\)\\)" + "Regular expression for doctest prompts. It defines three groups: +the pre-prompt margin; the prompt; and the post-prompt indentation.") + +(defconst doctest-open-block-re + "[^\n]+:[ \t]*\\(#.*\\)?$" + "Regular expression for a line that opens a block") + +(defconst doctest-close-block-re + "\\(return\\|raise\\|break\\|continue\\|pass\\)\\b" + "Regular expression for a line that closes a block") + +(defconst doctest-example-source-re + "^Failed example:\n\\(\n\\| [^\n]*\n\\)+" + "Regular expression for example source in doctest's output.") + +(defconst doctest-results-divider-re + "^\\([*]\\{60,\\}\\)$" + "Regular expression for example dividers in doctest's output.") + +(defconst doctest-py24-results-loc-re + "^File \"[^\"]+\", line \\([0-9]+\\), in [^\n]+" + "Regular expression for example location markers in doctest's output.") + +(defconst doctest-py21-results-loc-re + "^from line #\\([0-9]+\\) of [^\n]*" + "Regular expression for example location markers in doctest's output, +when the output was generated by an old version of doctest.") + +(defconst doctest-results-header-re + "^\\([^ \n\t].+:\\|Expected nothing\\|Got nothing\\)$" + "Regular expression for example headers in doctest's output.") + +(defconst doctest-traceback-header-re + "^[ \t]*Traceback (\\(most recent call last\\|innermost last\\)):" + "Regular expression for Python traceback headers.") + +(defconst doctest-py21-results-re + "^from line #" + "Regular expression used to test which version of doctest was used.") + +;; nb: There's a bug in Python's traceback.print_exception function +;; which causes SyntaxError exceptions to be displayed incorrectly; +;; which prevents this regexp from matching. But there shouldn't be +;; too many people testing for SyntaxErrors, so I won't worry about +;; it. +(defconst doctest-traceback-re + (let ((nonprompt + ;; This matches any non-blank line that doesn't start with + ;; a prompt (... or >>>). + (concat + "\\(?:[.][.][^.\n]\\|[>][>][^>\n]\\|" + "[.][^.\n]\\|[>][^>\n]\\|[^.>\n \t]\\)[^\n]*"))) + (concat + "^\\(\\([ \t]*\\)Traceback " + "(\\(?:most recent call last\\|innermost last\\)):\n\\)" + "\\(?:\\2[ \t]+[^ \t\n][^\n]*\n\\)*" + "\\(\\(?:\\2" nonprompt "\n\\)" + "\\(?:\\2[ \t]*" nonprompt "\n\\)*\\)")) + "Regular expression that matches a complete exception traceback. +It contains three groups: group 1 is the header line; group 2 is +the indentation; and group 3 is the exception message.") + +(defconst doctest-blankline-re + "^[ \t]*" + "Regular expression that matches blank line markers in doctest +output.") + +(defconst doctest-outdent-re + (concat "\\(" (mapconcat 'identity + '("else:" + "except\\(\\s +.*\\)?:" + "finally:" + "elif\\s +.*:") + "\\|") + "\\)") + "Regular expression for a line that should be outdented. Any line +that matches `doctest-outdent-re', but does not follow a line matching +`doctest-no-outdent-re', will be outdented.") + +;; It's not clear to me *why* the behavior given by this definition of +;; doctest-no-outdent-re is desirable; but it's basically just copied +;; from python-mode. +(defconst doctest-no-outdent-re + (concat + "\\(" + (mapconcat 'identity + (list "try:" + "except\\(\\s +.*\\)?:" + "while\\s +.*:" + "for\\s +.*:" + "if\\s +.*:" + "elif\\s +.*:" + "\\(return\\|raise\\|break\\|continue\\|pass\\)[ \t\n]" + ) + "\\|") + "\\)") + "Regular expression matching lines not to outdent after. Any line +that matches `doctest-outdent-re', but does not follow a line matching +`doctest-no-outdent-re', will be outdented.") + +(defconst doctest-script + "\ +from doctest import * +import sys +if '%m': + import imp + try: + m = imp.load_source('__imported__', '%m') + globs = m.__dict__ + except Exception, e: + print ('doctest-mode encountered an error while importing ' + 'the current buffer:\\n\\n %s' % e) + sys.exit(1) +else: + globs = {} +doc = open('%t').read() +if sys.version_info[:2] >= (2,4): + test = DocTestParser().get_doctest(doc, globs, '%n', '%f', 0) + r = DocTestRunner(optionflags=%l) + r.run(test) +else: + Tester(globs=globs).runstring(doc, '%f')" + ;; Docstring: + "Python script used to run doctest. +The following special sequences are defined: + %n -- replaced by the doctest buffer's name. + %f -- replaced by the doctest buffer's filename. + %l -- replaced by the doctest flags string. + %t -- replaced by the name of the tempfile containing the doctests." + ) + +(defconst doctest-keyword-re + (let* ((kw1 (mapconcat 'identity + '("and" "assert" "break" "class" + "continue" "def" "del" "elif" + "else" "except" "exec" "for" + "from" "global" "if" "import" + "in" "is" "lambda" "not" + "or" "pass" "print" "raise" + "return" "while" "yield" + ) + "\\|")) + (kw2 (mapconcat 'identity + '("else:" "except:" "finally:" "try:") + "\\|")) + (kw3 (mapconcat 'identity + '("ArithmeticError" "AssertionError" + "AttributeError" "DeprecationWarning" "EOFError" + "Ellipsis" "EnvironmentError" "Exception" "False" + "FloatingPointError" "FutureWarning" "IOError" + "ImportError" "IndentationError" "IndexError" + "KeyError" "KeyboardInterrupt" "LookupError" + "MemoryError" "NameError" "None" "NotImplemented" + "NotImplementedError" "OSError" "OverflowError" + "OverflowWarning" "PendingDeprecationWarning" + "ReferenceError" "RuntimeError" "RuntimeWarning" + "StandardError" "StopIteration" "SyntaxError" + "SyntaxWarning" "SystemError" "SystemExit" + "TabError" "True" "TypeError" "UnboundLocalError" + "UnicodeDecodeError" "UnicodeEncodeError" + "UnicodeError" "UnicodeTranslateError" + "UserWarning" "ValueError" "Warning" + "ZeroDivisionError" "__debug__" + "__import__" "__name__" "abs" "apply" "basestring" + "bool" "buffer" "callable" "chr" "classmethod" + "cmp" "coerce" "compile" "complex" "copyright" + "delattr" "dict" "dir" "divmod" + "enumerate" "eval" "execfile" "exit" "file" + "filter" "float" "getattr" "globals" "hasattr" + "hash" "hex" "id" "input" "int" "intern" + "isinstance" "issubclass" "iter" "len" "license" + "list" "locals" "long" "map" "max" "min" "object" + "oct" "open" "ord" "pow" "property" "range" + "raw_input" "reduce" "reload" "repr" "round" + "setattr" "slice" "staticmethod" "str" "sum" + "super" "tuple" "type" "unichr" "unicode" "vars" + "xrange" "zip") + "\\|")) + (pseudokw (mapconcat 'identity + '("self" "None" "True" "False" "Ellipsis") + "\\|")) + (string (concat "'\\(?:\\\\[^\n]\\|[^\n']*\\)'" "\\|" + "\"\\(?:\\\\[^\n]\\|[^\n\"]*\\)\"")) + (brk "\\(?:[ \t(]\\|$\\)")) + (concat + ;; Comments (group 1) + "\\(#.*\\)" + ;; Function & Class Definitions (groups 2-3) + "\\|\\b\\(class\\|def\\)" + "[ \t]+\\([a-zA-Z_][a-zA-Z0-9_]*\\)" + ;; Builtins preceeded by '.'(group 4) + "\\|[.][\t ]*\\(" kw3 "\\)" + ;; Keywords & builtins (group 5) + "\\|\\b\\(" kw1 "\\|" kw2 "\\|" + kw3 "\\|" pseudokw "\\)" brk + ;; Decorators (group 6) + "\\|\\(@[a-zA-Z_][a-zA-Z0-9_]*\\)" + )) + "A regular expression used for syntax highlighting of Python +source code.") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Syntax Highlighting (font-lock mode) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; Define the font-lock keyword table. +(defconst doctest-font-lock-keywords + `( + ;; The following pattern colorizes source lines. In particular, + ;; it first matches prompts, and then looks for any of the + ;; following matches *on the same line* as the prompt. It uses + ;; the form: + ;; + ;; (MATCHER MATCH-HIGHLIGHT + ;; (ANCHOR-MATCHER nil nil MATCH-HIGHLIGHT)) + ;; + ;; See the variable documentation for font-lock-keywords for a + ;; description of what each of those means. + ("^[ \t]*\\(>>>\\|\\.\\.\\.\\)" + (1 'doctest-prompt-face) + (doctest-source-matcher + nil nil + (1 'font-lock-comment-face t t) ; comments + (2 'font-lock-keyword-face t t) ; def/class + (3 'font-lock-type-face t t) ; func/class name + ;; group 4 (builtins preceeded by '.') gets no colorization. + (5 'font-lock-keyword-face t t) ; keywords & builtins + (6 'font-lock-preprocessor-face t t) ; decorators + (7 'font-lock-string-face t t) ; strings + )) + + ;; The following pattern colorizes output lines. In particular, + ;; it uses doctest-output-line-matcher to check if this is an + ;; output line, and if so, it colorizes it, and any special + ;; markers it contains. + (doctest-output-line-matcher + (0 'doctest-output-face t) + ("\\.\\.\\." (beginning-of-line) (end-of-line) + (0 'doctest-output-marker-face t)) + (,doctest-blankline-re (beginning-of-line) (end-of-line) + (0 'doctest-output-marker-face t)) + (doctest-traceback-line-matcher (beginning-of-line) (end-of-line) + (0 'doctest-output-traceback-face t)) + (,doctest-traceback-header-re (beginning-of-line) (end-of-line) + (0 'doctest-output-traceback-face t)) + ) + + ;; A PS1 prompt followed by a non-space is an error. + ("^[ \t]*\\(>>>[^ \t\n][^\n]*\\)" (1 'font-lock-warning-face t)) + ) + "Expressions to highlight in doctest-mode.") + +(defconst doctest-results-font-lock-keywords + `((,doctest-results-divider-re + (0 'doctest-results-divider-face)) + (,doctest-py24-results-loc-re + (0 'doctest-results-loc-face)) + (,doctest-results-header-re + (0 'doctest-results-header-face)) + (doctest-results-selection-matcher + (0 'doctest-results-selection-face t))) + "Expressions to highlight in doctest-results-mode.") + +(defun doctest-output-line-matcher (limit) + "A `font-lock-keyword' MATCHER that returns t if the current +line is the expected output for a doctest example, and if so, +sets `match-data' so that group 0 spans the current line." + ;; The real work is done by doctest-find-output-line. + (when (doctest-find-output-line limit) + ;; If we found one, then mark the entire line. + (beginning-of-line) + (re-search-forward "[^\n]*" limit))) + +(defun doctest-traceback-line-matcher (limit) + "A `font-lock-keyword' MATCHER that returns t if the current line is +the beginning of a traceback, and if so, sets `match-data' so that +group 0 spans the entire traceback. n.b.: limit is ignored." + (beginning-of-line) + (when (looking-at doctest-traceback-re) + (goto-char (match-end 0)) + t)) + +(defun doctest-source-matcher (limit) + "A `font-lock-keyword' MATCHER that returns t if the current line +contains a Python source expression that should be highlighted +after the point. If so, it sets `match-data' to cover the string +literal. The groups in `match-data' should be interpreted as follows: + + Group 1: comments + Group 2: def/class + Group 3: function/class name + Group 4: builtins preceeded by '.' + Group 5: keywords & builtins + Group 6: decorators + Group 7: strings +" + (let ((matchdata nil)) + ;; First, look for string literals. + (when doctest-highlight-strings + (save-excursion + (when (doctest-string-literal-matcher limit) + (setq matchdata + (list (match-beginning 0) (match-end 0) + nil nil nil nil nil nil nil nil nil nil nil nil + (match-beginning 0) (match-end 0)))))) + ;; Then, look for other keywords. If they occur before the + ;; string literal, then they take precedence. + (save-excursion + (when (and (re-search-forward doctest-keyword-re limit t) + (or (null matchdata) + (< (match-beginning 0) (car matchdata)))) + (setq matchdata (match-data)))) + (when matchdata + (set-match-data matchdata) + (goto-char (match-end 0)) + t))) + +(defun doctest-string-literal-matcher (limit &optional debug) + "A `font-lock-keyword' MATCHER that returns t if the current line +contains a string literal starting at or after the point. If so, it +expands `match-data' to cover the string literal. This matcher uses +`doctest-statement-info' to collect information about strings that +continue over multiple lines. It therefore might be a little slow for +very large statements." + (let* ((stmt-info (doctest-statement-info)) + (quotes (reverse (nth 5 stmt-info))) + (result nil)) + (if debug (doctest-debug "quotes %s" quotes)) + (while (and quotes (null result)) + (let* ((quote (pop quotes)) + (start (car quote)) + (end (min limit (or (cdr quote) limit)))) + (if debug (doctest-debug "quote %s-%s pt=%s lim=%s" + start end (point) limit)) + (when (or (and (<= (point) start) (< start limit)) + (and (< start (point)) (< (point) end))) + (setq start (max start (point))) + (set-match-data (list start end)) + (if debug (doctest-debug "marking string %s" (match-data))) + (goto-char end) + (setq result t)))) + result)) + +(defun doctest-results-selection-matcher (limit) + "Matches from `doctest-selected-failure' to the end of the +line. This is used to highlight the currently selected failure." + (when (and doctest-selected-failure + (<= (point) doctest-selected-failure) + (< doctest-selected-failure limit)) + (goto-char doctest-selected-failure) + (re-search-forward "[^\n]+" limit))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Source code editing & indentation +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun doctest-indent-source-line (&optional dedent-only) + "Re-indent the current line, as doctest source code. I.e., add a +prompt to the current line if it doesn't have one, and re-indent the +source code (to the right of the prompt). If `dedent-only' is true, +then don't increase the indentation level any." + (interactive "*") + (let ((indent-end nil)) + (save-excursion + (beginning-of-line) + (let ((new-indent (doctest-current-source-line-indentation dedent-only)) + (new-margin (doctest-current-source-line-margin)) + (line-had-prompt (looking-at doctest-prompt-re))) + ;; Delete the old prompt (if any). + (when line-had-prompt + (goto-char (match-beginning 2)) + (delete-char (- (match-end 2) (match-beginning 2)))) + ;; Delete the old indentation. + (delete-backward-char (skip-chars-forward " \t")) + ;; If it's a continuation line, or a new PS1 prompt, + ;; then copy the margin. + (when (or new-indent (not line-had-prompt)) + (beginning-of-line) + (delete-backward-char (skip-chars-forward " \t")) + (insert-char ?\ new-margin)) + ;; Add the new prompt. + (insert-string (if new-indent "... " ">>> ")) + ;; Add the new indentation + (if new-indent (insert-char ?\ new-indent)) + (setq indent-end (point)))) + ;; If we're left of the indentation end, then move up to the + ;; indentation end. + (if (< (point) indent-end) (goto-char indent-end)))) + +(defun doctest-current-source-line-indentation (&optional dedent-only) + "Return the post-prompt indent to use for this line. This is an +integer for a continuation lines, and nil for non-continuation lines." + (save-excursion + ;; Examine the previous doctest line (if present). + (let* ((prev-stmt-info (doctest-prev-statement-info)) + (prev-stmt-indent (nth 0 prev-stmt-info)) + (continuation-indent (nth 1 prev-stmt-info)) + (prev-stmt-opens-block (nth 2 prev-stmt-info)) + (prev-stmt-closes-block (nth 3 prev-stmt-info)) + (prev-stmt-blocks-outdent (nth 4 prev-stmt-info)) + ) + ;; Examine this doctest line. + (let* ((curr-line-indent 0) + (curr-line-outdented nil)) + (beginning-of-line) + (when (looking-at doctest-prompt-re) + (setq curr-line-indent (- (match-end 3) (match-beginning 3))) + (goto-char (match-end 3))) + (setq curr-line-outdented (and (looking-at doctest-outdent-re) + (not prev-stmt-blocks-outdent))) + ;; Compute the overall indent. + (let ((indent (or continuation-indent + (+ prev-stmt-indent + (if curr-line-outdented -4 0) + (if prev-stmt-opens-block 4 0) + (if prev-stmt-closes-block -4 0))))) + ;; If dedent-only is true, then make sure we don't indent. + (when dedent-only + (setq indent (min indent curr-line-indent))) + ;; If indent=0 and we're not outdented, then set indent to + ;; nil (to signify the start of a new source example). + (when (and (= indent 0) + (not (or curr-line-outdented continuation-indent))) + (setq indent nil)) + ;; Return the indentation. + indent))))) + +(defun doctest-prev-statement-info (&optional debug) + (save-excursion + (forward-line -1) + (doctest-statement-info debug))) + +(defun doctest-statement-info (&optional debug) + "Collect info about the previous statement, and return it as a list: + + (INDENT, CONTINUATION, OPENS-BLOCK, CLOSES-BLOCK, BLOCKS-OUTDENT, + QUOTES) + +INDENT -- The indentation of the previous statement (after the prompt) + +CONTINUATION -- If the previous statement is incomplete (e.g., has an +open paren or quote), then this is the appropriate indentation +level; otherwise, it's nil. + +OPENS-BLOCK -- True if the previous statement opens a Python control +block. + +CLOSES-BLOCK -- True if the previous statement closes a Python control +block. + +BLOCKS-OUTDENT -- True if the previous statement should 'block the +next statement from being considered an outdent. + +QUOTES -- A list of (START . END) pairs for all quotation strings. +" + (save-excursion + (end-of-line) + (let ((end (point))) + (while (and (doctest-on-source-line-p "...") (= (forward-line -1) 0))) + (cond + ;; If there's no previous >>> line, then give up. + ((not (doctest-on-source-line-p ">>>")) + '(0 nil nil nil nil)) + + ;; If there is a previous statement, walk through the source + ;; code, checking for operators that may be of interest. + (t + (beginning-of-line) + (let* ((quote-mark nil) (nesting 0) (indent-stack '()) + (stmt-indent 0) + (stmt-opens-block nil) + (stmt-closes-block nil) + (stmt-blocks-outdent nil) + (quotes '()) + (elt-re (concat "\\\\[^\n]\\|" + "(\\|)\\|\\[\\|\\]\\|{\\|}\\|" + "\"\"\"\\|\'\'\'\\|\"\\|\'\\|" + "#[^\n]*\\|" doctest-prompt-re))) + (while (re-search-forward elt-re end t) + (let* ((elt (match-string 0)) + (elt-first-char (substring elt 0 1))) + (if debug (doctest-debug "Debug: %s" elt)) + (cond + ;; Close quote -- set quote-mark back to nil. The + ;; second case is for cases like: ' ''' + (quote-mark + (cond + ((equal quote-mark elt) + (setq quote-mark nil) + (setcdr (car quotes) (point))) + ((equal quote-mark elt-first-char) + (setq quote-mark nil) + (setcdr (car quotes) (point)) + (backward-char 2)))) + ;; Prompt -- check if we're starting a new stmt. If so, + ;; then collect various info about it. + ((string-match doctest-prompt-re elt) + (when (and (null quote-mark) (= nesting 0)) + (let ((indent (- (match-end 3) (match-end 2)))) + (unless (looking-at "[ \t]*\n") + (setq stmt-indent indent) + (setq stmt-opens-block + (looking-at doctest-open-block-re)) + (setq stmt-closes-block + (looking-at doctest-close-block-re)) + (setq stmt-blocks-outdent + (looking-at doctest-no-outdent-re)))))) + ;; Open paren -- increment nesting, and update indent-stack. + ((string-match "(\\|\\[\\|{" elt-first-char) + (let ((elt-pos (point)) + (at-eol (looking-at "[ \t]*\n")) + (indent 0)) + (save-excursion + (re-search-backward doctest-prompt-re) + (if at-eol + (setq indent (+ 4 (- (match-end 3) (match-end 2)))) + (setq indent (- elt-pos (match-end 2)))) + (push indent indent-stack))) + (setq nesting (+ nesting 1))) + ;; Close paren -- decrement nesting, and pop indent-stack. + ((string-match ")\\|\\]\\|}" elt-first-char) + (setq indent-stack (cdr indent-stack)) + (setq nesting (max 0 (- nesting 1)))) + ;; Open quote -- set quote-mark. + ((string-match "\"\\|\'" elt-first-char) + (push (cons (- (point) (length elt)) nil) quotes) + (setq quote-mark elt))))) + + (let* ((continuation-indent + (cond + (quote-mark 0) + ((> nesting 0) (if (null indent-stack) 0 (car indent-stack))) + (t nil))) + (result + (list stmt-indent continuation-indent + stmt-opens-block stmt-closes-block + stmt-blocks-outdent quotes))) + (if debug (doctest-debug "Debug: %s" result)) + result))))))) + +(defun doctest-current-source-line-margin () + "Return the pre-prompt margin to use for this source line. This is +copied from the most recent source line, or set to +`doctest-default-margin' if there are no preceeding source lines." + (save-excursion + (save-restriction + (when (doctest-in-mmm-docstring-overlay) + (doctest-narrow-to-mmm-overlay)) + (beginning-of-line) + (forward-line -1) + (while (and (not (doctest-on-source-line-p)) + (re-search-backward doctest-prompt-re nil t)))) + (cond ((looking-at doctest-prompt-re) + (- (match-end 1) (match-beginning 1))) + ((doctest-in-mmm-docstring-overlay) + (doctest-default-margin-in-mmm-docstring-overlay)) + (t + doctest-default-margin)))) + +(defun doctest-electric-backspace () + "Delete the preceeding character, level of indentation, or +prompt. + +If point is at the leftmost column, delete the preceding newline. + +Otherwise, if point is at the first non-whitespace character +following an indented source line's prompt, then reduce the +indentation to the next multiple of 4; and update the source line's +prompt, when necessary. + +Otherwise, if point is at the first non-whitespace character +following an unindented source line's prompt, then remove the +prompt (converting the line to an output line or text line). + +Otherwise, if point is at the first non-whitespace character of a +line, the delete the line's indentation. + +Otherwise, delete the preceeding character. +" + (interactive "*") + (cond + ;; Beginning of line: delete preceeding newline. + ((bolp) (backward-delete-char 1)) + + ;; First non-ws char following prompt: dedent or remove prompt. + ((and (looking-at "[^ \t\n]\\|$") (doctest-looking-back doctest-prompt-re)) + (let* ((prompt-beg (match-beginning 2)) + (indent-beg (match-beginning 3)) (indent-end (match-end 3)) + (old-indent (- indent-end indent-beg)) + (new-indent (* (/ (- old-indent 1) 4) 4))) + (cond + ;; Indented source line: dedent it. + ((> old-indent 0) + (goto-char indent-beg) + (delete-region indent-beg indent-end) + (insert-char ?\ new-indent) + ;; Change prompt to PS1, when appropriate. + (when (and (= new-indent 0) (not (looking-at doctest-outdent-re))) + (delete-backward-char 4) + (insert-string ">>> "))) + ;; Non-indented source line: remove prompt. + (t + (goto-char indent-end) + (delete-region prompt-beg indent-end))))) + + ;; First non-ws char of a line: delete all indentation. + ((and (looking-at "[^ \n\t]\\|$") (doctest-looking-back "^[ \t]+")) + (delete-region (match-beginning 0) (match-end 0))) + + ;; Otherwise: delete a character. + (t + (backward-delete-char 1)))) + +(defun doctest-newline-and-indent () + "Insert a newline, and indent the new line appropriately. + +If the current line is a source line containing a bare prompt, +then clear the current line, and insert a newline. + +Otherwise, if the current line is a source line, then insert a +newline, and add an appropriately indented prompt to the new +line. + +Otherwise, if the current line is an output line, then insert a +newline and indent the new line to match the example's margin. + +Otherwise, insert a newline. + +If `doctest-avoid-trailing-whitespace' is true, then clear any +whitespace to the left of the point before inserting a newline. +" + (interactive "*") + ;; If we're avoiding trailing spaces, then delete WS before point. + (if doctest-avoid-trailing-whitespace + (delete-char (- (skip-chars-backward " \t")))) + (cond + ;; If we're on an empty prompt, delete it. + ((doctest-on-empty-source-line-p) + (delete-region (match-beginning 0) (match-end 0)) + (insert-char ?\n 1)) + ;; If we're on a doctest line, add a new prompt. + ((doctest-on-source-line-p) + (insert-char ?\n 1) + (doctest-indent-source-line)) + ;; If we're in doctest output, indent to the margin. + ((doctest-on-output-line-p) + (insert-char ?\n 1) + (insert-char ?\ (doctest-current-source-line-margin))) + ;; Otherwise, just add a newline. + (t (insert-char ?\n 1)))) + +(defun doctest-electric-colon () + "Insert a colon, and dedent the line when appropriate." + (interactive "*") + (insert-char ?: 1) + (when (doctest-on-source-line-p) + (doctest-indent-source-line t))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Code Execution +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun doctest-execute () + "Run doctest on the current buffer, or on the current docstring +if the point is inside an `mmm-mode' `doctest-docstring' region. +Display the results in the *doctest-output* buffer." + (interactive) + (doctest-execute-region (point-min) (point-max) nil t)) + +(defun doctest-execute-with-diff () + "Run doctest on the current buffer, or on the current docstring +if the point is inside an `mmm-mode' `doctest-docstring' region. +Display the results in the *doctest-output* buffer, using diff format." + (interactive) + (doctest-execute-region (point-min) (point-max) t t)) + +(defun doctest-execute-buffer-with-diff () + "Run doctest on the current buffer, and display the results in the +*doctest-output* buffer, using the diff format." + (interactive) + (doctest-execute-region (point-min) (point-max) t nil)) + +(defun doctest-execute-buffer () + "Run doctest on the current buffer, and display the results in the +*doctest-output* buffer." + (interactive) + (doctest-execute-region (point-min) (point-max) nil nil)) + +(defun doctest-execute-region (start end &optional diff + check-for-mmm-docstring-overlay) + "Run doctest on the current buffer, and display the results in the +*doctest-output* buffer." + (interactive "r") + ;; If it's already running, give the user a chance to restart it. + (when (doctest-process-live-p doctest-async-process) + (when (y-or-n-p "Doctest is already running. Restart it? ") + (doctest-cancel-async-process) + (message "Killing doctest..."))) + (cond + ((and doctest-async (doctest-process-live-p doctest-async-process)) + (message "Can't run two doctest processes at once!")) + (t + (let* ((results-buf-name (doctest-results-buffer-name)) + (in-docstring (and check-for-mmm-docstring-overlay + (doctest-in-mmm-docstring-overlay))) + (temp (doctest-temp-name)) (dir doctest-temp-directory) + (input-file (expand-file-name (concat temp ".py") dir)) + (globs-file (when in-docstring + (expand-file-name (concat temp "-globs.py") dir))) + (cur-buf (current-buffer)) + (in-buf (get-buffer-create "*doctest-input*")) + (script (doctest-script input-file globs-file diff))) + ;; If we're in a docstring, narrow start & end. + (when in-docstring + (let ((bounds (doctest-mmm-overlay-bounds))) + (setq start (max start (car bounds)) + end (min end (cdr bounds))))) + ;; Write the doctests to a file. + (save-excursion + (goto-char (min start end)) + (let ((lineno (doctest-line-number))) + (set-buffer in-buf) + ;; Add blank lines, to keep line numbers the same: + (dotimes (n (- lineno 1)) (insert-string "\n")) + ;; Add the selected region + (insert-buffer-substring cur-buf start end) + ;; Write it to a file + (write-file input-file))) + ;; If requested, write the buffer to a file for use as globs. + (when globs-file + (let ((cur-buf-start (point-min)) (cur-buf-end (point-max))) + (save-excursion + (set-buffer in-buf) + (delete-region (point-min) (point-max)) + (insert-buffer-substring cur-buf cur-buf-start cur-buf-end) + (write-file globs-file)))) + ;; Dispose of in-buf (we're done with it now. + (kill-buffer in-buf) + ;; Prepare the results buffer. Clear it, if it contains + ;; anything, and set its mode. + (setq doctest-results-buffer (get-buffer-create results-buf-name)) + (save-excursion + (set-buffer doctest-results-buffer) + (toggle-read-only 0) + (delete-region (point-min) (point-max)) + (doctest-results-mode) + (setq doctest-source-buffer cur-buf) + ) + ;; Add markers to examples, and record what line number each one + ;; starts at. That way, if the input buffer is edited, we can + ;; still find corresponding examples in the output. + (doctest-mark-examples) + + ;; Run doctest + (cond (doctest-async + ;; Asynchronous mode: + (let ((process (start-process "*doctest*" doctest-results-buffer + doctest-python-command + "-c" script))) + ;; Store some information about the process. + (setq doctest-async-process-buffer cur-buf) + (setq doctest-async-process process) + (push input-file doctest-async-process-tempfiles) + (when globs-file + (push globs-file doctest-async-process-tempfiles)) + ;; Set up a sentinel to respond when it's done running. + (set-process-sentinel process 'doctest-async-process-sentinel) + + ;; Show the output window. + (let ((w (display-buffer doctest-results-buffer))) + (when doctest-follow-output + ;; Insert a newline, which will move the buffer's + ;; point past the process's mark -- this causes the + ;; window to scroll as new output is generated. + (save-current-buffer + (set-buffer doctest-results-buffer) + (insert-string "\n") + (set-window-point w (point))))) + + ;; Let the user know the process is running. + (doctest-update-mode-line ":running") + (message "Running doctest..."))) + (t + ;; Synchronous mode: + (call-process doctest-python-command nil + doctest-results-buffer t "-c" script) + (doctest-handle-output) + (delete-file input-file) + (when globs-file + (delete-file globs-file)))))))) + +(defun doctest-handle-output () + "This function, which is called after the 'doctest' process spawned +by doctest-execute-buffer has finished, checks the doctest results +buffer. If that buffer is empty, it reports no errors and hides it; +if that buffer is not empty, it reports that errors occured, displays +the buffer, and runs doctest-postprocess-results." + ;; If any tests failed, display them. + (cond ((not (buffer-live-p doctest-results-buffer)) + (doctest-warn "Results buffer not found!")) + ((> (buffer-size doctest-results-buffer) 1) + (display-buffer doctest-results-buffer) + (doctest-postprocess-results) + (let ((num (length doctest-example-markers))) + (message "%d doctest example%s failed!" num + (if (= num 1) "" "s")))) + (t + (display-buffer doctest-results-buffer) + (delete-windows-on doctest-results-buffer) + (message "All doctest examples passed!")))) + +(defun doctest-async-process-sentinel (process state) + "A process sentinel, called when the asynchronous doctest process +completes, which calls doctest-handle-output." + ;; Check to make sure we got the process we're expecting. On + ;; some operating systems, this will end up getting called twice + ;; when we use doctest-cancel-async-process; this check keeps us + ;; from trying to clean up after the same process twice (since we + ;; set doctest-async-process to nil when we're done). + (when (and (equal process doctest-async-process) + (buffer-live-p doctest-async-process-buffer)) + (save-current-buffer + (set-buffer doctest-async-process-buffer) + (cond ((not (buffer-live-p doctest-results-buffer)) + (doctest-warn "Results buffer not found!")) + ((equal state "finished\n") + (doctest-handle-output) + (let ((window (get-buffer-window + doctest-async-process-buffer t))) + (when window (set-window-point window (point))))) + ((equal state "killed\n") + (message "Doctest killed.")) + (t + (message "Doctest failed -- %s" state) + (display-buffer doctest-results-buffer))) + (doctest-update-mode-line "") + (while doctest-async-process-tempfiles + (delete-file (pop doctest-async-process-tempfiles))) + (setq doctest-async-process nil)))) + +(defun doctest-cancel-async-process () + "If a doctest process is running, then kill it." + (interactive "") + (when (doctest-process-live-p doctest-async-process) + ;; Update the modeline + (doctest-update-mode-line ":killing") + ;; Kill the process. + (kill-process doctest-async-process) + ;; Run the sentinel. (Depending on what OS we're on, the sentinel + ;; may end up getting called once or twice.) + (doctest-async-process-sentinel doctest-async-process "killed\n") + )) + +(defun doctest-postprocess-results () + "Post-process the doctest results buffer: check what version of +doctest was used, and set doctest-results-py-version accordingly; +turn on read-only mode; filter the example markers; hide the example +source (if `doctest-hide-example-source' is non-nil); and select the +first failure." + (save-excursion + (set-buffer doctest-results-buffer) + ;; Check if we're using an old doctest version. + (goto-char (point-min)) + (if (re-search-forward doctest-py21-results-re nil t) + (setq doctest-results-py-version 'py21) + (setq doctest-results-py-version 'py24)) + ;; Turn on read-only mode. + (toggle-read-only t)) + + (doctest-filter-example-markers) + (if doctest-hide-example-source + (doctest-hide-example-source)) + (doctest-next-failure 1)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Markers +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun doctest-mark-examples () + "Add a marker at the beginning of every (likely) example in the +input buffer; and create a list, `doctest-example-markers', +which maps from markers to the line numbers they originally occured +on. This will allow us to find the corresponding example in the +doctest output, even if the input buffer is edited." + (dolist (marker-info doctest-example-markers) + (set-marker (car marker-info) nil)) + (setq doctest-example-markers '()) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "^ *>>> " nil t) + (backward-char 4) + (push (cons (point-marker) (doctest-line-number)) + doctest-example-markers) + (forward-char 4)))) + +(defun doctest-filter-example-markers () + "Remove any entries from `doctest-example-markers' that do not +correspond to a failed example." + (let ((filtered nil) (markers doctest-example-markers)) + (save-excursion + (set-buffer doctest-results-buffer) + (goto-char (point-max)) + (while (re-search-backward (doctest-results-loc-re) nil t) + (let ((lineno (string-to-int (match-string 1)))) + (when (equal doctest-results-py-version 'py21) + (setq lineno (+ lineno 1))) + (while (and markers (< lineno (cdar markers))) + (set-marker (caar markers) nil) + (setq markers (cdr markers))) + (if (and markers (= lineno (cdar markers))) + (push (pop markers) filtered) + (doctest-warn "Example expected on line %d but not found %s" + lineno markers))))) + (dolist (marker-info markers) + (set-marker (car marker-info) nil)) + (setq doctest-example-markers filtered))) + +(defun doctest-prev-example-marker () + "Helper for doctest-replace-output: move to the preceeding example +marker, and return the corresponding 'original' lineno. If none is +found, return nil." + (let ((lineno nil) + (pos nil)) + (save-excursion + (end-of-line) + (when (re-search-backward "^\\( *\\)>>> " nil t) + (goto-char (match-end 1)) + (dolist (marker-info doctest-example-markers) + (when (= (marker-position (car marker-info)) (point)) + (setq lineno (cdr marker-info)) + (setq pos (point)))))) + (unless (null lineno) + (goto-char pos) + lineno))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Navigation +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun doctest-next-failure (count) + "Move to the top of the next failing example, and highlight the +example's failure description in *doctest-output*." + (interactive "p") + (cond + ((and doctest-async (doctest-process-live-p doctest-async-process)) + (message "Wait for doctest to finish running!")) + ((not (doctest-results-buffer-valid-p)) + (message "Run doctest first! (C-c C-c)")) + ((equal count 0) + t) + (t + (let ((marker nil) (example-markers doctest-example-markers) + (results-window (display-buffer doctest-results-buffer))) + (save-excursion + (set-buffer doctest-results-buffer) + ;; Pick up where we left off. + ;; (nb: doctest-selected-failure is buffer-local) + (goto-char (or doctest-selected-failure (point-min))) + ;; Skip past anything on *this* line. + (if (>= count 0) (end-of-line) (beginning-of-line)) + ;; Look for the next failure + (when + (if (>= count 0) + (re-search-forward (doctest-results-loc-re) nil t count) + (re-search-backward (doctest-results-loc-re) nil t (- count))) + ;; We found a failure: + (let ((old-selected-failure doctest-selected-failure)) + (beginning-of-line) + ;; Extract the line number for the doctest file. + (let ((orig-lineno (string-to-int (match-string 1)))) + (when (equal doctest-results-py-version 'py21) + (setq orig-lineno (+ orig-lineno 1))) + (dolist (marker-info example-markers) + (when (= orig-lineno (cdr marker-info)) + (setq marker (car marker-info))))) + + ;; Update the window cursor. + (beginning-of-line) + (set-window-point results-window (point)) + ;; Store our position for next time. + (setq doctest-selected-failure (point)) + ;; Update selection. + (doctest-fontify-line old-selected-failure) + (doctest-fontify-line doctest-selected-failure)))) + + (cond + ;; We found a failure -- move point to the selected failure. + (marker + (goto-char (marker-position marker)) + (beginning-of-line)) + ;; We didn't find a failure, but there is one -- wrap. + ((> (length doctest-example-markers) 0) + (if (>= count 0) (doctest-first-failure) (doctest-last-failure))) + ;; We didn't find a failure -- alert the user. + (t (message "No failures found!"))))))) + +(defun doctest-prev-failure (count) + "Move to the top of the previous failing example, and highlight +the example's failure description in *doctest-output*." + (interactive "p") + (doctest-next-failure (- count))) + +(defun doctest-first-failure () + "Move to the top of the first failing example, and highlight +the example's failure description in *doctest-output*." + (interactive) + (if (buffer-live-p doctest-results-buffer) + (save-excursion + (set-buffer doctest-results-buffer) + (let ((old-selected-failure doctest-selected-failure)) + (setq doctest-selected-failure (point-min)) + (doctest-fontify-line old-selected-failure)))) + (doctest-next-failure 1)) + +(defun doctest-last-failure () + "Move to the top of the last failing example, and highlight +the example's failure description in *doctest-output*." + (interactive) + (if (buffer-live-p doctest-results-buffer) + (save-excursion + (set-buffer doctest-results-buffer) + (let ((old-selected-failure doctest-selected-failure)) + (setq doctest-selected-failure (point-max)) + (doctest-fontify-line old-selected-failure)))) + (doctest-next-failure -1)) + +(defun doctest-select-failure () + "Move to the top of the currently selected example, and select that +example in the source buffer. Intended for use in the results +buffer." + (interactive) + (re-search-backward doctest-results-divider-re) + (let ((old-selected-failure doctest-selected-failure)) + (setq doctest-selected-failure (point)) + (doctest-fontify-line doctest-selected-failure) + (doctest-fontify-line old-selected-failure)) + (pop-to-buffer doctest-source-buffer) + (doctest-next-failure 1)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Replace Output +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun doctest-replace-output () + "Move to the top of the closest example, and replace its output +with the 'got' output from the *doctest-output* buffer. An error is +displayed if the chosen example is not listed in *doctest-output*, or +if the 'expected' output for the example does not exactly match the +output listed in the source buffer. The user is asked to confirm the +replacement." + (interactive) + ;; Move to the beginning of the example. + (cond + ((and doctest-async (doctest-process-live-p doctest-async-process)) + (message "Wait for doctest to finish running!")) + ((not (doctest-results-buffer-valid-p)) + (message "Run doctest first! (C-c C-c)")) + ((save-excursion (set-buffer doctest-results-buffer) + (equal doctest-results-py-version 'py21)) + (error "doctest-replace-output requires python 2.4+")) + (t + (save-excursion + (save-restriction + (when (doctest-in-mmm-docstring-overlay) + (doctest-narrow-to-mmm-overlay)) + + (let* ((orig-buffer (current-buffer)) + ;; Find an example, and look up its original lineno. + (lineno (doctest-prev-example-marker)) + ;; Find the example's indentation. + (prompt-indent (doctest-line-indentation))) + + ;; Switch to the output buffer, and look for the example. + ;; If we don't find one, complain. + (cond + ((null lineno) (message "Doctest example not found")) + (t + (set-buffer doctest-results-buffer) + (goto-char (point-min)) + (let ((output-re (format "^File .*, line %s," lineno))) + (when (not (re-search-forward output-re nil t)) + (message "This doctest example did not fail") + (setq lineno nil))))) + + ;; If we didn't find an example, give up. + (when (not (null lineno)) + ;; Get the output's 'expected' & 'got' texts. + (let ((doctest-got nil) (doctest-expected nil) (header nil)) + (while (setq header (doctest-results-next-header)) + (cond + ((equal header "Failed example:") + t) + ((equal header "Expected nothing") + (setq doctest-expected "")) + ((equal header "Expected:") + (unless (re-search-forward "^\\(\\( \\).*\n\\)*" nil t) + (error "Error parsing doctest output")) + (setq doctest-expected (doctest-replace-regexp-in-string + "^ " prompt-indent + (match-string 0)))) + ((equal header "Got nothing") + (setq doctest-got "")) + ((or (equal header "Got:") (equal header "Exception raised:")) + (unless (re-search-forward "^\\(\\( \\).*\n\\)*" nil t) + (error "Error parsing doctest output")) + (setq doctest-got (doctest-replace-regexp-in-string + "^ " prompt-indent (match-string 0)))) + ((string-match "^Differences" header) + (error (concat "doctest-replace-output can not be used " + "with diff style output"))) + (t (error "Unexpected header %s" header)))) + + ;; Go back to the source buffer. + (set-buffer orig-buffer) + + ;; Skip ahead to the output. + (beginning-of-line) + (unless (re-search-forward "^ *>>>.*") + (error "Error parsing doctest output")) + (re-search-forward "\\(\n *\\.\\.\\..*\\)*\n?") + (when (looking-at "\\'") (insert-char ?\n)) + + ;; Check that the output matches. + (let ((start (point)) end) + (cond ((re-search-forward "^ *\\(>>>.*\\|$\\)" nil t) + (setq end (match-beginning 0))) + (t + (goto-char (point-max)) + (insert-string "\n") + (setq end (point-max)))) + (when (and doctest-expected + (not (equal (buffer-substring start end) + doctest-expected))) + (warn "{%s} {%s}" (buffer-substring start end) + doctest-expected) + (error (concat "This example's output has been modified " + "since doctest was last run"))) + (setq doctest-expected (buffer-substring start end)) + (goto-char end)) + + ;; Trim exceptions + (when (and doctest-trim-exceptions + (string-match doctest-traceback-re + doctest-got)) + (let ((s1 0) (e1 (match-end 1)) + (s2 (match-beginning 2)) (e2 (match-end 2)) + (s3 (match-beginning 3)) (e3 (length doctest-got))) + (setq doctest-got + (concat (substring doctest-got s1 e1) + (substring doctest-got s2 e2) " . . .\n" + (substring doctest-got s3 e3))))) + + ;; Confirm it with the user. + (let ((confirm-buffer (get-buffer-create "*doctest-confirm*"))) + (set-buffer confirm-buffer) + ;; Erase anything left over in the buffer. + (delete-region (point-min) (point-max)) + ;; Write a confirmation message + (if (equal doctest-expected "") + (insert-string "Replace nothing\n") + (insert-string (concat "Replace:\n" doctest-expected))) + (if (equal doctest-got "") + (insert-string "With nothing\n") + (insert-string (concat "With:\n" doctest-got))) + (let ((confirm-window (display-buffer confirm-buffer))) + ;; Shrink the confirm window. + (shrink-window-if-larger-than-buffer confirm-window) + ;; Return to the original buffer. + (set-buffer orig-buffer) + ;; Match the old expected region. + (when doctest-expected + (search-backward doctest-expected)) + (when (equal doctest-expected "") (backward-char 1)) + ;; Get confirmation & do the replacement + (widen) + (cond ((y-or-n-p "Ok to replace? ") + (when (equal doctest-expected "") (forward-char 1)) + (replace-match doctest-got t t) + (message "Replaced.")) + (t + (message "Replace cancelled."))) + ;; Clean up our confirm window + (kill-buffer confirm-buffer) + (delete-window confirm-window))))))))))) + +(defun doctest-results-next-header () + "Move to the next header in the doctest results buffer, and return +the string contents of that header. If no header is found, return +nil." + (if (re-search-forward (concat doctest-results-header-re "\\|" + doctest-results-divider-re) nil t) + (let ((result (match-string 0))) + (if (string-match doctest-results-header-re result) + result + nil)) + nil)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; mmm-mode support +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; MMM Mode is a minor mode for Emacs which allows Multiple Major +;; Modes to coexist in a single buffer. + +;;;###autoload +(defun doctest-register-mmm-classes (&optional add-mode-ext-classes + fix-mmm-fontify-region-bug) + "Register doctest's mmm classes, allowing doctest to be used as a +submode region in other major modes, such as python-mode and rst-mode. +Two classes are registered: + +`doctest-docstring' + + Used to edit docstrings containing doctest examples in python- + mode. Docstring submode regions start and end with triple-quoted + strings (\"\"\"). In order to avoid confusing start-string + markers and end-string markers, all triple-quote strings in the + buffer are treated as submode regions (even if they're not + actually docstrings). Use (C-c % C-d) to insert a new doctest- + docstring region. When `doctest-execute' (C-c C-c) is called + inside a doctest-docstring region, it executes just the current + docstring. The globals for this execution are constructed by + importing the current buffer's contents in Python. + +`doctest-example' + + Used to edit doctest examples in text-editing modes, such as + `rst-mode' or `text-mode'. Docstring submode regions start with + optionally indented prompts (>>>) and end with blank lines. Use + (C-c % C-e) to insert a new doctest-example region. When + `doctest-execute' (C-c C-c) is called inside a doctest-example + region, it executes all examples in the buffer. + +If ADD-MODE-EXT-CLASSES is true, then register the new classes in +`mmm-mode-ext-classes-alist', which will cause them to be used by +default in the following modes: + + doctest-docstring: python-mode + doctest-example: rst-mode + +If FIX-MMM-FONTIFY-REGION-BUG is true, then register a hook that will +fix a bug in `mmm-fontify-region' that affects some (but not all) +versions of emacs. (See `doctest-fixed-mmm-fontify-region' for more +info.)" + (interactive) + (require 'mmm-auto) + (mmm-add-classes + '( + ;; === doctest-docstring === + (doctest-docstring :submode doctest-mode + + ;; The front is any triple-quote. Include it in the submode region, + ;; to prevent clashes between the two syntax tables over quotes. + :front "\\(\"\"\"\\|'''\\)" :include-front t + + ;; The back matches the front. Include just the first character + ;; of the quote. If we didn't include at least one quote, then + ;; the outer modes quote-counting would be thrown off. But if + ;; we include all three, we run into a bug in mmm-mode. See + ;; for more info about the bug. + :save-matches t :back "~1" :back-offset 1 :end-not-begin t + + ;; Define a skeleton for entering new docstrings. + :insert ((?d docstring nil @ "\"\"" @ "\"" \n + _ \n "\"" @ "\"\"" @))) + + ;; === doctest-example === + (doctest-example + :submode doctest-mode + ;; The front is an optionally indented prompt. + :front "^[ \t]*>>>" :include-front t + ;; The back is a blank line. + :back "^[ \t]*$" + ;; Define a skeleton for entering new docstrings. + :insert ((?e doctest-example nil + @ @ " >>> " _ "\n\n" @ @))))) + + ;; Register some local variables that need to be saved. + (add-to-list 'mmm-save-local-variables + '(doctest-results-buffer buffer)) + (add-to-list 'mmm-save-local-variables + '(doctest-example-markers buffer)) + + ;; Register association with modes, if requested. + (when add-mode-ext-classes + (mmm-add-mode-ext-class 'python-mode nil 'doctest-docstring) + (mmm-add-mode-ext-class 'rst-mode nil 'doctest-example)) + + ;; Fix the buggy mmm-fontify-region, if requested. + (when fix-mmm-fontify-region-bug + (add-hook 'mmm-mode-hook 'doctest-fix-mmm-fontify-region-bug))) + +(defvar doctest-old-mmm-fontify-region 'nil + "Used to hold the original definition of `mmm-fontify-region' when it +is rebound by `doctest-fix-mmm-fontify-region-bug'.") + +(defun doctest-fix-mmm-fontify-region-bug () + "A function for `mmm-mode-hook' which fixes a potential bug in +`mmm-fontify-region' by using `doctest-fixed-mmm-fontify-region' +instead. (See `doctest-fixed-mmm-fontify-region' for more info.)" + (setq font-lock-fontify-region-function + 'doctest-fixed-mmm-fontify-region)) + +(defun doctest-fixed-mmm-fontify-region (start stop &optional loudly) + "A replacement for `mmm-fontify-region', which fixes a bug caused by +versions of emacs where post-command-hooks are run *before* +fontification. `mmm-mode' assumes that its post-command-hook will be +run after fontification; and if it's not, then mmm-mode can end up +with the wrong local variables, keymap, etc. after fontification. We +fix that here by redefining `mmm-fontify-region' to remember what +submode overlay it started in; and to return to that overlay after +fontification is complete. The original definition of +`mmm-fontify-region' is stored in `doctest-old-mmm-fontify-region'." + (let ((overlay mmm-current-overlay)) + (mmm-fontify-region start stop loudly) + (if (and overlay (or (< (point) (overlay-start overlay)) + (> (point) (overlay-end overlay)))) + (goto-char (overlay-start overlay))) + (mmm-update-submode-region))) + +(defun doctest-in-mmm-docstring-overlay () + (and (featurep 'mmm-auto) + (mmm-overlay-at (point)) + (save-excursion + (goto-char (overlay-start (mmm-overlay-at (point)))) + (looking-at "\"\"\"\\|\'\'\'")))) + +(defun doctest-narrow-to-mmm-overlay () + "If we're in an mmm-mode overlay, then narrow to that overlay. +This is useful, e.g., to keep from interpreting the close-quote of a +docstring as part of the example's output." + (let ((bounds (doctest-mmm-overlay-bounds))) + (when bounds (narrow-to-region (car bounds) (cdr bounds))))) + +(defun doctest-default-margin-in-mmm-docstring-overlay () + (save-excursion + (let ((pos (car (doctest-mmm-overlay-bounds)))) + (goto-char pos) + (when (doctest-looking-back "\"\"\"\\|\'\'\'") + (setq pos (- pos 3))) + (beginning-of-line) + (- pos (point))))) + +(defun doctest-mmm-overlay-bounds () + (when (featurep 'mmm-auto) + (let ((overlay (mmm-overlay-at (point)))) + (when overlay + (let ((start (overlay-start overlay)) + (end (overlay-end overlay))) + (when (doctest-in-mmm-docstring-overlay) + (save-excursion + (goto-char start) + (re-search-forward "[\"\']*") + (setq start (point)) + (goto-char end) + (while (doctest-looking-back "[\"\']") + (backward-char 1)) + (setq end (point)))) + (cons start end)))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Helper functions +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun doctest-on-source-line-p (&optional prompt) + "Return true if the current line is a source line. The optional +argument prompt can be used to specify which type of source +line (... or >>>)." + (save-excursion + (beginning-of-line) + ;; Check if we're looking at a prompt (of the right type). + (when (and (looking-at doctest-prompt-re) + (or (null prompt) + (equal prompt (substring (match-string 2) 0 3)))) + ;; Scan backwards to make sure there's a >>> somewhere. Otherwise, + ;; this might be a '...' in the text or in an example's output. + (while (looking-at "^[ \t]*[.][.][.]") + (forward-line -1)) + (looking-at "^[ \t]*>>>")))) + +(defun doctest-on-empty-source-line-p () + "Return true if the current line contains a bare prompt." + (save-excursion + (beginning-of-line) + (and (doctest-on-source-line-p) + (looking-at (concat doctest-prompt-re "$"))))) + +(defun doctest-on-output-line-p () + "Return true if the current line is an output line." + (save-excursion + (beginning-of-line) + ;; The line must not be blank or a source line. + (when (not (or (doctest-on-source-line-p) (looking-at "[ \t]*$"))) + ;; The line must follow a source line, with no intervening blank + ;; lines. + (while (not (or (doctest-on-source-line-p) (looking-at "[ \t]*$") + (= (point) (point-min)))) + (forward-line -1)) + (doctest-on-source-line-p)))) + +(defun doctest-find-output-line (&optional limit) + "Move forward to the next doctest output line (staying within +the given bounds). Return the character position of the doctest +output line if one was found, and false otherwise." + (let ((found-it nil) ; point where we found an output line + (limit (or limit (point-max)))) ; default value for limit + (save-excursion + ;; Keep moving forward, one line at a time, until we find a + ;; doctest output line. + (while (and (not found-it) (< (point) limit) (not (eobp))) + (if (and (not (eolp)) (doctest-on-output-line-p)) + (setq found-it (point)) + (forward-line)))) + ;; If we found a doctest output line, then go to it. + (if found-it (goto-char found-it)))) + +(defun doctest-line-indentation () + "Helper for doctest-replace-output: return the whitespace indentation +at the beginning of this line." + (save-excursion + (end-of-line) + (re-search-backward "^\\( *\\)" nil t) + (match-string 1))) + +(defun doctest-optionflags (&optional diff) + "Return a string describing the optionflags that should be used +by doctest. If DIFF is non-nil, then add the REPORT_UDIFF flag." + (let ((flags "0")) + (dolist (flag doctest-optionflags) + (setq flags (concat flags "|" flag))) + (if diff (concat flags "|" "REPORT_UDIFF") flags))) + +(defun doctest-results-loc-re () + "Return the regexp that should be used to look for doctest example +location markers in doctest's output (based on which version of +doctest was used" + (cond + ((equal doctest-results-py-version 'py21) + doctest-py21-results-loc-re) + ((equal doctest-results-py-version 'py24) + doctest-py24-results-loc-re) + (t (error "bad value for doctest-results-py-version")))) + +(defun doctest-results-buffer-name () + "Return the buffer name that should be used for the doctest results +buffer. This is computed from the variable +`doctest-results-buffer-name'." + (doctest-replace-regexp-in-string + "%[nfN]" + (lambda (sym) + (cond ((equal sym "%n") (buffer-name)) + ((equal sym "%N") (doctest-replace-regexp-in-string + "[.]doctest$" "" (buffer-name) t)) + ((equal sym "%f") (buffer-file-name)))) + doctest-results-buffer-name t)) + +(defun doctest-script (input-file globs-file diff) + "..." + (doctest-replace-regexp-in-string + "%[tnflm]" + (lambda (sym) + (cond ((equal sym "%n") (buffer-name)) + ((equal sym "%f") (buffer-file-name)) + ((equal sym "%l") (doctest-optionflags diff)) + ((equal sym "%t") input-file) + ((equal sym "%m") (or globs-file "")))) + doctest-script t)) + +(defun doctest-hide-example-source () + "Delete the source code listings from the results buffer (since it's +easy enough to see them in the original buffer)" + (save-excursion + (set-buffer doctest-results-buffer) + (toggle-read-only 0) + (goto-char (point-min)) + (while (re-search-forward doctest-example-source-re nil t) + (replace-match "" nil nil)) + (toggle-read-only t))) + +(defun doctest-results-buffer-valid-p () + "Return true if this buffer has a live results buffer; and that +results buffer reports this buffer as its source buffer. (Two +buffers in doctest-mode might point to the same results buffer; +but only one of them will be equal to that results buffer's +source buffer." + (let ((cur-buf (current-buffer))) + (and (buffer-live-p doctest-results-buffer) + (save-excursion + (set-buffer doctest-results-buffer) + (equal cur-buf doctest-source-buffer))))) + +(defun doctest-update-mode-line (value) + "Update the doctest mode line with the given string value. This +is used to display information about asynchronous processes that +are run by doctest-mode." + (setq doctest-mode-line-process + value) + (force-mode-line-update t)) + +(defun doctest-version () + "Echo the current version of `doctest-mode' in the minibuffer." + (interactive) + (message "Using `doctest-mode' version %s" doctest-version)) + +(defun doctest-warn (msg &rest args) + "Display a doctest warning message." + (if (fboundp 'display-warning) + (display-warning 'doctest (apply 'format msg args)) + (apply 'message msg args))) + +(defun doctest-debug (msg &rest args) + "Display a doctest debug message." + (if (fboundp 'display-warning) + (display-warning 'doctest (apply 'format msg args) 'debug) + (apply 'message msg args))) + +(defvar doctest-serial-number 0) ;used if broken-temp-names. +(defun doctest-temp-name () + "Return a new temporary filename, for use in calling doctest." + (if (memq 'broken-temp-names features) + (let + ((sn doctest-serial-number) + (pid (and (fboundp 'emacs-pid) (emacs-pid)))) + (setq doctest-serial-number (1+ doctest-serial-number)) + (if pid + (format "doctest-%d-%d" sn pid) + (format "doctest-%d" sn))) + (make-temp-name "doctest-"))) + +(defun doctest-fontify-line (charpos) + "Run font-lock-fontify-region on the line containing the given +position." + (if (and charpos (functionp 'font-lock-fontify-region)) + (save-excursion + (goto-char charpos) + (let ((beg (progn (beginning-of-line) (point))) + (end (progn (end-of-line) (point)))) + (font-lock-fontify-region beg end))))) + +(defun doctest-do-auto-fill () + "If the current line is a soucre line or an output line, do nothing. +Otherwise, call (do-auto-fill)." + (cond + ;; Don't wrap source lines. + ((doctest-on-source-line-p) nil) + ;; Don't wrap output lines + ((doctest-on-output-line-p) nil) + ;; Wrap all other lines + (t (do-auto-fill)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Emacs Compatibility Functions +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Define compatible versions of functions that are defined +;; for some versions of emacs but not others. + +;; Backwards compatibility: looking-back +(cond ((fboundp 'looking-back) ;; Emacs 22.x + (defalias 'doctest-looking-back 'looking-back)) + (t + (defun doctest-looking-back (regexp) + "Return true if text before point matches REGEXP." + (save-excursion + (let ((orig-pos (point))) + ;; Search backwards for the regexp. + (if (re-search-backward regexp nil t) + ;; Check if it ends at the original point. + (= orig-pos (match-end 0)))))))) + +;; Backwards compatibility: replace-regexp-in-string +(cond ((fboundp 'replace-regexp-in-string) + (defalias 'doctest-replace-regexp-in-string 'replace-regexp-in-string)) + (t ;; XEmacs 21.x or Emacs 20.x + (defun doctest-replace-regexp-in-string + (regexp rep string &optional fixedcase literal) + "Replace all matches for REGEXP with REP in STRING." + (let ((start 0)) + (while (and (< start (length string)) + (string-match regexp string start)) + (setq start (+ (match-end 0) 1)) + (let ((newtext (if (functionp rep) + (save-match-data + (funcall rep (match-string 0 string))) + rep))) + (setq string (replace-match newtext fixedcase + literal string))))) + string))) + +;; Backwards compatibility: line-number +(cond ((fboundp 'line-number) ;; XEmacs + (defalias 'doctest-line-number 'line-number)) + ((fboundp 'line-number-at-pos) ;; Emacs 22.x + (defalias 'doctest-line-number 'line-number-at-pos)) + (t ;; Emacs 21.x + (defun doctest-line-number (&optional pos) + "Return the line number of POS (default=point)." + (1+ (count-lines 1 + (save-excursion (progn (beginning-of-line) + (or pos (point))))))))) + +;; Backwards compatibility: process-live-p +(cond ((fboundp 'process-live-p) ;; XEmacs + (defalias 'doctest-process-live-p 'process-live-p)) + (t ;; Emacs + (defun doctest-process-live-p (process) + (and (processp process) + (equal (process-status process) 'run))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Doctest Results Mode (output of doctest-execute-buffer) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; Register the font-lock keywords (xemacs) +(put 'doctest-results-mode 'font-lock-defaults + '(doctest-results-font-lock-keywords)) + +;; Register the font-lock keywords (older versions of gnu emacs) +(when (boundp 'font-lock-defaults-alist) + (add-to-list 'font-lock-defaults-alist + '(doctest-results-mode doctest-results-font-lock-keywords + nil nil nil nil))) + +(defvar doctest-selected-failure nil + "The location of the currently selected failure. +This variable is uffer-local to doctest-results-mode buffers.") + +(defvar doctest-source-buffer nil + "The buffer that spawned this one. +This variable is uffer-local to doctest-results-mode buffers.") + +(defvar doctest-results-py-version nil + "A symbol indicating which version of Python was used to generate +the results in a doctest-results-mode buffer. Can be either the +symbol `py21' or the symbol `py24'. +This variable is uffer-local to doctest-results-mode buffers.") + +;; Keymap for doctest-results-mode. +(defconst doctest-results-mode-map + (let ((map (make-keymap))) + (define-key map [return] 'doctest-select-failure) + map) + "Keymap for doctest-results-mode.") + +;; Syntax table for doctest-results-mode. +(defvar doctest-results-mode-syntax-table nil + "Syntax table used in `doctest-results-mode' buffers.") +(when (not doctest-results-mode-syntax-table) + (setq doctest-results-mode-syntax-table (make-syntax-table)) + (dolist (entry '(("(" . "()") ("[" . "(]") ("{" . "(}") + (")" . ")(") ("]" . ")[") ("}" . "){") + ("$%&*+-/<=>|'\"`" . ".") ("_" . "w"))) + (dolist (char (string-to-list (car entry))) + (modify-syntax-entry char (cdr entry) + doctest-results-mode-syntax-table)))) + +;; Define the mode +(defun doctest-results-mode () + "A major mode used to display the results of running doctest. +See `doctest-mode'. + +\\{doctest-results-mode-map}" + (interactive) + + ;; Declare local variables. + (kill-all-local-variables) + (make-local-variable 'font-lock-defaults) + (make-local-variable 'doctest-selected-failure) + (make-local-variable 'doctest-source-buffer) + (make-local-variable 'doctest-results-py-version) + + ;; Define local variables. + (setq major-mode 'doctest-results-mode + mode-name "Doctest-Results" + mode-line-process 'doctest-mode-line-process + font-lock-defaults '(doctest-results-font-lock-keywords + nil nil nil nil)) + ;; Define keymap. + (use-local-map doctest-results-mode-map) + + ;; Define the syntax table. + (set-syntax-table doctest-results-mode-syntax-table) + + ;; Enable font-lock mode. + (if (featurep 'font-lock) (font-lock-mode 1))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Doctest Mode +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; Register the font-lock keywords (xemacs) +(put 'doctest-mode 'font-lock-defaults '(doctest-font-lock-keywords + nil nil nil nil)) + +;; Register the font-lock keywords (older versions of gnu emacs) +(when (boundp 'font-lock-defaults-alist) + (add-to-list 'font-lock-defaults-alist + '(doctest-mode doctest-font-lock-keywords + nil nil nil nil))) + +(defvar doctest-results-buffer nil + "The output buffer for doctest-mode. +This variable is buffer-local to doctest-mode buffers.") + +(defvar doctest-example-markers nil + "A list mapping markers to the line numbers at which they appeared +in the buffer at the time doctest was last run. This is used to find +'original' line numbers, which can be used to search the doctest +output buffer. It's encoded as a list of (MARKER . POS) tuples, in +reverse POS order. +This variable is buffer-local to doctest-mode buffers.") + +;; These are global, since we only one run process at a time: +(defvar doctest-async-process nil + "The process object created by the asynchronous doctest process") +(defvar doctest-async-process-tempfiles nil + "A list of tempfile names created by the asynchronous doctest process") +(defvar doctest-async-process-buffer nil + "The source buffer for the asynchronous doctest process") +(defvar doctest-mode-line-process "" + "A string displayed on the modeline, to indicate when doctest is +running asynchronously.") + +;; Keymap for doctest-mode. n.b.: we intentionally define [tab] +;; rather than overriding indent-line-function, since we don't want +;; doctest-indent-source-line to be called by do-auto-fill. +(defconst doctest-mode-map + (let ((map (make-keymap))) + (define-key map [backspace] 'doctest-electric-backspace) + (define-key map [return] 'doctest-newline-and-indent) + (define-key map [tab] 'doctest-indent-source-line) + (define-key map ":" 'doctest-electric-colon) + (define-key map "\C-c\C-v" 'doctest-version) + (define-key map "\C-c\C-c" 'doctest-execute) + (define-key map "\C-c\C-d" 'doctest-execute-with-diff) + (define-key map "\C-c\C-n" 'doctest-next-failure) + (define-key map "\C-c\C-p" 'doctest-prev-failure) + (define-key map "\C-c\C-a" 'doctest-first-failure) + (define-key map "\C-c\C-e" 'doctest-last-failure) + (define-key map "\C-c\C-z" 'doctest-last-failure) + (define-key map "\C-c\C-r" 'doctest-replace-output) + (define-key map "\C-c|" 'doctest-execute-region) + map) + "Keymap for doctest-mode.") + +;; Syntax table for doctest-mode. +(defvar doctest-mode-syntax-table nil + "Syntax table used in `doctest-mode' buffers.") +(when (not doctest-mode-syntax-table) + (setq doctest-mode-syntax-table (make-syntax-table)) + (dolist (entry '(("(" . "()") ("[" . "(]") ("{" . "(}") + (")" . ")(") ("]" . ")[") ("}" . "){") + ("$%&*+-/<=>|'\"`" . ".") ("_" . "w"))) + (dolist (char (string-to-list (car entry))) + (modify-syntax-entry char (cdr entry) doctest-mode-syntax-table)))) + +;; Use doctest mode for files ending in .doctest +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.doctest$" . doctest-mode)) + +;;;###autoload +(defun doctest-mode () + "A major mode for editing text files that contain Python +doctest examples. Doctest is a testing framework for Python that +emulates an interactive session, and checks the result of each +command. For more information, see the Python library reference: + + +`doctest-mode' defines three kinds of line, each of which is +treated differently: + + - 'Source lines' are lines consisting of a Python prompt + ('>>>' or '...'), followed by source code. Source lines are + colored (similarly to `python-mode') and auto-indented. + + - 'Output lines' are non-blank lines immediately following + source lines. They are colored using several doctest- + specific output faces. + + - 'Text lines' are any other lines. They are not processed in + any special way. + +\\{doctest-mode-map}" + (interactive) + + ;; Declare local variables. + (kill-all-local-variables) + (make-local-variable 'font-lock-defaults) + (make-local-variable 'doctest-results-buffer) + (make-local-variable 'doctest-example-markers) + + ;; Define local variables. + (setq major-mode 'doctest-mode + mode-name "Doctest" + mode-line-process 'doctest-mode-line-process + font-lock-defaults '(doctest-font-lock-keywords + nil nil nil nil)) + + ;; Define keymap. + (use-local-map doctest-mode-map) + + ;; Define the syntax table. + (set-syntax-table doctest-mode-syntax-table) + + ;; Enable auto-fill mode. + (auto-fill-mode 1) + (setq auto-fill-function 'doctest-do-auto-fill) + + ;; Enable font-lock mode. + (if (featurep 'font-lock) (font-lock-mode 1)) + + ;; Run the mode hook. + (run-hooks 'doctest-mode-hook)) + +(provide 'doctest-mode) +;;; doctest-mode.el ends here diff --git a/conf/emacs.d/init_python.el b/conf/emacs.d/init_python.el new file mode 100644 index 0000000..d7b6e59 --- /dev/null +++ b/conf/emacs.d/init_python.el @@ -0,0 +1,99 @@ +(autoload 'python-mode "python-mode" "Python Mode." t) +(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) +(add-to-list 'interpreter-mode-alist '("python" . python-mode)) +(require 'python-mode) +(add-hook 'python-mode-hook + (lambda () + (set-variable 'py-indent-offset 4) + ;(set-variable 'py-smart-indentation nil) + (set-variable 'indent-tabs-mode nil) + (define-key py-mode-map (kbd "RET") 'newline-and-indent) + ;(define-key py-mode-map [tab] 'yas/expand) + ;(setq yas/after-exit-snippet-hook 'indent-according-to-mode) + (smart-operator-mode-on) + )) +;; pymacs +(autoload 'pymacs-apply "pymacs") +(autoload 'pymacs-call "pymacs") +(autoload 'pymacs-eval "pymacs" nil t) +(autoload 'pymacs-exec "pymacs" nil t) +(autoload 'pymacs-load "pymacs" nil t) +;;(eval-after-load "pymacs" +;; '(add-to-list 'pymacs-load-path YOUR-PYMACS-DIRECTORY")) +(pymacs-load "ropemacs" "rope-") +(setq ropemacs-enable-autoimport t) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Auto-completion +;;; Integrates: +;;; 1) Rope +;;; 2) Yasnippet +;;; all with AutoComplete.el +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defun prefix-list-elements (list prefix) + (let (value) + (nreverse + (dolist (element list value) + (setq value (cons (format "%s%s" prefix element) value)))))) +(defvar ac-source-rope + '((candidates + . (lambda () + (prefix-list-elements (rope-completions) ac-target)))) + "Source for Rope") +(defun ac-python-find () + "Python `ac-find-function'." + (require 'thingatpt) + (let ((symbol (car-safe (bounds-of-thing-at-point 'symbol)))) + (if (null symbol) + (if (string= "." (buffer-substring (- (point) 1) (point))) + (point) + nil) + symbol))) +(defun ac-python-candidate () + "Python `ac-candidates-function'" + (let (candidates) + (dolist (source ac-sources) + (if (symbolp source) + (setq source (symbol-value source))) + (let* ((ac-limit (or (cdr-safe (assq 'limit source)) ac-limit)) + (requires (cdr-safe (assq 'requires source))) + cand) + (if (or (null requires) + (>= (length ac-target) requires)) + (setq cand + (delq nil + (mapcar (lambda (candidate) + (propertize candidate 'source source)) + (funcall (cdr (assq 'candidates source))))))) + (if (and (> ac-limit 1) + (> (length cand) ac-limit)) + (setcdr (nthcdr (1- ac-limit) cand) nil)) + (setq candidates (append candidates cand)))) + (delete-dups candidates))) +(add-hook 'python-mode-hook + (lambda () + (auto-complete-mode 1) + (set (make-local-variable 'ac-sources) + (append ac-sources '(ac-source-rope) '(ac-source-yasnippet))) + (set (make-local-variable 'ac-find-function) 'ac-python-find) + (set (make-local-variable 'ac-candidate-function) 'ac-python-candidate) + (set (make-local-variable 'ac-auto-start) 3))) +;;sameer's python specific tab completion +(defun sameer-python-tab () + ; Try the following: + ; 1) Do a yasnippet expansion + ; 2) Do a Rope code completion + ; 3) Do an indent + (interactive) + (if (eql (ac-start) 0) + (indent-for-tab-command))) +(defadvice ac-start (before advice-turn-on-auto-start activate) + (set (make-local-variable 'ac-auto-start) t)) +(defadvice ac-cleanup (after advice-turn-off-auto-start activate) + (set (make-local-variable 'ac-auto-start) nil)) +(define-key py-mode-map (kbd "M-p") 'sameer-python-tab) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; End Auto Completion +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Auto Syntax Error Hightlight +(add-hook 'find-file-hook 'flymake-find-file-hook) +(provide 'init_python) diff --git a/conf/emacs.d/ipython.el b/conf/emacs.d/ipython.el new file mode 100644 index 0000000..273d7d0 --- /dev/null +++ b/conf/emacs.d/ipython.el @@ -0,0 +1,491 @@ +;;; ipython.el --- Adds support for IPython to python-mode.el + +;; Copyright (C) 2002, 2003, 2004, 2005 Alexander Schmolck +;; Author: Alexander Schmolck +;; Keywords: ipython python languages oop +;; URL: http://ipython.scipy.org +;; Compatibility: Emacs21, XEmacs21 +;; FIXME: #$@! INPUT RING +(defconst ipython-version "$Revision: 2927 $" + "VC version number.") + +;;; Commentary +;; This library makes all the functionality python-mode has when running with +;; the normal python-interpreter available for ipython, too. It also enables a +;; persistent py-shell command history across sessions (if you exit python +;; with C-d in py-shell) and defines the command `ipython-to-doctest', which +;; can be used to convert bits of a ipython session into something that can be +;; used for doctests. To install, put this file somewhere in your emacs +;; `load-path' [1] and add the following line to your ~/.emacs file (the first +;; line only needed if the default (``"ipython"``) is wrong):: +;; +;; (setq ipython-command "/SOME-PATH/ipython") +;; (require 'ipython) +;; +;; Ipython will be set as the default python shell, but only if the ipython +;; executable is in the path. For ipython sessions autocompletion with +;; is also enabled (experimental feature!). Please also note that all the +;; terminal functions in py-shell are handled by emacs's comint, **not** by +;; (i)python, so importing readline etc. will have 0 effect. +;; +;; To start an interactive ipython session run `py-shell' with ``M-x py-shell`` +;; (or the default keybinding ``C-c C-!``). +;; +;; You can customize the arguments passed to the IPython instance at startup by +;; setting the ``py-python-command-args`` variable. For example, to start +;; always in ``pylab`` mode with hardcoded light-background colors, you can +;; use:: +;; +;; (setq py-python-command-args '("-pylab" "-colors" "LightBG")) +;; +;; +;; NOTE: This mode is currently somewhat alpha and although I hope that it +;; will work fine for most cases, doing certain things (like the +;; autocompletion and a decent scheme to switch between python interpreters) +;; properly will also require changes to ipython that will likely have to wait +;; for a larger rewrite scheduled some time in the future. +;; +;; +;; Further note that I don't know whether this runs under windows or not and +;; that if it doesn't I can't really help much, not being afflicted myself. +;; +;; +;; Hints for effective usage +;; ------------------------- +;; +;; - IMO the best feature by far of the ipython/emacs combo is how much easier +;; it makes it to find and fix bugs thanks to the ``%pdb on or %debug``/ +;; pdbtrack combo. Try it: first in the ipython to shell do ``%pdb on`` then +;; do something that will raise an exception (FIXME nice example), or type +;; ``%debug`` after the exception has been raised. YOu'll be amazed at how +;; easy it is to inspect the live objects in each stack frames and to jump to +;; the corresponding sourcecode locations as you walk up and down the stack +;; trace (even without ``%pdb on`` you can always use ``C-c -`` +;; (`py-up-exception') to jump to the corresponding source code locations). +;; +;; - emacs gives you much more powerful commandline editing and output searching +;; capabilities than ipython-standalone -- isearch is your friend if you +;; quickly want to print 'DEBUG ...' to stdout out etc. +;; +;; - This is not really specific to ipython, but for more convenient history +;; access you might want to add something like the following to *the beggining* +;; of your ``.emacs`` (if you want behavior that's more similar to stand-alone +;; ipython, you can change ``meta p`` etc. for ``control p``):: +;; +;; (require 'comint) +;; (define-key comint-mode-map [(meta p)] +;; 'comint-previous-matching-input-from-input) +;; (define-key comint-mode-map [(meta n)] +;; 'comint-next-matching-input-from-input) +;; (define-key comint-mode-map [(control meta n)] +;; 'comint-next-input) +;; (define-key comint-mode-map [(control meta p)] +;; 'comint-previous-input) +;; +;; - Be aware that if you customize py-python-command previously, this value +;; will override what ipython.el does (because loading the customization +;; variables comes later). +;; +;; Please send comments and feedback to the ipython-list +;; () where I (a.s.) or someone else will try to +;; answer them (it helps if you specify your emacs version, OS etc; +;; familiarity with might +;; speed up things further). +;; +;; Footnotes: +;; +;; [1] If you don't know what `load-path' is, C-h v load-path will tell +;; you; if required you can also add a new directory. So assuming that +;; ipython.el resides in ~/el/, put this in your emacs: +;; +;; +;; (add-to-list 'load-path "~/el") +;; (setq ipython-command "/some-path/ipython") +;; (require 'ipython) +;; +;; +;; +;; +;; TODO: +;; - do autocompletion properly +;; - implement a proper switching between python interpreters +;; +;; BUGS: +;; - neither:: +;; +;; (py-shell "-c print 'FOOBAR'") +;; +;; nor:: +;; +;; (let ((py-python-command-args (append py-python-command-args +;; '("-c" "print 'FOOBAR'")))) +;; (py-shell)) +;; +;; seem to print anything as they should +;; +;; - look into init priority issues with `py-python-command' (if it's set +;; via custom) + + +;;; Code +(require 'cl) +(require 'shell) +(require 'executable) +(require 'ansi-color) + +(defcustom ipython-command "ipython" + "*Shell command used to start ipython." + :type 'string + :group 'python) + +;; Users can set this to nil +(defvar py-shell-initial-switch-buffers t + "If nil, don't switch to the *Python* buffer on the first call to + `py-shell'.") + +(defvar ipython-backup-of-py-python-command nil + "HACK") + + +(defvar ipython-de-input-prompt-regexp "\\(?: +In \\[[0-9]+\\]: *.* +----+> \\(.* +\\)[\n]?\\)\\|\\(?: +In \\[[0-9]+\\]: *\\(.* +\\)\\)\\|^[ ]\\{3\\}[.]\\{3,\\}: *\\(.* +\\)" + "A regular expression to match the IPython input prompt and the python +command after it. The first match group is for a command that is rewritten, +the second for a 'normal' command, and the third for a multiline command.") +(defvar ipython-de-output-prompt-regexp "^Out\\[[0-9]+\\]: " + "A regular expression to match the output prompt of IPython.") + + +(if (not (executable-find ipython-command)) + (message (format "Can't find executable %s - ipython.el *NOT* activated!!!" + ipython-command)) + ;; XXX load python-mode, so that we can screw around with its variables + ;; this has the disadvantage that python-mode is loaded even if no + ;; python-file is ever edited etc. but it means that `py-shell' works + ;; without loading a python-file first. Obviously screwing around with + ;; python-mode's variables like this is a mess, but well. + (require 'python-mode) + ;; turn on ansi colors for ipython and activate completion + (defun ipython-shell-hook () + ;; the following is to synchronize dir-changes + (make-local-variable 'shell-dirstack) + (setq shell-dirstack nil) + (make-local-variable 'shell-last-dir) + (setq shell-last-dir nil) + (make-local-variable 'shell-dirtrackp) + (setq shell-dirtrackp t) + (add-hook 'comint-input-filter-functions 'shell-directory-tracker nil t) + + (ansi-color-for-comint-mode-on) + (define-key py-shell-map [tab] 'ipython-complete) + ;; Add this so that tab-completion works both in X11 frames and inside + ;; terminals (such as when emacs is called with -nw). + (define-key py-shell-map "\t" 'ipython-complete) + ;;XXX this is really just a cheap hack, it only completes symbols in the + ;;interactive session -- useful nonetheless. + (define-key py-mode-map [(meta tab)] 'ipython-complete) + + ) + (add-hook 'py-shell-hook 'ipython-shell-hook) + ;; Regular expression that describes tracebacks for IPython in context and + ;; verbose mode. + + ;;Adapt python-mode settings for ipython. + ;; (this works for %xmode 'verbose' or 'context') + + ;; XXX putative regexps for syntax errors; unfortunately the + ;; current python-mode traceback-line-re scheme is too primitive, + ;; so it's either matching syntax errors, *or* everything else + ;; (XXX: should ask Fernando for a change) + ;;"^ File \"\\(.*?\\)\", line \\([0-9]+\\).*\n.*\n.*\nSyntaxError:" + ;;^ File \"\\(.*?\\)\", line \\([0-9]+\\)" + + (setq py-traceback-line-re + "\\(^[^\t >].+?\\.py\\).*\n +[0-9]+[^\00]*?\n-+> \\([0-9]+\\)+") + + + ;; Recognize the ipython pdb, whose prompt is 'ipdb>' or 'ipydb>' + ;;instead of '(Pdb)' + (setq py-pdbtrack-input-prompt "\n[(<]*[Ii]?[Pp]y?db[>)]+ ") + (setq pydb-pydbtrack-input-prompt "\n[(]*ipydb[>)]+ ") + + (setq py-shell-input-prompt-1-regexp "^In \\[[0-9]+\\]: *" + py-shell-input-prompt-2-regexp "^ [.][.][.]+: *" ) + ;; select a suitable color-scheme + (unless (member "-colors" py-python-command-args) + (setq py-python-command-args + (nconc py-python-command-args + (list "-colors" + (cond + ((eq frame-background-mode 'dark) + "Linux") + ((eq frame-background-mode 'light) + "LightBG") + (t ; default (backg-mode isn't always set by XEmacs) + "LightBG")))))) + (unless (equal ipython-backup-of-py-python-command py-python-command) + (setq ipython-backup-of-py-python-command py-python-command)) + (setq py-python-command ipython-command)) + + +;; MODIFY py-shell so that it loads the editing history +(defadvice py-shell (around py-shell-with-history) + "Add persistent command-history support (in +$PYTHONHISTORY (or \"~/.ipython/history\", if we use IPython)). Also, if +`py-shell-initial-switch-buffers' is nil, it only switches to *Python* if that +buffer already exists." + (if (comint-check-proc "*Python*") + ad-do-it + (setq comint-input-ring-file-name + (if (string-equal py-python-command ipython-command) + (concat (or (getenv "IPYTHONDIR") "~/.ipython") "/history") + (or (getenv "PYTHONHISTORY") "~/.python-history.py"))) + (comint-read-input-ring t) + (let ((buf (current-buffer))) + ad-do-it + (unless py-shell-initial-switch-buffers + (switch-to-buffer-other-window buf))))) +(ad-activate 'py-shell) +;; (defadvice py-execute-region (before py-execute-buffer-ensure-process) +;; "HACK: test that ipython is already running before executing something. +;; Doing this properly seems not worth the bother (unless people actually +;; request it)." +;; (unless (comint-check-proc "*Python*") +;; (error "Sorry you have to first do M-x py-shell to send something to ipython."))) +;; (ad-activate 'py-execute-region) + +(defadvice py-execute-region (around py-execute-buffer-ensure-process) + "HACK: if `py-shell' is not active or ASYNC is explicitly desired, fall back + to python instead of ipython." + (let ((py-which-shell (if (and (comint-check-proc "*Python*") (not async)) + py-python-command + ipython-backup-of-py-python-command))) + ad-do-it)) +(ad-activate 'py-execute-region) + +(defun ipython-to-doctest (start end) + "Transform a cut-and-pasted bit from an IPython session into something that +looks like it came from a normal interactive python session, so that it can +be used in doctests. Example: + + + In [1]: import sys + + In [2]: sys.stdout.write 'Hi!\n' + ------> sys.stdout.write ('Hi!\n') + Hi! + + In [3]: 3 + 4 + Out[3]: 7 + +gets converted to: + + >>> import sys + >>> sys.stdout.write ('Hi!\n') + Hi! + >>> 3 + 4 + 7 + +" + (interactive "*r\n") + ;(message (format "###DEBUG s:%de:%d" start end)) + (save-excursion + (save-match-data + ;; replace ``In [3]: bla`` with ``>>> bla`` and + ;; ``... : bla`` with ``... bla`` + (goto-char start) + (while (re-search-forward ipython-de-input-prompt-regexp end t) + ;(message "finding 1") + (cond ((match-string 3) ;continued + (replace-match "... \\3" t nil)) + (t + (replace-match ">>> \\1\\2" t nil)))) + ;; replace `` + (goto-char start) + (while (re-search-forward ipython-de-output-prompt-regexp end t) + (replace-match "" t nil))))) + +(defvar ipython-completion-command-string + "print ';'.join(__IP.Completer.all_completions('%s')) #PYTHON-MODE SILENT\n" + "The string send to ipython to query for all possible completions") + + +;; xemacs doesn't have `comint-preoutput-filter-functions' so we'll try the +;; following wonderful hack to work around this case +(if (featurep 'xemacs) + ;;xemacs + (defun ipython-complete () + "Try to complete the python symbol before point. Only knows about the stuff +in the current *Python* session." + (interactive) + (let* ((ugly-return nil) + (sep ";") + (python-process (or (get-buffer-process (current-buffer)) + ;XXX hack for .py buffers + (get-process py-which-bufname))) + ;; XXX currently we go backwards to find the beginning of an + ;; expression part; a more powerful approach in the future might be + ;; to let ipython have the complete line, so that context can be used + ;; to do things like filename completion etc. + (beg (save-excursion (skip-chars-backward "a-z0-9A-Z_." (point-at-bol)) + (point))) + (end (point)) + (pattern (buffer-substring-no-properties beg end)) + (completions nil) + (completion-table nil) + completion + (comint-output-filter-functions + (append comint-output-filter-functions + '(ansi-color-filter-apply + (lambda (string) + ;(message (format "DEBUG filtering: %s" string)) + (setq ugly-return (concat ugly-return string)) + (delete-region comint-last-output-start + (process-mark (get-buffer-process (current-buffer))))))))) + ;(message (format "#DEBUG pattern: '%s'" pattern)) + (process-send-string python-process + (format ipython-completion-command-string pattern)) + (accept-process-output python-process) + ;(message (format "DEBUG return: %s" ugly-return)) + (setq completions + (split-string (substring ugly-return 0 (position ?\n ugly-return)) sep)) + (setq completion-table (loop for str in completions + collect (list str nil))) + (setq completion (try-completion pattern completion-table)) + (cond ((eq completion t)) + ((null completion) + (message "Can't find completion for \"%s\"" pattern) + (ding)) + ((not (string= pattern completion)) + (delete-region beg end) + (insert completion)) + (t + (message "Making completion list...") + (with-output-to-temp-buffer "*Python Completions*" + (display-completion-list (all-completions pattern completion-table))) + (message "Making completion list...%s" "done"))))) + ;; emacs + (defun ipython-complete () + "Try to complete the python symbol before point. Only knows about the stuff +in the current *Python* session." + (interactive) + (let* ((ugly-return nil) + (sep ";") + (python-process (or (get-buffer-process (current-buffer)) + ;XXX hack for .py buffers + (get-process py-which-bufname))) + ;; XXX currently we go backwards to find the beginning of an + ;; expression part; a more powerful approach in the future might be + ;; to let ipython have the complete line, so that context can be used + ;; to do things like filename completion etc. + (beg (save-excursion (skip-chars-backward "a-z0-9A-Z_./" (point-at-bol)) + (point))) + (end (point)) + (pattern (buffer-substring-no-properties beg end)) + (completions nil) + (completion-table nil) + completion + (comint-preoutput-filter-functions + (append comint-preoutput-filter-functions + '(ansi-color-filter-apply + (lambda (string) + (setq ugly-return (concat ugly-return string)) + ""))))) + (process-send-string python-process + (format ipython-completion-command-string pattern)) + (accept-process-output python-process) + (setq completions + (split-string (substring ugly-return 0 (position ?\n ugly-return)) sep)) + ;(message (format "DEBUG completions: %S" completions)) + (setq completion-table (loop for str in completions + collect (list str nil))) + (setq completion (try-completion pattern completion-table)) + (cond ((eq completion t)) + ((null completion) + (message "Can't find completion for \"%s\"" pattern) + (ding)) + ((not (string= pattern completion)) + (delete-region beg end) + (insert completion)) + (t + (message "Making completion list...") + (with-output-to-temp-buffer "*IPython Completions*" + (display-completion-list (all-completions pattern completion-table))) + (message "Making completion list...%s" "done"))))) +) + +;;; autoindent support: patch sent in by Jin Liu , +;;; originally written by doxgen@newsmth.net +;;; Minor modifications by fperez for xemacs compatibility. + +(defvar ipython-autoindent t + "If non-nil, enable autoindent for IPython shell through python-mode.") + +(defvar ipython-indenting-buffer-name "*IPython Indentation Calculation*" + "Temporary buffer for indenting multiline statement.") + +(defun ipython-get-indenting-buffer () + "Return a temporary buffer set in python-mode. Create one if necessary." + (let ((buf (get-buffer-create ipython-indenting-buffer-name))) + (set-buffer buf) + (unless (eq major-mode 'python-mode) + (python-mode)) + buf)) + +(defvar ipython-indentation-string nil + "Indentation for the next line in a multiline statement.") + +(defun ipython-send-and-indent () + "Send the current line to IPython, and calculate the indentation for +the next line." + (interactive) + (if ipython-autoindent + (let ((line (buffer-substring (point-at-bol) (point))) + (after-prompt1) + (after-prompt2)) + (save-excursion + (comint-bol t) + (if (looking-at py-shell-input-prompt-1-regexp) + (setq after-prompt1 t) + (setq after-prompt2 (looking-at py-shell-input-prompt-2-regexp))) + (with-current-buffer (ipython-get-indenting-buffer) + (when after-prompt1 + (erase-buffer)) + (when (or after-prompt1 after-prompt2) + (delete-region (point-at-bol) (point)) + (insert line) + (newline-and-indent)))))) + ;; send input line to ipython interpreter + (comint-send-input)) + +(defun ipython-indentation-hook (string) + "Insert indentation string if py-shell-input-prompt-2-regexp +matches last process output." + (let* ((start-marker (or comint-last-output-start + (point-min-marker))) + (end-marker (process-mark (get-buffer-process (current-buffer)))) + (text (ansi-color-filter-apply (buffer-substring start-marker end-marker)))) + ;; XXX if `text' matches both pattern, it MUST be the last prompt-2 + (when (and (string-match py-shell-input-prompt-2-regexp text) + (not (string-match "\n$" text))) + (with-current-buffer (ipython-get-indenting-buffer) + (setq ipython-indentation-string + (buffer-substring (point-at-bol) (point)))) + (goto-char end-marker) + (insert ipython-indentation-string) + (setq ipython-indentation-string nil)))) + +(add-hook 'py-shell-hook + (lambda () + (add-hook 'comint-output-filter-functions + 'ipython-indentation-hook))) + +(define-key py-shell-map (kbd "RET") 'ipython-send-and-indent) +;;; / end autoindent support + +(provide 'ipython) diff --git a/conf/emacs.d/php-mode.el b/conf/emacs.d/php-mode.el new file mode 100644 index 0000000..ba0926c --- /dev/null +++ b/conf/emacs.d/php-mode.el @@ -0,0 +1,325 @@ +;;; php-mode.el -- major mode for editing PHP source files + +;; Author: Fred Yankowski +;; Keywords: PHP, PHP3, languages +;; $Id: php-mode.el,v 1.31 2002/04/12 19:34:11 fred Exp $ + +;; php-mode.el is Copyright (c) 1999,2000 by Fred Yankowski +;; +;; This is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2, +;; or (at your option) any later version. +;; +;; This is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public +;; License as the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary; +;; + +;; PHP mode is a major mode for editing the PHP programming language +;; . It is mostly concerned with setting up syntax +;; coloring via the font-lock library. The most recent version can be +;; found at . +;; +;; To use PHP mode, add this to your ~/.emacs file: +;; +;; (autoload 'php-mode "php-mode" "PHP editing mode" t) +;; (add-to-list 'auto-mode-alist '("\\.php3\\'" . php-mode)) +;; +;; Repeat the second line for any other filename suffixes that you +;; want to associate with PHP mode. Then, install this file in some +;; directory in your Emacs load-path and run byte-compile-file on it. +;; Voila'. +;; +;; If php-mode does not colorize the text of your PHP code, you may need +;; to tweak the supporting font-lock mode a bit. Here is more code for +;; .emacs that demonstrates one approach: +;; +;; (cond (window-system +;; (require 'font-lock) +;; (setq font-lock-support-mode 'lazy-lock-mode) +;; (setq font-lock-maximum-decoration t) +;; (global-font-lock-mode t) +;; )) +;; +;; The above configuration treats the entire file as being PHP code, +;; causing interspersed HTML code to be handled very poorly. An +;; option that provides very satisfying results is to use php-mode in +;; conjuction with the Multiple Major Modes package. Get that package +;; from mmm-mode.sourceforge.net, install it, and use something like +;; the following in your .emacs file to configure it: +;; +;; (require 'mmm-mode) +;; (setq mmm-global-mode 'maybe) +;; (mmm-add-mode-ext-class nil "\\.php3?\\'" 'html-php) +;; (mmm-add-classes +;; '((html-php +;; :submode php-mode +;; :front "<\\?\\(php\\)?" +;; :back "\\?>" +;; ))) +;; (autoload 'php-mode "php-mode" "PHP editing mode" t) +;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . sgml-html-mode)) +;; +;; Note that .php files now have the PSGML/HTML mode as their major +;; mode and PHP mode as a submode applied by the MMM minor mode. You +;; can force a file to get PHP mode as a submode by starting the file +;; with a line like this: +;; +;; ") + + `(,(concat "\\<\\(" php-constants "\\)\\>") + 1 font-lock-constant-face) + + ;; handle several words specially, to include following word, + ;; thereby excluding it from unknown-symbol checks later + '("\\<\\(new\\|extends\\)\\s-+\\$?\\(\\sw+\\)" + (1 font-lock-keyword-face) (2 default)) + + ;; treat 'print' as keyword only when not used like a function name + '("\\" . font-lock-keyword-face) + + '("<\\?\\(php\\)?" . font-lock-constant-face) + '("\\?>" . font-lock-constant-face) + ))) + + (defconst php-font-lock-keywords-3 + (append + (list + ;; warn about 'new FooBar()' -- empty parens are tempting but wrong + '("\\<\\(new\\)\\s-+\\(\\sw+\\)\\((\\s-*)\\)" + (1 font-lock-keyword-face) (2 default) (3 font-lock-warning-face)) + ) + php-font-lock-keywords-2 + (list + ;'("]*>" . font-lock-constant-face) ; or + + ;; warn about '$' immediately after -> + '("\\$\\sw+->\\s-*\\(\\$\\)\\(\\sw+\\)" + (1 font-lock-warning-face) (2 default)) + + ;; warn about $word.word -- it could be a valid concatenation, + ;; but without any spaces we'll assume $word->word was meant. + '("\\$\\sw+\\(\\.\\)\\sw" + 1 font-lock-warning-face) + + ;; exclude casts from bare-word treatment + `(,(concat "(\\(" php-types "\\))") + 1 default) + + ;; highlight variables, as suggested by Trond Aasan + '("[$*]{?\\(\\sw+\\)" 1 font-lock-variable-name-face) + + ;; Warn about bare symbols, those that don't follow '$' or precede + ;; '('. But first explicitly mark some words that are OK. + '("->\\s-*\\sw+" . default) ; -->word + '("\\$\\sw+" . default) ; $word + '("\\<\\sw+\\s-*[[(]" . default) ; word( or word[ + '("\\<[0-9]+" . default) ; number (also matches word) + '("\\<\\sw+\\>" . font-lock-warning-face) + + ;; Warn about ==> instead of => (why do I *do* that?) + '("==+>" . font-lock-warning-face) + )))) + +(defconst php-font-lock-syntactic-keywords + (if xemacsp nil + ;; Mark shell-style comments. font-lock handles this in a + ;; separate pass from normal syntactic scanning (somehow), so we + ;; get a chance to mark these in addition to C and C++ style + ;; comments. This only works in GNU Emacs, not Xemacs 21 which + ;; seems to ignore this same code if we try to use it. + (list + ;; Mark _all_ # chars as being comment-start. That will be + ;; ignored when inside a quoted string. + '("\\(\#\\)" + (1 (11 . nil))) + ;; Mark all newlines ending a line with # as being comment-end. + ;; This causes a problem, premature end-of-comment, when '#' + ;; appears inside a multiline C-style comment. Oh well. + '("#.*\\([\n]\\)" + (1 (12 . nil))) + ))) + +;; Define the imenu-generic-expression for PHP mode. +;; To use, execute M-x imenu, then click on Functions or Classes, +;; then select given function/class name to go to its definition. +;; [Contributed by Gerrit Riessen] +(defvar php-imenu-generic-expression + '( + ("Functions" + "\\(^\\|\\s-\\)function\\s-+\\(\\sw+\\)\\s-*(" 2) + ("Classes" + "\\(^\\|\\s-\\)class\\s-+\\(\\sw+\\)\\s-*" 2) + ) + "Imenu generic expression for PHP Mode. See `imenu-generic-expression'." + ) + +(define-derived-mode php-mode c-mode "PHP" + "A major mode for editing PHP source code. + +Key bindings: +\\{php-mode-map}" + + (setq comment-start "// " + comment-end "" + comment-start-skip "// *") + + (defvar php-mode-syntax-table php-mode-syntax-table) + + (modify-syntax-entry ?_ "w" php-mode-syntax-table) + ;; underscore considered part of word + (modify-syntax-entry ?$ "." php-mode-syntax-table) + ;; dollar-sign considered punctuation, not part of word + + (if xemacsp (progn + (modify-syntax-entry ?# "< b" php-mode-syntax-table) + (modify-syntax-entry ?\n "> b" php-mode-syntax-table))) + ;; The above causes Xemacs to handle shell-style comments correctly, + ;; but fails to work in GNU Emacs which fails to interpret \n as the + ;; end of the comment. + + (make-local-variable 'font-lock-defaults) + (setq font-lock-defaults + '((php-font-lock-keywords-1 + php-font-lock-keywords-2 + ;; Comment-out the next line if the font-coloring is too + ;; extreme/ugly for you. + php-font-lock-keywords-3 + ) + nil ; KEYWORDS-ONLY + T ; CASE-FOLD + nil ; SYNTAX-ALIST + nil ; SYNTAX-BEGIN + (font-lock-syntactic-keywords . php-font-lock-syntactic-keywords))) + + (make-local-variable 'require-final-newline) + (setq require-final-newline nil) + (make-local-variable 'next-line-add-newlines) + (setq next-line-add-newlines nil) + ;; Will not force newline at end of file. Such newlines can cause + ;; trouble if the PHP file is included in another file before calls + ;; to header() or cookie(). + + (make-local-variable 'imenu-generic-expression) + (make-local-variable 'imenu-case-fold-search) + (setq + imenu-generic-expression php-imenu-generic-expression + imenu-case-fold-search nil) + ) + + +(unless (boundp 'default) + (defvar default 'default)) +;; Created "default" symbol for GNU Emacs so that both Xemacs and GNU +;; emacs can refer to the default face by a variable named "default". + +(unless (boundp 'font-lock-keyword-face) + (copy-face 'bold 'font-lock-keyword-face)) +;; font-lock-keyword-face is sure to be valid now, assuming that the +;; bold face exists + +(unless (boundp 'font-lock-constant-face) + (copy-face 'font-lock-keyword-face 'font-lock-constant-face)) +;; font-lock-constant-face now exists, which Xemacs doesn't seem to have +;; by default + +(provide 'php-mode) diff --git a/conf/emacs.d/pycomplete.el b/conf/emacs.d/pycomplete.el new file mode 100644 index 0000000..159d93c --- /dev/null +++ b/conf/emacs.d/pycomplete.el @@ -0,0 +1,50 @@ +;;; Complete symbols at point using Pymacs. + +;; Copyright (C) 2007 Skip Montanaro + +;; Author: Skip Montanaro +;; Maintainer: skip@pobox.com +;; Created: Oct 2004 +;; Keywords: python pymacs emacs + +;; This software is provided as-is, without express or implied warranty. +;; Permission to use, copy, modify, distribute or sell this software, +;; without fee, for any purpose and by any individual or organization, is +;; hereby granted, provided that the above copyright notice and this +;; paragraph appear in all copies. + +;; Along with pycomplete.py this file allows programmers to complete Python +;; symbols within the current buffer. See pycomplete.py for the Python side +;; of things and a short description of what to expect. + +(require 'pymacs) +(require 'python-mode) + +(pymacs-load "pycomplete") + +(defun py-complete () + (interactive) + (let ((pymacs-forget-mutability t)) + (insert (pycomplete-pycomplete (py-symbol-near-point) + (py-find-global-imports))))) + +(defun py-find-global-imports () + (save-excursion + (let (first-class-or-def imports) + (goto-char (point-min)) + (setq first-class-or-def + (re-search-forward "^ *\\(def\\|class\\) " nil t)) + (goto-char (point-min)) + (setq imports nil) + (while (re-search-forward + "^\\(import \\|from \\([A-Za-z_][A-Za-z_0-9]*\\) import \\).*" + nil t) + (setq imports (append imports + (list (buffer-substring + (match-beginning 0) + (match-end 0)))))) + imports))) + +(define-key py-mode-map "\M-\C-i" 'py-complete) + +(provide 'pycomplete) diff --git a/conf/emacs.d/pycomplete.py b/conf/emacs.d/pycomplete.py new file mode 100644 index 0000000..83efc48 --- /dev/null +++ b/conf/emacs.d/pycomplete.py @@ -0,0 +1,110 @@ + +""" +Python dot expression completion using Pymacs. + +This almost certainly needs work, but if you add + + (require 'pycomplete) + +to your .xemacs/init.el file (untried w/ GNU Emacs so far) and have Pymacs +installed, when you hit M-TAB it will try to complete the dot expression +before point. For example, given this import at the top of the file: + + import time + +typing "time.cl" then hitting M-TAB should complete "time.clock". + +This is unlikely to be done the way Emacs completion ought to be done, but +it's a start. Perhaps someone with more Emacs mojo can take this stuff and +do it right. + +See pycomplete.el for the Emacs Lisp side of things. +""" + +# Author: Skip Montanaro +# Maintainer: skip@pobox.com +# Created: Oct 2004 +# Keywords: python pymacs emacs + +# This software is provided as-is, without express or implied warranty. +# Permission to use, copy, modify, distribute or sell this software, without +# fee, for any purpose and by any individual or organization, is hereby +# granted, provided that the above copyright notice and this paragraph +# appear in all copies. + +# Along with pycomplete.el this file allows programmers to complete Python +# symbols within the current buffer. + +import sys +import os.path + +try: + x = set +except NameError: + from sets import Set as set +else: + del x + +def get_all_completions(s, imports=None): + """Return contextual completion of s (string of >= zero chars). + + If given, imports is a list of import statements to be executed first. + """ + locald = {} + if imports is not None: + for stmt in imports: + try: + exec stmt in globals(), locald + except TypeError: + raise TypeError, "invalid type: %s" % stmt + + dots = s.split(".") + if not s or len(dots) == 1: + keys = set() + keys.update(locald.keys()) + keys.update(globals().keys()) + import __builtin__ + keys.update(dir(__builtin__)) + keys = list(keys) + keys.sort() + if s: + return [k for k in keys if k.startswith(s)] + else: + return keys + + sym = None + for i in range(1, len(dots)): + s = ".".join(dots[:i]) + try: + sym = eval(s, globals(), locald) + except NameError: + try: + sym = __import__(s, globals(), locald, []) + except ImportError: + return [] + if sym is not None: + s = dots[-1] + return [k for k in dir(sym) if k.startswith(s)] + +def pycomplete(s, imports=None): + completions = get_all_completions(s, imports) + dots = s.split(".") + return os.path.commonprefix([k[len(dots[-1]):] for k in completions]) + +if __name__ == "__main__": + print " ->", pycomplete("") + print "sys.get ->", pycomplete("sys.get") + print "sy ->", pycomplete("sy") + print "sy (sys in context) ->", pycomplete("sy", imports=["import sys"]) + print "foo. ->", pycomplete("foo.") + print "Enc (email * imported) ->", + print pycomplete("Enc", imports=["from email import *"]) + print "E (email * imported) ->", + print pycomplete("E", imports=["from email import *"]) + + print "Enc ->", pycomplete("Enc") + print "E ->", pycomplete("E") + +# Local Variables : +# pymacs-auto-reload : t +# End : diff --git a/conf/emacs.d/pymacs.el b/conf/emacs.d/pymacs.el new file mode 100644 index 0000000..53d77fc --- /dev/null +++ b/conf/emacs.d/pymacs.el @@ -0,0 +1,757 @@ +;;; Interface between Emacs Lisp and Python - Lisp part. -*- emacs-lisp -*- +;;; Copyright © 2001, 2002, 2003 Progiciels Bourbeau-Pinard inc. +;;; François Pinard , 2001. + +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 2, or (at your option) +;;; any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program; if not, write to the Free Software Foundation, +;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + +;;; Portability stunts. + +(defvar pymacs-use-hash-tables + (and (fboundp 'make-hash-table) (fboundp 'gethash) (fboundp 'puthash)) + "Set to t if hash tables are available.") + +(eval-and-compile + + ;; pymacs-cancel-timer + (defalias 'pymacs-cancel-timer + (cond ((fboundp 'cancel-timer) 'cancel-timer) + ;; XEmacs case - yet having post-gc-hook, this is unused. + ((fboundp 'delete-itimer) 'delete-itimer) + (t 'ignore))) + + ;; pymacs-kill-without-query + (if (fboundp 'set-process-query-on-exit-flag) + (defun pymacs-kill-without-query (process) + "Tell recent Emacs how to quickly destroy PROCESS while exiting." + (set-process-query-on-exit-flag process nil)) + (defalias 'pymacs-kill-without-query + (if (fboundp 'process-kill-without-query-process) + 'process-kill-without-query-process + 'ignore))) + + ;; pymacs-multibyte-string-p + (cond ((fboundp 'multibyte-string-p) + (defalias 'pymacs-multibyte-string-p 'multibyte-string-p)) + ((fboundp 'find-charset-string) + (defun pymacs-multibyte-string-p (string) + "Tell XEmacs if STRING should be handled as multibyte." + (not (member (find-charset-string string) '(nil (ascii)))))) + (t + ; Tell XEmacs that STRING is unibyte, when Mule is not around! + (defalias 'pymacs-multibyte-string-p 'ignore))) + + ;; pymacs-report-error + (defalias 'pymacs-report-error (symbol-function 'error)) + + ;; pymacs-set-buffer-multibyte + (if (fboundp 'set-buffer-multibyte) + (defalias 'pymacs-set-buffer-multibyte 'set-buffer-multibyte) + (defun pymacs-set-buffer-multibyte (flag) + "For use in Emacs 20.2 or earlier. Under XEmacs: no operation." + (setq enable-multibyte-characters flag))) + + ;; pymacs-timerp + (defalias 'pymacs-timerp + (cond ((fboundp 'timerp) 'timerp) + ; XEmacs case - yet having post-gc-hook, this is unused. + ((fboundp 'itimerp) 'itimerp) + (t 'ignore))) + + ) + +;;; Published variables and functions. + +(defvar pymacs-load-path nil + "List of additional directories to search for Python modules. +The directories listed will be searched first, in the order given.") + +(defvar pymacs-trace-transit '(5000 . 30000) + "Keep the communication buffer growing, for debugging. +When this variable is nil, the `*Pymacs*' communication buffer gets erased +before each communication round-trip. Setting it to `t' guarantees that +the full communication is saved, which is useful for debugging. +It could also be given as (KEEP . LIMIT): whenever the buffer exceeds LIMIT +bytes, it is reduced to approximately KEEP bytes.") + +(defvar pymacs-forget-mutability nil + "Transmit copies to Python instead of Lisp handles, as much as possible. +When this variable is nil, most mutable objects are transmitted as handles. +This variable is meant to be temporarily rebound to force copies.") + +(defvar pymacs-mutable-strings nil + "Prefer transmitting Lisp strings to Python as handles. +When this variable is nil, strings are transmitted as copies, and the +Python side thus has no way for modifying the original Lisp strings. +This variable is ignored whenever `forget-mutability' is set.") + +(defvar pymacs-timeout-at-start 30 + "Maximum reasonable time, in seconds, for starting the Pymacs helper. +A machine should be pretty loaded before one needs to increment this.") + +(defvar pymacs-timeout-at-reply 5 + "Expected maximum time, in seconds, to get the first line of a reply. +The status of the Pymacs helper is checked at every such timeout.") + +(defvar pymacs-timeout-at-line 2 + "Expected maximum time, in seconds, to get another line of a reply. +The status of the Pymacs helper is checked at every such timeout.") + +(defvar pymacs-auto-restart 'ask + "Should the Pymacs helper be restarted whenever it dies? +Possible values are nil, t or ask.") + +(defvar pymacs-dreadful-zombies nil + "If zombies should trigger hard errors, whenever they get called. +If `nil', calling a zombie will merely produce a diagnostic message.") + +(defun pymacs-load (module &optional prefix noerror) + "Import the Python module named MODULE into Emacs. +Each function in the Python module is made available as an Emacs function. +The Lisp name of each function is the concatenation of PREFIX with +the Python name, in which underlines are replaced by dashes. If PREFIX is +not given, it defaults to MODULE followed by a dash. +If NOERROR is not nil, do not raise error when the module is not found." + (interactive + (let* ((module (read-string "Python module? ")) + (default (concat (car (last (split-string module "\\."))) "-")) + (prefix (read-string (format "Prefix? [%s] " default) + nil nil default))) + (list module prefix))) + (message "Pymacs loading %s..." module) + (let ((lisp-code (pymacs-call "pymacs_load_helper" module prefix))) + (cond (lisp-code (let ((result (eval lisp-code))) + (message "Pymacs loading %s...done" module) + result)) + (noerror (message "Pymacs loading %s...failed" module) nil) + (t (pymacs-report-error "Pymacs loading %s...failed" module))))) + +(defun pymacs-eval (text) + "Compile TEXT as a Python expression, and return its value." + (interactive "sPython expression? ") + (let ((value (pymacs-serve-until-reply "eval" `(princ ,text)))) + (when (interactive-p) + (message "%S" value)) + value)) + +(defun pymacs-exec (text) + "Compile and execute TEXT as a sequence of Python statements. +This functionality is experimental, and does not appear to be useful." + (interactive "sPython statements? ") + (let ((value (pymacs-serve-until-reply "exec" `(princ ,text)))) + (when (interactive-p) + (message "%S" value)) + value)) + +(defun pymacs-call (function &rest arguments) + "Return the result of calling a Python function FUNCTION over ARGUMENTS. +FUNCTION is a string denoting the Python function, ARGUMENTS are separate +Lisp expressions, one per argument. Immutable Lisp constants are converted +to Python equivalents, other structures are converted into Lisp handles." + (pymacs-serve-until-reply + "eval" `(pymacs-print-for-apply ',function ',arguments))) + +(defun pymacs-apply (function arguments) + "Return the result of calling a Python function FUNCTION over ARGUMENTS. +FUNCTION is a string denoting the Python function, ARGUMENTS is a list of +Lisp expressions. Immutable Lisp constants are converted to Python +equivalents, other structures are converted into Lisp handles." + (pymacs-serve-until-reply + "eval" `(pymacs-print-for-apply ',function ',arguments))) + +;;; Integration details. + +;; This page tries to increase the integration seamlessness of Pymacs +;; with the reminder of Emacs. + +;; Module "desktop" savagely kills `*Pymacs*' in some circumstances. +;; Let's avoid such damage. + +(eval-after-load 'desktop + '(push "\\*Pymacs\\*" desktop-clear-preserve-buffers)) + +;; Python functions and modules should ideally look like Lisp +;; functions and modules. + +(when t + + (defadvice documentation (around pymacs-ad-documentation activate) + ;; Integration of doc-strings. + (let* ((reference (pymacs-python-reference function)) + (python-doc (when reference + (pymacs-eval (format "doc_string(%s)" reference))))) + (if (or reference python-doc) + (setq ad-return-value + (concat + "It interfaces to a Python function.\n\n" + (when python-doc + (if raw python-doc (substitute-command-keys python-doc))))) + ad-do-it))) + + (defun pymacs-python-reference (object) + ;; Return the text reference of a Python object if possible, else nil. + (when (functionp object) + (let* ((definition (indirect-function object)) + (body (and (pymacs-proper-list-p definition) + (> (length definition) 2) + (eq (car definition) 'lambda) + (cddr definition)))) + (when (and body (listp (car body)) (eq (caar body) 'interactive)) + ;; Skip the interactive specification of a function. + (setq body (cdr body))) + (when (and body + ;; Advised functions start with a string. + (not (stringp (car body))) + ;; Python trampolines hold exactly one expression. + (= (length body) 1)) + (let ((expression (car body))) + ;; EXPRESSION might now hold something like: + ;; (pymacs-apply (quote (pymacs-python . N)) ARGUMENT-LIST) + (when (and (pymacs-proper-list-p expression) + (= (length expression) 3) + (eq (car expression) 'pymacs-apply) + (eq (car (cadr expression)) 'quote)) + (setq object (cadr (cadr expression)))))))) + (when (eq (car-safe object) 'pymacs-python) + (format "python[%d]" (cdr object))))) + +;; The following functions are experimental -- they are not satisfactory yet. + +(defun pymacs-file-handler (operation &rest arguments) + ;; Integration of load-file, autoload, etc. + ;; Emacs might want the contents of some `MODULE.el' which does not exist, + ;; while there is a `MODULE.py' or `MODULE.pyc' file in the same directory. + ;; The goal is to generate a virtual contents for this `MODULE.el' file, as + ;; a set of Lisp trampoline functions to the Python module functions. + ;; Python modules can then be loaded or autoloaded as if they were Lisp. + (cond ((and (eq operation 'file-readable-p) + (let ((module (substring (car arguments) 0 -3))) + (or (pymacs-file-force operation arguments) + (file-readable-p (concat module ".py")) + (file-readable-p (concat module ".pyc")))))) + ((and (eq operation 'load) + (not (pymacs-file-force + 'file-readable-p (list (car arguments)))) + (file-readable-p (car arguments))) + (let ((lisp-code (pymacs-call "pymacs_load_helper" + (substring (car arguments) 0 -3) + nil))) + (unless lisp-code + (pymacs-report-error "Python import error")) + (eval lisp-code))) + ((and (eq operation 'insert-file-contents) + (not (pymacs-file-force + 'file-readable-p (list (car arguments)))) + (file-readable-p (car arguments))) + (let ((lisp-code (pymacs-call "pymacs_load_helper" + (substring (car arguments) 0 -3) + nil))) + (unless lisp-code + (pymacs-report-error "Python import error")) + (insert (prin1-to-string lisp-code)))) + (t (pymacs-file-force operation arguments)))) + +(defun pymacs-file-force (operation arguments) + ;; Bypass the file handler. + (let ((inhibit-file-name-handlers + (cons 'pymacs-file-handler + (and (eq inhibit-file-name-operation operation) + inhibit-file-name-handlers))) + (inhibit-file-name-operation operation)) + (apply operation arguments))) + +;(add-to-list 'file-name-handler-alist '("\\.el\\'" . pymacs-file-handler)) + +;;; Gargabe collection of Python IDs. + +;; Python objects which have no Lisp representation are allocated on the +;; Python side as `python[INDEX]', and INDEX is transmitted to Emacs, with +;; the value to use on the Lisp side for it. Whenever Lisp does not need a +;; Python object anymore, it should be freed on the Python side. The +;; following variables and functions are meant to fill this duty. + +(defvar pymacs-used-ids nil + "List of received IDs, currently allocated on the Python side.") + +;; This is set whenever the Pymacs helper successfully starts, and is +;; also used to later detect the death of a previous helper. If +;; pymacs-use-hash-tables is unset, this variable receives `t' when +;; the helper starts, so the detection works nevertheless. +(defvar pymacs-weak-hash nil + "Weak hash table, meant to find out which IDs are still needed.") + +(defvar pymacs-gc-wanted nil + "Flag that it is desirable to clean up unused IDs on the Python side.") + +(defvar pymacs-gc-inhibit nil + "Flag that a new Pymacs garbage collection should just not run now.") + +(defvar pymacs-gc-timer nil + "Timer to trigger Pymacs garbage collection at regular time intervals. +The timer is used only if `post-gc-hook' is not available.") + +(defun pymacs-schedule-gc (&optional xemacs-list) + (unless pymacs-gc-inhibit + (setq pymacs-gc-wanted t))) + +(defun pymacs-garbage-collect () + ;; Clean up unused IDs on the Python side. + (when (and pymacs-use-hash-tables (not pymacs-gc-inhibit)) + (let ((pymacs-gc-inhibit t) + (pymacs-forget-mutability t) + (ids pymacs-used-ids) + used-ids unused-ids) + (while ids + (let ((id (car ids))) + (setq ids (cdr ids)) + (if (gethash id pymacs-weak-hash) + (setq used-ids (cons id used-ids)) + (setq unused-ids (cons id unused-ids))))) + (setq pymacs-used-ids used-ids + pymacs-gc-wanted nil) + (when unused-ids + (pymacs-apply "free_python" unused-ids))))) + +(defun pymacs-defuns (arguments) + ;; Take one argument, a list holding a number of items divisible by 3. The + ;; first argument is an INDEX, the second is a NAME, the third is the + ;; INTERACTION specification, and so forth. Register Python INDEX with a + ;; function with that NAME and INTERACTION on the Lisp side. The strange + ;; calling convention is to minimise quoting at call time. + (while (>= (length arguments) 3) + (let ((index (nth 0 arguments)) + (name (nth 1 arguments)) + (interaction (nth 2 arguments))) + (fset name (pymacs-defun index interaction)) + (setq arguments (nthcdr 3 arguments))))) + +(defun pymacs-defun (index interaction) + ;; Register INDEX on the Lisp side with a Python object that is a function, + ;; and return a lambda form calling that function. If the INTERACTION + ;; specification is nil, the function is not interactive. Otherwise, the + ;; function is interactive, INTERACTION is then either a string, or the + ;; index of an argument-less Python function returning the argument list. + (let ((object (pymacs-python index))) + (cond ((null interaction) + `(lambda (&rest arguments) + (pymacs-apply ',object arguments))) + ((stringp interaction) + `(lambda (&rest arguments) + (interactive ,interaction) + (pymacs-apply ',object arguments))) + (t `(lambda (&rest arguments) + (interactive (pymacs-call ',(pymacs-python interaction))) + (pymacs-apply ',object arguments)))))) + +(defun pymacs-python (index) + ;; Register on the Lisp side a Python object having INDEX, and return it. + ;; The result is meant to be recognised specially by `print-for-eval', and + ;; in the function position by `print-for-apply'. + (let ((object (cons 'pymacs-python index))) + (when pymacs-use-hash-tables + (puthash index object pymacs-weak-hash) + (setq pymacs-used-ids (cons index pymacs-used-ids))) + object)) + +;;; Generating Python code. + +;; Many Lisp expressions cannot fully be represented in Python, at least +;; because the object is mutable on the Lisp side. Such objects are allocated +;; somewhere into a vector of handles, and the handle index is used for +;; communication instead of the expression itself. + +(defvar pymacs-lisp nil + "Vector of handles to hold transmitted expressions.") + +(defvar pymacs-freed-list nil + "List of unallocated indices in Lisp.") + +;; When the Python GC is done with a Lisp object, a communication occurs so to +;; free the object on the Lisp side as well. + +(defun pymacs-allocate-lisp (expression) + ;; This function allocates some handle for an EXPRESSION, and return its + ;; index. + (unless pymacs-freed-list + (let* ((previous pymacs-lisp) + (old-size (length previous)) + (new-size (if (zerop old-size) 100 (+ old-size (/ old-size 2)))) + (counter new-size)) + (setq pymacs-lisp (make-vector new-size nil)) + (while (> counter 0) + (setq counter (1- counter)) + (if (< counter old-size) + (aset pymacs-lisp counter (aref previous counter)) + (setq pymacs-freed-list (cons counter pymacs-freed-list)))))) + (let ((index (car pymacs-freed-list))) + (setq pymacs-freed-list (cdr pymacs-freed-list)) + (aset pymacs-lisp index expression) + index)) + +(defun pymacs-free-lisp (indices) + ;; This function is triggered from Python side for Lisp handles which lost + ;; their last reference. These references should be cut on the Lisp side as + ;; well, or else, the objects will never be garbage-collected. + (while indices + (let ((index (car indices))) + (aset pymacs-lisp index nil) + (setq pymacs-freed-list (cons index pymacs-freed-list) + indices (cdr indices))))) + +(defun pymacs-print-for-apply (function arguments) + ;; This function prints a Python expression calling FUNCTION, which is a + ;; string naming a Python function, or a Python reference, over all its + ;; ARGUMENTS, which are Lisp expressions. + (let ((separator "") + argument) + (if (eq (car-safe function) 'pymacs-python) + (princ (format "python[%d]" (cdr function))) + (princ function)) + (princ "(") + (while arguments + (setq argument (car arguments) + arguments (cdr arguments)) + (princ separator) + (setq separator ", ") + (pymacs-print-for-eval argument)) + (princ ")"))) + +(defun pymacs-print-for-eval (expression) + ;; This function prints a Python expression out of a Lisp EXPRESSION. + (let (done) + (cond ((not expression) + (princ "None") + (setq done t)) + ((eq expression t) + (princ "True") + (setq done t)) + ((numberp expression) + (princ expression) + (setq done t)) + ((stringp expression) + (when (or pymacs-forget-mutability + (not pymacs-mutable-strings)) + (let* ((multibyte (pymacs-multibyte-string-p expression)) + (text (if multibyte + (encode-coding-string expression 'utf-8) + (copy-sequence expression)))) + (set-text-properties 0 (length text) nil text) + (princ (mapconcat 'identity + (split-string (prin1-to-string text) "\n") + "\\n")) + (when multibyte + (princ ".encode('ISO-8859-1').decode('UTF-8')"))) + (setq done t))) + ((symbolp expression) + (let ((name (symbol-name expression))) + ;; The symbol can only be transmitted when in the main oblist. + (when (eq expression (intern-soft name)) + (princ "lisp[") + (prin1 name) + (princ "]") + (setq done t)))) + ((vectorp expression) + (when pymacs-forget-mutability + (let ((limit (length expression)) + (counter 0)) + (princ "(") + (while (< counter limit) + (unless (zerop counter) + (princ ", ")) + (pymacs-print-for-eval (aref expression counter)) + (setq counter (1+ counter))) + (when (= limit 1) + (princ ",")) + (princ ")") + (setq done t)))) + ((eq (car-safe expression) 'pymacs-python) + (princ "python[") + (princ (cdr expression)) + (princ "]") + (setq done t)) + ((pymacs-proper-list-p expression) + (when pymacs-forget-mutability + (princ "[") + (pymacs-print-for-eval (car expression)) + (while (setq expression (cdr expression)) + (princ ", ") + (pymacs-print-for-eval (car expression))) + (princ "]") + (setq done t)))) + (unless done + (let ((class (cond ((vectorp expression) "Vector") + ((and pymacs-use-hash-tables + (hash-table-p expression)) + "Table") + ((bufferp expression) "Buffer") + ((pymacs-proper-list-p expression) "List") + (t "Lisp")))) + (princ class) + (princ "(") + (princ (pymacs-allocate-lisp expression)) + (princ ")"))))) + +;;; Communication protocol. + +(defvar pymacs-transit-buffer nil + "Communication buffer between Emacs and Python.") + +;; The principle behind the communication protocol is that it is easier to +;; generate than parse, and that each language already has its own parser. +;; So, the Emacs side generates Python text for the Python side to interpret, +;; while the Python side generates Lisp text for the Lisp side to interpret. +;; About nothing but expressions are transmitted, which are evaluated on +;; arrival. The pseudo `reply' function is meant to signal the final result +;; of a series of exchanges following a request, while the pseudo `error' +;; function is meant to explain why an exchange could not have been completed. + +;; The protocol itself is rather simple, and contains human readable text +;; only. A message starts at the beginning of a line in the communication +;; buffer, either with `>' for the Lisp to Python direction, or `<' for the +;; Python to Lisp direction. This is followed by a decimal number giving the +;; length of the message text, a TAB character, and the message text itself. +;; Message direction alternates systematically between messages, it never +;; occurs that two successive messages are sent in the same direction. The +;; first message is received from the Python side, it is `(version VERSION)'. + +(defun pymacs-start-services () + ;; This function gets called automatically, as needed. + (let ((buffer (get-buffer-create "*Pymacs*"))) + (with-current-buffer buffer + ;; Erase the buffer in case some previous incarnation of the + ;; Pymacs helper died. Otherwise, the "(goto-char (point-min))" + ;; below might not find the proper synchronising reply and later + ;; trigger a spurious "Protocol error" diagnostic. + (erase-buffer) + (buffer-disable-undo) + (pymacs-set-buffer-multibyte nil) + (set-buffer-file-coding-system 'raw-text) + (save-match-data + ;; Launch the Pymacs helper. + (let ((process + (apply 'start-process "pymacs" buffer + (let ((python (getenv "PYMACS_PYTHON"))) + (if (or (null python) (equal python "")) + "python" + python)) + "-c" (concat "import sys;" + " from Pymacs.pymacs import main;" + " main(*sys.argv[1:])") + (append + (and (>= emacs-major-version 24) '("-f")) + (mapcar 'expand-file-name pymacs-load-path))))) + (pymacs-kill-without-query process) + ;; Receive the synchronising reply. + (while (progn + (goto-char (point-min)) + (not (re-search-forward "<\\([0-9]+\\)\t" nil t))) + (unless (accept-process-output process pymacs-timeout-at-start) + (pymacs-report-error + "Pymacs helper did not start within %d seconds" + pymacs-timeout-at-start))) + (let ((marker (process-mark process)) + (limit-position (+ (match-end 0) + (string-to-number (match-string 1))))) + (while (< (marker-position marker) limit-position) + (unless (accept-process-output process pymacs-timeout-at-start) + (pymacs-report-error + "Pymacs helper probably was interrupted at start"))))) + ;; Check that synchronisation occurred. + (goto-char (match-end 0)) + (let ((reply (read (current-buffer)))) + (if (and (pymacs-proper-list-p reply) + (= (length reply) 2) + (eq (car reply) 'version)) + (unless (string-equal (cadr reply) "0.24-beta2") + (pymacs-report-error + "Pymacs Lisp version is 0.24-beta2, Python is %s" + (cadr reply))) + (pymacs-report-error "Pymacs got an invalid initial reply"))))) + (if (not pymacs-use-hash-tables) + (setq pymacs-weak-hash t) + (when pymacs-used-ids + ;; A previous Pymacs session occurred in this Emacs session, + ;; some IDs hang around which do not correspond to anything on + ;; the Python side. Python should not recycle such IDs for + ;; new objects. + (let ((pymacs-transit-buffer buffer) + (pymacs-forget-mutability t) + (pymacs-gc-inhibit t)) + (pymacs-apply "zombie_python" pymacs-used-ids)) + (setq pymacs-used-ids nil)) + (setq pymacs-weak-hash (make-hash-table :weakness 'value)) + (if (boundp 'post-gc-hook) + (add-hook 'post-gc-hook 'pymacs-schedule-gc) + (setq pymacs-gc-timer (run-at-time 20 20 'pymacs-schedule-gc)))) + ;; If nothing failed, only then declare that Pymacs has started! + (setq pymacs-transit-buffer buffer))) + +(defun pymacs-terminate-services () + ;; This function is mainly provided for documentation purposes. + (interactive) + (garbage-collect) + (pymacs-garbage-collect) + (when (or (not pymacs-used-ids) + (yes-or-no-p "\ +Killing the Pymacs helper might create zombie objects. Kill? ")) + (cond ((boundp 'post-gc-hook) + (remove-hook 'post-gc-hook 'pymacs-schedule-gc)) + ((pymacs-timerp pymacs-gc-timer) + (pymacs-cancel-timer pymacs-gc-timer))) + (when pymacs-transit-buffer + (kill-buffer pymacs-transit-buffer)) + (setq pymacs-gc-inhibit nil + pymacs-gc-timer nil + pymacs-transit-buffer nil + pymacs-lisp nil + pymacs-freed-list nil))) + +(defun pymacs-serve-until-reply (action inserter) + ;; This function builds a Python request by printing ACTION and + ;; evaluating INSERTER, which itself prints an argument. It then + ;; sends the request to the Pymacs helper, and serves all + ;; sub-requests coming from the Python side, until either a reply or + ;; an error is finally received. + (unless (and pymacs-transit-buffer + (buffer-name pymacs-transit-buffer) + (get-buffer-process pymacs-transit-buffer)) + (when pymacs-weak-hash + (unless (or (eq pymacs-auto-restart t) + (and (eq pymacs-auto-restart 'ask) + (yes-or-no-p "The Pymacs helper died. Restart it? "))) + (pymacs-report-error "There is no Pymacs helper!"))) + (pymacs-start-services)) + (when pymacs-gc-wanted + (pymacs-garbage-collect)) + (let ((inhibit-quit t) + done value) + (while (not done) + (let ((form (pymacs-round-trip action inserter))) + (setq action (car form)) + (when (eq action 'free) + (pymacs-free-lisp (cadr form)) + (setq form (cddr form) + action (car form))) + (let* ((pair (pymacs-interruptible-eval (cadr form))) + (success (cdr pair))) + (setq value (car pair)) + (cond ((eq action 'eval) + (if success + (setq action "return" + inserter `(pymacs-print-for-eval ',value)) + (setq action "raise" + inserter `(let ((pymacs-forget-mutability t)) + (pymacs-print-for-eval ,value))))) + ((eq action 'expand) + (if success + (setq action "return" + inserter `(let ((pymacs-forget-mutability t)) + (pymacs-print-for-eval ,value))) + (setq action "raise" + inserter `(let ((pymacs-forget-mutability t)) + (pymacs-print-for-eval ,value))))) + ((eq action 'return) + (if success + (setq done t) + (pymacs-report-error "%s" value))) + ((eq action 'raise) + (if success + (pymacs-report-error "Python: %s" value) + (pymacs-report-error "%s" value))) + (t (pymacs-report-error "Protocol error: %s" form)))))) + value)) + +(defun pymacs-round-trip (action inserter) + ;; This function produces a Python request by printing and + ;; evaluating INSERTER, which itself prints an argument. It sends + ;; the request to the Pymacs helper, awaits for any kind of reply, + ;; and returns it. + (with-current-buffer pymacs-transit-buffer + ;; Possibly trim the beginning of the transit buffer. + (cond ((not pymacs-trace-transit) + (erase-buffer)) + ((consp pymacs-trace-transit) + (when (> (buffer-size) (cdr pymacs-trace-transit)) + (let ((cut (- (buffer-size) (car pymacs-trace-transit)))) + (when (> cut 0) + (save-excursion + (goto-char cut) + (unless (memq (preceding-char) '(0 ?\n)) + (forward-line 1)) + (delete-region (point-min) (point)))))))) + ;; Send the request, wait for a reply, and process it. + (let* ((process (get-buffer-process pymacs-transit-buffer)) + (status (process-status process)) + (marker (process-mark process)) + (moving (= (point) marker)) + send-position reply-position reply) + (save-excursion + (save-match-data + ;; Encode request. + (setq send-position (marker-position marker)) + (let ((standard-output marker)) + (princ action) + (princ " ") + (eval inserter)) + (goto-char marker) + (unless (= (preceding-char) ?\n) + (princ "\n" marker)) + ;; Send request text. + (goto-char send-position) + (insert (format ">%d\t" (- marker send-position))) + (setq reply-position (marker-position marker)) + (process-send-region process send-position marker) + ;; Receive reply text. + (while (and (eq status 'run) + (progn + (goto-char reply-position) + (not (re-search-forward "<\\([0-9]+\\)\t" nil t)))) + (unless (accept-process-output process pymacs-timeout-at-reply) + (setq status (process-status process)))) + (when (eq status 'run) + (let ((limit-position (+ (match-end 0) + (string-to-number (match-string 1))))) + (while (and (eq status 'run) + (< (marker-position marker) limit-position)) + (unless (accept-process-output process pymacs-timeout-at-line) + (setq status (process-status process)))))) + ;; Decode reply. + (if (not (eq status 'run)) + (pymacs-report-error "Pymacs helper status is `%S'" status) + (goto-char (match-end 0)) + (setq reply (read (current-buffer)))))) + (when (and moving (not pymacs-trace-transit)) + (goto-char marker)) + reply))) + +(defun pymacs-interruptible-eval (expression) + ;; This function produces a pair (VALUE . SUCCESS) for EXPRESSION. + ;; A cautious evaluation of EXPRESSION is attempted, and any + ;; error while evaluating is caught, including Emacs quit (C-g). + ;; Any Emacs quit also gets forward as a SIGINT to the Pymacs handler. + ;; With SUCCESS being true, VALUE is the expression value. + ;; With SUCCESS being false, VALUE is an interruption diagnostic. + (condition-case info + (cons (let ((inhibit-quit nil)) (eval expression)) t) + (quit (setq quit-flag t) + (interrupt-process pymacs-transit-buffer) + (cons "*Interrupted!*" nil)) + (error (cons (prin1-to-string info) nil)))) + +(defun pymacs-proper-list-p (expression) + ;; Tell if a list is proper, id est, that it is `nil' or ends with `nil'. + (cond ((not expression)) + ((consp expression) (not (cdr (last expression)))))) + +(provide 'pymacs) diff --git a/conf/emacs.d/python-pylint.el b/conf/emacs.d/python-pylint.el new file mode 100644 index 0000000..505136b --- /dev/null +++ b/conf/emacs.d/python-pylint.el @@ -0,0 +1,115 @@ +;;; python-pylint.el --- minor mode for running `pylint' + +;; Copyright (c) 2009, 2010 Ian Eure + +;; Author: Ian Eure + +;; Keywords: languages python +;; Last edit: 2010-02-12 +;; Version: 1.01 + +;; python-pylint.el is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by the Free +;; Software Foundation; either version 2, or (at your option) any later +;; version. +;; +;; It is distributed in the hope that it will be useful, but WITHOUT ANY +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +;; details. +;; +;; You should have received a copy of the GNU General Public License along +;; with your copy of Emacs; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +;; 02111-1307, USA. + +;;; Commentary: +;; +;; (autoload 'python-pylint "python-pylint") +;; (autoload 'pylint "python-pylint") +;; +;;; Code: + +(defgroup python-pylint nil + "Minor mode for running pylint" + :prefix "python-pylint-" + :group 'tools) + +(defvar python-pylint-last-buffer nil + "The most recent PYLINT buffer. +A PYLINT buffer becomes most recent when you select PYLINT mode in it. +Notice that using \\[next-error] or \\[compile-goto-error] modifies +`complation-last-buffer' rather than `python-pylint-last-buffer'.") + +(defconst python-pylint-regexp-alist + (let ((base "^\\(.*\\):\\([0-9]+\\):\s+\\(\\[%s.*\\)$")) + (list + (list (format base "[FE]") 1 2) + (list (format base "[RWC]") 1 2 nil 1))) + "Regexp used to match PYLINT hits. See `compilation-error-regexp-alist'.") + +(defcustom python-pylint-options '("-rn" "-f parseable") + "Options to pass to pylint.py" + :type '(repeat string) + :group 'python-pylint) + +(defcustom python-pylint-command "pylint" + "PYLINT command." + :type '(file) + :group 'python-pylint) + +(defcustom python-pylint-ask-about-save nil + "Non-nil means \\[python-pylint] asks which buffers to save before compiling. +Otherwise, it saves all modified buffers without asking." + :type 'boolean + :group 'python-pylint) + +(define-compilation-mode python-pylint-mode "PYLINT" + (setq python-pylint-last-buffer (current-buffer)) + (set (make-local-variable 'compilation-error-regexp-alist) + python-pylint-regexp-alist) + (set (make-local-variable 'compilation-disable-input) t)) + +(defvar python-pylint-mode-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map compilation-minor-mode-map) + (define-key map " " 'scroll-up) + (define-key map "\^?" 'scroll-down) + (define-key map "\C-c\C-f" 'next-error-follow-minor-mode) + + (define-key map "\r" 'compile-goto-error) ;; ? + (define-key map "n" 'next-error-no-select) + (define-key map "p" 'previous-error-no-select) + (define-key map "{" 'compilation-previous-file) + (define-key map "}" 'compilation-next-file) + (define-key map "\t" 'compilation-next-error) + (define-key map [backtab] 'compilation-previous-error) + map) + "Keymap for PYLINT buffers. +`compilation-minor-mode-map' is a cdr of this.") + +;;;###autoload +(defun python-pylint () + "Run PYLINT, and collect output in a buffer. +While pylint runs asynchronously, you can use \\[next-error] (M-x next-error), +or \\\\[compile-goto-error] in the grep \ +output buffer, to go to the lines where pylint found matches." + (interactive) + + (save-some-buffers (not python-pylint-ask-about-save) nil) + (let* ((tramp (tramp-tramp-file-p (buffer-file-name))) + (file (or (and tramp + (aref (tramp-dissect-file-name (buffer-file-name)) 3)) + (buffer-file-name))) + (command (mapconcat + 'identity + (list python-pylint-command + (mapconcat 'identity python-pylint-options " ") + (comint-quote-filename file)) " "))) + + (compilation-start command 'python-pylint-mode))) + +;;;###autoload +(defalias 'pylint 'python-pylint) + +(provide 'python-pylint) \ No newline at end of file diff --git a/conf/emacs.d/semanticdb/!home!lxsameer!src!sss!semantic.cache b/conf/emacs.d/semanticdb/!home!lxsameer!src!sss!semantic.cache new file mode 100644 index 0000000..b9d55aa --- /dev/null +++ b/conf/emacs.d/semanticdb/!home!lxsameer!src!sss!semantic.cache @@ -0,0 +1,18 @@ +;; Object sss/ +;; SEMANTICDB Tags save file +(semanticdb-project-database-file "sss/" + :tables (list + (semanticdb-table "sss.c" + :major-mode 'c-mode + :tags nil + :file "sss.c" + :pointmax 850 + :fsize 169 + :lastmodtime '(19739 31366) + :unmatched-syntax 'nil + ) + ) + :file "!home!lxsameer!src!sss!semantic.cache" + :semantic-tag-version "2.0pre7" + :semanticdb-version "2.0pre7" + ) diff --git a/conf/emacs.d/semanticdb/!usr!include!c++!4.4!x86_64-linux-gnu!bits!semantic.cache b/conf/emacs.d/semanticdb/!usr!include!c++!4.4!x86_64-linux-gnu!bits!semantic.cache new file mode 100644 index 0000000..c77c7ff --- /dev/null +++ b/conf/emacs.d/semanticdb/!usr!include!c++!4.4!x86_64-linux-gnu!bits!semantic.cache @@ -0,0 +1,18 @@ +;; Object bits/ +;; SEMANTICDB Tags save file +(semanticdb-project-database-file "bits/" + :tables (list + (semanticdb-table "c++config.h" + :major-mode 'c++-mode + :tags nil + :file "c++config.h" + :pointmax 41901 + :fsize 41900 + :lastmodtime '(19701 32168) + :unmatched-syntax 'nil + ) + ) + :file "!usr!include!c++!4.4!x86_64-linux-gnu!bits!semantic.cache" + :semantic-tag-version "2.0pre7" + :semanticdb-version "2.0pre7" + ) diff --git a/conf/emacs.d/snippets/django-mode/LICENSE b/conf/emacs.d/snippets/django-mode/LICENSE new file mode 100644 index 0000000..20d40b6 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/README.rst b/conf/emacs.d/snippets/django-mode/README.rst new file mode 100644 index 0000000..73ca023 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/README.rst @@ -0,0 +1,23 @@ +================ +yasnippet-django +================ + +yasnippet-django is a set of `yasnippet`_-compatible snippets for Django 1.0 + +The current set of snippets build on the updated TextMate bundle, created by `Brian Kerr`_. They have been converted for use with yasnippet. If you have ideas for other additions please let me know. + +Usage +===== + +#. Checkout the repository, or untar the release: + + git://github.com/jonatkinson/yasnippet-django.git + + -or- + + tar xzf yasnippet-django-X.X.tar.gz + +#. Copy these files into your yasnippets/django-mode/ folder (this could be located anywhere, if you need a point in the right direction, try ~/.emacs.d/) + +.. _yasnippet: http://code.google.com/p/yasnippet/ +.. _Brian Kerr: http://bitbucket.org/bkerr/django-textmate-bundles/wiki/Home \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/.yas-make-groups b/conf/emacs.d/snippets/django-mode/html-mode/.yas-make-groups new file mode 100644 index 0000000..e69de29 diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/autoescape b/conf/emacs.d/snippets/django-mode/html-mode/django/autoescape new file mode 100644 index 0000000..6a2d852 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/autoescape @@ -0,0 +1,3 @@ +{% autoescape ${1:off} %} + $2 +{% endautoescape %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/block b/conf/emacs.d/snippets/django-mode/html-mode/django/block new file mode 100644 index 0000000..ba27016 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/block @@ -0,0 +1,3 @@ +{% block $1 %} + $2 +{% endblock $1 %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/blocktrans b/conf/emacs.d/snippets/django-mode/html-mode/django/blocktrans new file mode 100644 index 0000000..70d874a --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/blocktrans @@ -0,0 +1,3 @@ +{% blocktrans ${1:with ${2:var1} as ${3:var2}} %} + $4{{ $3 }} +{% endblocktrans %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/comment b/conf/emacs.d/snippets/django-mode/html-mode/django/comment new file mode 100644 index 0000000..7ede196 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/comment @@ -0,0 +1,3 @@ +{% comment %} + $1 +{% endcomment %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/cycle b/conf/emacs.d/snippets/django-mode/html-mode/django/cycle new file mode 100644 index 0000000..7dd6194 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/cycle @@ -0,0 +1 @@ +{% cycle $1 as $2 %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/debug b/conf/emacs.d/snippets/django-mode/html-mode/django/debug new file mode 100644 index 0000000..2100ee0 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/debug @@ -0,0 +1,3 @@ +
+{% debug %}
+
\ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/extends b/conf/emacs.d/snippets/django-mode/html-mode/django/extends new file mode 100644 index 0000000..90c70b3 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/extends @@ -0,0 +1 @@ +{% extends '${1:base.html}' %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/filter b/conf/emacs.d/snippets/django-mode/html-mode/django/filter new file mode 100644 index 0000000..15ebf9e --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/filter @@ -0,0 +1,3 @@ +{% filter $1 %} + $2 +{% endfilter %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/firstof b/conf/emacs.d/snippets/django-mode/html-mode/django/firstof new file mode 100644 index 0000000..4d0d379 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/firstof @@ -0,0 +1 @@ +{% firstof $1 %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/for b/conf/emacs.d/snippets/django-mode/html-mode/django/for new file mode 100644 index 0000000..e2c2dc1 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/for @@ -0,0 +1,3 @@ +{% for $1 in $2 %} + $3 +{% endfor %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/if b/conf/emacs.d/snippets/django-mode/html-mode/django/if new file mode 100644 index 0000000..8101a43 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/if @@ -0,0 +1,5 @@ +{% if $1 %} +$0${2: +{% else %} +} +{% endif %} diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/ifchanged b/conf/emacs.d/snippets/django-mode/html-mode/django/ifchanged new file mode 100644 index 0000000..1157a15 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/ifchanged @@ -0,0 +1 @@ +{% ifchanged $1%}$2{% endifchanged %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/ifequal b/conf/emacs.d/snippets/django-mode/html-mode/django/ifequal new file mode 100644 index 0000000..5d65eb1 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/ifequal @@ -0,0 +1,3 @@ +{% ifequal $1 $2 %} + $3 +{% endifequal %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/ifnotequal b/conf/emacs.d/snippets/django-mode/html-mode/django/ifnotequal new file mode 100644 index 0000000..f39c64c --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/ifnotequal @@ -0,0 +1,3 @@ +{% ifnotequal $1 $2 %} + $3 +{% endifnotequal %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/include b/conf/emacs.d/snippets/django-mode/html-mode/django/include new file mode 100644 index 0000000..dc4ae8e --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/include @@ -0,0 +1 @@ +{% include ${1:"$2"} %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/load b/conf/emacs.d/snippets/django-mode/html-mode/django/load new file mode 100644 index 0000000..6085188 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/load @@ -0,0 +1 @@ +{% load $1 %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/now b/conf/emacs.d/snippets/django-mode/html-mode/django/now new file mode 100644 index 0000000..d28a2de --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/now @@ -0,0 +1 @@ +{% now "$1" %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/regroup b/conf/emacs.d/snippets/django-mode/html-mode/django/regroup new file mode 100644 index 0000000..78bdc48 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/regroup @@ -0,0 +1 @@ +{% regroup $1 by $2 as $3 %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/spaceless b/conf/emacs.d/snippets/django-mode/html-mode/django/spaceless new file mode 100644 index 0000000..5c81bce --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/spaceless @@ -0,0 +1,3 @@ +{% spaceless %} + $1 +{% endspaceless %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/ssi b/conf/emacs.d/snippets/django-mode/html-mode/django/ssi new file mode 100644 index 0000000..5df3b97 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/ssi @@ -0,0 +1 @@ +{% ssi $1 ${2:parsed} %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/super b/conf/emacs.d/snippets/django-mode/html-mode/django/super new file mode 100644 index 0000000..f3cee21 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/super @@ -0,0 +1 @@ +{{ block.super }} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/trans b/conf/emacs.d/snippets/django-mode/html-mode/django/trans new file mode 100644 index 0000000..38c8143 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/trans @@ -0,0 +1 @@ +{% trans "${1:string to translate}" %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/url b/conf/emacs.d/snippets/django-mode/html-mode/django/url new file mode 100644 index 0000000..99f93ef --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/url @@ -0,0 +1 @@ +{% url $1 as $2 %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/widthratio b/conf/emacs.d/snippets/django-mode/html-mode/django/widthratio new file mode 100644 index 0000000..15bba48 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/widthratio @@ -0,0 +1 @@ +{% widthratio ${1:this_value} ${2:max_value} ${3:100} %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/html-mode/django/with b/conf/emacs.d/snippets/django-mode/html-mode/django/with new file mode 100644 index 0000000..1ac6e82 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/html-mode/django/with @@ -0,0 +1,3 @@ +{% with $1 as $2 %} + $3 +{% endwith %} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/.yas-make-groups b/conf/emacs.d/snippets/django-mode/python-mode/.yas-make-groups new file mode 100644 index 0000000..e69de29 diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/auto b/conf/emacs.d/snippets/django-mode/python-mode/django/auto new file mode 100644 index 0000000..39e2925 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/auto @@ -0,0 +1 @@ +${1:FIELDNAME} = models.AutoField() \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/boolean b/conf/emacs.d/snippets/django-mode/python-mode/django/boolean new file mode 100644 index 0000000..3c25c7a --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/boolean @@ -0,0 +1 @@ +${1:FIELDNAME} = models.BooleanField(${2:default=True}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/char b/conf/emacs.d/snippets/django-mode/python-mode/django/char new file mode 100644 index 0000000..f82c2bc --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/char @@ -0,0 +1 @@ +${1:FIELDNAME} = models.CharField(${2:blank=True, }max_length=${3:255}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/commaseparatedinteger b/conf/emacs.d/snippets/django-mode/python-mode/django/commaseparatedinteger new file mode 100644 index 0000000..7f33d86 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/commaseparatedinteger @@ -0,0 +1 @@ +${1:FIELDNAME} = models.CommaSeparatedIntegerField(max_length=$2) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/date b/conf/emacs.d/snippets/django-mode/python-mode/django/date new file mode 100644 index 0000000..3133e6d --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/date @@ -0,0 +1 @@ +${1:FIELDNAME} = models.DateField(2:blank=True, null=True, }${3:auto_now_add=True}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/datetime b/conf/emacs.d/snippets/django-mode/python-mode/django/datetime new file mode 100644 index 0000000..1ba726b --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/datetime @@ -0,0 +1 @@ +${1:FIELDNAME} = models.DateTimeField(${2:blank=True, null=True, }${3:auto_now_add=True}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/decimal b/conf/emacs.d/snippets/django-mode/python-mode/django/decimal new file mode 100644 index 0000000..030ffe3 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/decimal @@ -0,0 +1 @@ +${1:FIELDNAME} = models.DecimalField(max_digits=$2, decimal_places=$3) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/email b/conf/emacs.d/snippets/django-mode/python-mode/django/email new file mode 100644 index 0000000..61cc19a --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/email @@ -0,0 +1 @@ +${1:FIELDNAME} = models.EmailField() \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/file b/conf/emacs.d/snippets/django-mode/python-mode/django/file new file mode 100644 index 0000000..25a4396 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/file @@ -0,0 +1 @@ +${1:FIELDNAME} = models.FileField(upload_to=${1:/path/for/upload}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/filepath b/conf/emacs.d/snippets/django-mode/python-mode/django/filepath new file mode 100644 index 0000000..a11e169 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/filepath @@ -0,0 +1 @@ +${1:FIELDNAME} = models.FilePathField(path="${1:/location/of/choices}"${2:, match="${3:regex}"}${4:, recursive=True}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/fk b/conf/emacs.d/snippets/django-mode/python-mode/django/fk new file mode 100644 index 0000000..b669629 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/fk @@ -0,0 +1 @@ +${1:FIELDNAME} = models.ForeignKey(${2:RELATED_MODEL}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/float b/conf/emacs.d/snippets/django-mode/python-mode/django/float new file mode 100644 index 0000000..dd7c96c --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/float @@ -0,0 +1 @@ +${1:FIELDNAME} = models.FloatField() \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/form b/conf/emacs.d/snippets/django-mode/python-mode/django/form new file mode 100644 index 0000000..3cb5af1 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/form @@ -0,0 +1,15 @@ +class ${1:Formname}(forms.Form): + """${2:($1 description)}""" + ${3:def __init__(self, *args, **kwargs): + ${4:} + super($1, self).__init__(*args, **kwargs)} + + $0 + + ${5:def clean_${6:fieldname}(self): + $7 + return self.cleaned_data['$6']} + + ${8:def clean(self): + $9 + return self.cleaned_data} diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/image b/conf/emacs.d/snippets/django-mode/python-mode/django/image new file mode 100644 index 0000000..ec8d5ed --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/image @@ -0,0 +1 @@ +${1:FIELDNAME} = models.ImageField(upload_to="${2:/dir/path}"${3:, height_field=$4}${5:, width_field=$6}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/integer b/conf/emacs.d/snippets/django-mode/python-mode/django/integer new file mode 100644 index 0000000..5e8acdf --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/integer @@ -0,0 +1 @@ +${1:FIELDNAME} = models.IntegerField(${2:blank=True, null=True}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/intermediate b/conf/emacs.d/snippets/django-mode/python-mode/django/intermediate new file mode 100644 index 0000000..b5584ad --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/intermediate @@ -0,0 +1,5 @@ +class ${1:Modelname}(models.Model): + """${2:($1 description)}""" + ${3:target_field_name} = models.ForeignKey(${4:TargetModel}) + ${5:source_field_name} = models.ForeignKey(${6:SourceModel}) + $0 diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/ip b/conf/emacs.d/snippets/django-mode/python-mode/django/ip new file mode 100644 index 0000000..0c8c0eb --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/ip @@ -0,0 +1 @@ +${1:FIELDNAME} = models.IPAddressField(${2:blank=True}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/model b/conf/emacs.d/snippets/django-mode/python-mode/django/model new file mode 100644 index 0000000..a0382e4 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/model @@ -0,0 +1,14 @@ +class ${1:Modelname}(models.Model): + """${2:($1 description)}""" + $0 + + ${3:class Meta: + ordering = [${4:}] + verbose_name, verbose_name_plural = "${5:}", "${6:$5s}"} + + def __unicode__(self): + return ${7:u"$1"} + + ${8:@models.permalink + def get_absolute_url(self): + return ('${9:$1}', [${10:self.id}])} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/modeladmin b/conf/emacs.d/snippets/django-mode/python-mode/django/modeladmin new file mode 100644 index 0000000..04f6bff --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/modeladmin @@ -0,0 +1,13 @@ +class ${1:ModelName}Admin(admin.ModelAdmin): + ${2:date_hierarchy = '${3:}'} + ${4:list_display = (${5:})} + ${6:list_filter = (${7:})} + ${8:search_fields = [${9:}]} + + ${10:fieldsets = (${11:})} + + ${12:save_as = True} + ${13:save_on_top = True} + ${14:inlines = [${15:}]} + +admin.site.register($1, $1Admin) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/modelform b/conf/emacs.d/snippets/django-mode/python-mode/django/modelform new file mode 100644 index 0000000..bac4d9c --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/modelform @@ -0,0 +1,14 @@ +class ${1:ModelnameForm}(forms.ModelForm): + $0 + + ${3:def clean_${4:fieldname}(self): + $5 + return self.cleaned_data['$4']} + + ${6:def clean(self): + ${7:} + return self.cleaned_data} + + ${8:def save(self): + super($1, self).save() + ${9:}} \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/mtm b/conf/emacs.d/snippets/django-mode/python-mode/django/mtm new file mode 100644 index 0000000..c33282e --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/mtm @@ -0,0 +1 @@ +${1:FIELDNAME} = models.ManyToManyField(${2:RELATED_MODEL}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/nullboolean b/conf/emacs.d/snippets/django-mode/python-mode/django/nullboolean new file mode 100644 index 0000000..2a5f7ec --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/nullboolean @@ -0,0 +1 @@ +${1:FIELDNAME} = models.NullBooleanField(${2:default=True}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/positiveinteger b/conf/emacs.d/snippets/django-mode/python-mode/django/positiveinteger new file mode 100644 index 0000000..5eb4209 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/positiveinteger @@ -0,0 +1 @@ +${1:FIELDNAME} = models.PositiveIntegerField(${2:blank=True, null=True}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/positivesmallinteger b/conf/emacs.d/snippets/django-mode/python-mode/django/positivesmallinteger new file mode 100644 index 0000000..3fec6b1 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/positivesmallinteger @@ -0,0 +1 @@ +${1:FIELDNAME} = models.PositiveSmallIntegerField(${2:blank=True, null=True}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/sendmail b/conf/emacs.d/snippets/django-mode/python-mode/django/sendmail new file mode 100644 index 0000000..e6cfcf0 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/sendmail @@ -0,0 +1 @@ +mail.send_mail("${1:Subject}", "${2:Message}", "${3:from@example.com}", ${4:["to@example.com"]}${5:, fail_silently=True}) diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/slug b/conf/emacs.d/snippets/django-mode/python-mode/django/slug new file mode 100644 index 0000000..61fe061 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/slug @@ -0,0 +1 @@ +${1:slug} = models.SlugField() \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/smallinteger b/conf/emacs.d/snippets/django-mode/python-mode/django/smallinteger new file mode 100644 index 0000000..5bd61a3 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/smallinteger @@ -0,0 +1 @@ +${1:FIELDNAME} = models.SmallIntegerField(${2:blank=True, null=True}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/stackedinline b/conf/emacs.d/snippets/django-mode/python-mode/django/stackedinline new file mode 100644 index 0000000..3a1b2c8 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/stackedinline @@ -0,0 +1,5 @@ +class ${1:ModelName}Inline(admin.StackedInline): + model = ${2:$1} + ${3:extra = ${4:}} + ${5:max_num = ${6:}} + $0 diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/tabinline b/conf/emacs.d/snippets/django-mode/python-mode/django/tabinline new file mode 100644 index 0000000..3d3aaed --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/tabinline @@ -0,0 +1,5 @@ +class ${1:ModelName}Inline(admin.TabularInline): + model = ${2:$1} + ${3:extra = ${4:}} + ${5:max_num = ${6:}} + $0 diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/text b/conf/emacs.d/snippets/django-mode/python-mode/django/text new file mode 100644 index 0000000..f659018 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/text @@ -0,0 +1 @@ +${1:FIELDNAME} = models.TextField(${2:blank=True}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/time b/conf/emacs.d/snippets/django-mode/python-mode/django/time new file mode 100644 index 0000000..75f2632 --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/time @@ -0,0 +1 @@ +${1:FIELDNAME} = models.TimeField(${2:blank=True}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/django-mode/python-mode/django/xml b/conf/emacs.d/snippets/django-mode/python-mode/django/xml new file mode 100644 index 0000000..e085a4d --- /dev/null +++ b/conf/emacs.d/snippets/django-mode/python-mode/django/xml @@ -0,0 +1 @@ +${1:FIELDNAME} = models.XMLField(schema_path=${2:/path/to/RelaxNG}${3:, blank=True}) \ No newline at end of file diff --git a/conf/emacs.d/snippets/text-mode/ruby-mode/# b/conf/emacs.d/snippets/text-mode/ruby-mode/# new file mode 100644 index 0000000..33581c8 --- /dev/null +++ b/conf/emacs.d/snippets/text-mode/ruby-mode/# @@ -0,0 +1,4 @@ +#name : # => +#group : general +# -- +# => \ No newline at end of file