examples/mcabberrc.lua
changeset 31 54957980a83a
parent 27 92b254b64360
child 32 524fde5be49a
--- a/examples/mcabberrc.lua	Mon Mar 16 04:43:24 2009 +0200
+++ b/examples/mcabberrc.lua	Mon Mar 16 05:31:24 2009 +0200
@@ -77,8 +77,10 @@
 
 -- This is a hack to allow loading of lm.lua and loudmouth.so from ~/.mcabber
 -- instead of installing them system-wide
-package.path = main.config_file ( '?.lua' ) .. ';' .. package.path
-package.cpath = main.config_file ( '?.so' ) .. ';' .. package.cpath
+if main.option ( 'lua_extra_include' ) then
+	package.path = main.option ( 'lua_extra_include' ) .. '/?.lua;' .. package.path
+	package.cpath = main.option ( 'lua_extra_include' ) .. '/?.so;' .. package.cpath
+end
 
 require 'lm'
 
@@ -93,7 +95,7 @@
 	end
 end
 
--- This is for debugging purposes, for real reloading need to quote and bracket keys.
+-- This is for debugging purposes, not for reloading. For that see jobs.
 function table_to_string ( tab, pre )
 	local prefix = pre or ""
 	local tbls, jk = "", ""
@@ -102,7 +104,7 @@
 		if type ( val ) == 'table' then
 			tbls = string.format ( "%s  %s%s = %s,\n", tbls, prefix, tostring(key), table_to_string ( val, "  " .. prefix ) )
 		else
-			jk = string.format ( "%s %s = %q,", jk, tostring(key), tostring(val) )
+			jk = string.format ( "%s %s = \"%s\",", jk, tostring(key), tostring(val) )
 		end
 	end
 
@@ -126,28 +128,17 @@
 	return false
 end
 
+-- XXX to C
 boolean_cid = main.add_category { 'enable', 'disable', 'yes', 'no', 'true', 'false', 'on', 'off' }
 
-function yesno ( value )
-	if value == 'enable' or value == 'yes' or value == 'true' or value == 'on' or value == true then
-		return true
-	elseif value == 'disable' or value == 'no' or value == 'false' or value == 'off' or value == false then
-		return false
-	else
-		return nil
-	end
-end
-
 -- COMMANDS
 
 -- Help strings should not contain command, only arguments. This is necessary to support soft aliases.
 commands_help = {
 	post      = "filename\n\nSends file as a message. Just shorthand.",
-	s         = "status [message]\n\nSets your status, but takes into account mpd (if enabled).",
 	beep      = "[enable|disable|on|off|yes|no|true|false]\n\nEnables or disables beeping on all messages.\nIf state is omitted, prints current state.",
 	cmd       = "shell_command\n\nRuns shell command in background and sends output to current buddy.\nWorks asynchroneously, and may break long output in the middle of line",
 	exthelp   = "[command]\n\nPrints help for a given command, or list of available help topics.",
-	reload    = "\n\nJust a shorthand to reload lua config file. Note, that for now this discards all changes to configuration, open forms, transferred files.",
 	['join!'] = "\n\nForcibly joins to current buddy. Just saves you typing of full room name (that can be quite long) in a case of a non-bookmarked rooms.",
 	count     = "\n\nPrints number of resources of current buddy. Useful to determine member count of large room.",
 	toggle    = "\n\nToggles away/online status.",
@@ -157,10 +148,6 @@
 	function ( args )
 		main.run ( 'say_to -f ' .. args .. ' .' )
 	end, 'filename' )
-main.command ( 's',
-	function ( args )
-		main.run ( ('status %s %s'):format ( args, mpd_getstatus () ) )
-	end, 'status' )
 main.command ( 'cmd',
 	function ( args )
 		local to = main.current_buddy ()
@@ -189,10 +176,6 @@
 			print ( "For built-in mcabber commands see /help" )
 		end
 	end, 'cmd' )
-main.command ( 'reload',
-	function ( args )
-		dofile ( main.config_file ( 'mcabberrc.lua' ) )
-	end )
 main.command ( 'join!',
 	function ( args )
 		main.run ( 'room join ' .. main.current_buddy () )