2 * luaa.c - Lua configuration management
4 * Copyright © 2008-2009 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <basedir_fs.h>
35 #include "awesome-version-internal.h"
43 #include "selection.h"
45 #include "common/xcursor.h"
46 #include "common/buffer.h"
49 extern const struct luaL_reg awesome_dbus_lib
[];
51 extern const struct luaL_reg awesome_hooks_lib
[];
52 extern const struct luaL_reg awesome_keygrabber_lib
[];
53 extern const struct luaL_reg awesome_mousegrabber_lib
[];
54 extern const struct luaL_reg awesome_root_lib
[];
55 extern const struct luaL_reg awesome_mouse_methods
[];
56 extern const struct luaL_reg awesome_mouse_meta
[];
57 extern const struct luaL_reg awesome_screen_methods
[];
58 extern const struct luaL_reg awesome_screen_meta
[];
61 * \param L The Lua VM state.
62 * \return The number of elements pushed on stack.
65 luaA_quit(lua_State
*L
)
67 ev_unloop(globalconf
.loop
, 1);
71 /** Execute another application, probably a window manager, to replace
73 * \param L The Lua VM state.
74 * \return The number of elements pushed on stack.
76 * \lparam The command line to execute.
79 luaA_exec(lua_State
*L
)
81 const char *cmd
= luaL_checkstring(L
, 1);
83 awesome_atexit(false);
92 luaA_restart(lua_State
*L
)
98 /** UTF-8 aware string length computing.
99 * \param L The Lua VM state.
100 * \return The number of elements pushed on stack.
103 luaA_mbstrlen(lua_State
*L
)
105 const char *cmd
= luaL_checkstring(L
, 1);
106 lua_pushnumber(L
, (ssize_t
) mbstowcs(NULL
, NONULL(cmd
), 0));
110 /** Overload standard Lua next function to use __next key on metatable.
111 * \param L The Lua VM state.
112 * \return The number of elements pushed on stack.
115 luaAe_next(lua_State
*L
)
117 if(luaL_getmetafield(L
, 1, "__next"))
120 lua_call(L
, lua_gettop(L
) - 1, LUA_MULTRET
);
121 return lua_gettop(L
);
124 luaL_checktype(L
, 1, LUA_TTABLE
);
132 /** Overload lua_next() function by using __next metatable field
133 * to get next elements.
134 * \param L The Lua VM stack.
135 * \param idx The index number of elements in stack.
136 * \return 1 if more elements to come, 0 otherwise.
139 luaA_next(lua_State
*L
, int idx
)
141 if(luaL_getmetafield(L
, idx
, "__next"))
143 /* if idx is relative, reduce it since we got __next */
145 /* copy table and then move key */
146 lua_pushvalue(L
, idx
);
147 lua_pushvalue(L
, -3);
149 lua_pcall(L
, 2, 2, 0);
150 /* next returned nil, it's the end */
159 else if(lua_istable(L
, idx
))
160 return lua_next(L
, idx
);
166 /** Generic pairs function.
167 * \param L The Lua VM state.
168 * \return The number of elements pushed on stack.
171 luaA_generic_pairs(lua_State
*L
)
173 lua_pushvalue(L
, lua_upvalueindex(1)); /* return generator, */
174 lua_pushvalue(L
, 1); /* state, */
175 lua_pushnil(L
); /* and initial value */
179 /** Overload standard pairs function to use __pairs field of metatables.
180 * \param L The Lua VM state.
181 * \return The number of elements pushed on stack.
184 luaAe_pairs(lua_State
*L
)
186 if(luaL_getmetafield(L
, 1, "__pairs"))
189 lua_call(L
, lua_gettop(L
) - 1, LUA_MULTRET
);
190 return lua_gettop(L
);
193 luaL_checktype(L
, 1, LUA_TTABLE
);
194 return luaA_generic_pairs(L
);
198 luaA_ipairs_aux(lua_State
*L
)
200 int i
= luaL_checkint(L
, 2) + 1;
201 luaL_checktype(L
, 1, LUA_TTABLE
);
202 lua_pushinteger(L
, i
);
203 lua_rawgeti(L
, 1, i
);
204 return (lua_isnil(L
, -1)) ? 0 : 2;
207 /** Overload standard ipairs function to use __ipairs field of metatables.
208 * \param L The Lua VM state.
209 * \return The number of elements pushed on stack.
212 luaAe_ipairs(lua_State
*L
)
214 if(luaL_getmetafield(L
, 1, "__ipairs"))
217 lua_call(L
, lua_gettop(L
) - 1, LUA_MULTRET
);
218 return lua_gettop(L
);
221 luaL_checktype(L
, 1, LUA_TTABLE
);
222 lua_pushvalue(L
, lua_upvalueindex(1));
224 lua_pushinteger(L
, 0); /* and initial value */
228 /** Enhanced type() function which recognize awesome objects.
229 * \param L The Lua VM state.
230 * \return The number of arguments pushed on the stack.
233 luaAe_type(lua_State
*L
)
236 lua_pushstring(L
, luaA_typename(L
, 1));
240 /** Modified version of os.execute() which use spawn code to reset signal
241 * handlers correctly before exec()'ing the new program.
242 * \param L The Lua VM state.
243 * \return The number of arguments pushed on stack.
246 luaAe_os_execute(lua_State
*L
)
248 lua_pushinteger(L
, spawn_system(luaL_optstring(L
, 1, NULL
)));
252 /** Replace various standards Lua functions with our own.
253 * \param L The Lua VM state.
256 luaA_fixups(lua_State
*L
)
258 /* export string.wlen */
259 lua_getglobal(L
, "string");
260 lua_pushcfunction(L
, luaA_mbstrlen
);
261 lua_setfield(L
, -2, "wlen");
263 /* replace os.execute */
264 lua_getglobal(L
, "os");
265 lua_pushcfunction(L
, luaAe_os_execute
);
266 lua_setfield(L
, -2, "execute");
269 lua_pushliteral(L
, "next");
270 lua_pushcfunction(L
, luaAe_next
);
271 lua_settable(L
, LUA_GLOBALSINDEX
);
273 lua_pushliteral(L
, "pairs");
274 lua_pushcfunction(L
, luaAe_next
);
275 lua_pushcclosure(L
, luaAe_pairs
, 1); /* pairs get next as upvalue */
276 lua_settable(L
, LUA_GLOBALSINDEX
);
278 lua_pushliteral(L
, "ipairs");
279 lua_pushcfunction(L
, luaA_ipairs_aux
);
280 lua_pushcclosure(L
, luaAe_ipairs
, 1);
281 lua_settable(L
, LUA_GLOBALSINDEX
);
283 lua_pushliteral(L
, "type");
284 lua_pushcfunction(L
, luaAe_type
);
285 lua_settable(L
, LUA_GLOBALSINDEX
);
287 lua_pushliteral(L
, "selection");
288 lua_pushcfunction(L
, luaA_selection_get
);
289 lua_settable(L
, LUA_GLOBALSINDEX
);
292 /** __next function for wtable objects.
293 * \param L The Lua VM state.
294 * \return The number of elements pushed on stack.
297 luaA_wtable_next(lua_State
*L
)
299 /* upvalue 1 is content table */
300 if(lua_next(L
, lua_upvalueindex(1)))
306 /** __ipairs function for wtable objects.
307 * \param L The Lua VM state.
308 * \return The number of elements pushed on stack.
311 luaA_wtable_ipairs(lua_State
*L
)
313 /* push ipairs_aux */
314 lua_pushvalue(L
, lua_upvalueindex(2));
315 /* push content table */
316 lua_pushvalue(L
, lua_upvalueindex(1));
317 lua_pushinteger(L
, 0); /* and initial value */
321 /** Index function of wtable objects.
322 * \param L The Lua VM state.
323 * \return The number of elements pushed on stack.
326 luaA_wtable_index(lua_State
*L
)
332 /* check for size, waiting lua 5.2 and __len on tables */
333 if((buf
= lua_tolstring(L
, -1, &len
)))
334 if(a_tokenize(buf
, len
) == A_TK_LEN
)
336 lua_pushnumber(L
, lua_objlen(L
, lua_upvalueindex(1)));
341 /* upvalue 1 is content table */
342 lua_rawget(L
, lua_upvalueindex(1));
346 /** Newindex function of wtable objects.
347 * \param L The Lua VM state.
348 * \return The number of elements pushed on stack.
351 luaA_wtable_newindex(lua_State
*L
)
353 bool invalid
= false;
355 /* push key on top */
357 /* get current key value in content table */
358 lua_rawget(L
, lua_upvalueindex(1));
359 /* if value is a widget, notify change */
360 if(lua_istable(L
, -1) || luaA_toudata(L
, -1, &widget_class
))
363 lua_pop(L
, 1); /* remove value */
365 /* if new value is a widget or a table */
366 if(lua_istable(L
, 3))
368 luaA_table2wtable(L
);
371 else if(!invalid
&& luaA_toudata(L
, 3, &widget_class
))
374 /* upvalue 1 is content table */
375 lua_rawset(L
, lua_upvalueindex(1));
378 luaA_wibox_invalidate_byitem(L
, lua_topointer(L
, 1));
383 /** Convert the top element of the stack to a proxied wtable.
384 * \param L The Lua VM state.
387 luaA_table2wtable(lua_State
*L
)
389 if(!lua_istable(L
, -1))
392 lua_newtable(L
); /* create *real* content table */
393 lua_createtable(L
, 0, 5); /* metatable */
394 lua_pushvalue(L
, -2); /* copy content table */
395 lua_pushcfunction(L
, luaA_ipairs_aux
); /* push ipairs aux */
396 lua_pushcclosure(L
, luaA_wtable_ipairs
, 2);
397 lua_pushvalue(L
, -3); /* copy content table */
398 lua_pushcclosure(L
, luaA_wtable_next
, 1); /* __next has the content table as upvalue */
399 lua_pushvalue(L
, -4); /* copy content table */
400 lua_pushcclosure(L
, luaA_wtable_index
, 1); /* __index has the content table as upvalue */
401 lua_pushvalue(L
, -5); /* copy content table */
402 lua_pushcclosure(L
, luaA_wtable_newindex
, 1); /* __newindex has the content table as upvalue */
403 /* set metatable field with just pushed closure */
404 lua_setfield(L
, -5, "__newindex");
405 lua_setfield(L
, -4, "__index");
406 lua_setfield(L
, -3, "__next");
407 lua_setfield(L
, -2, "__ipairs");
408 /* set metatable impossible to touch */
409 lua_pushliteral(L
, "wtable");
410 lua_setfield(L
, -2, "__metatable");
411 /* set new metatable on original table */
412 lua_setmetatable(L
, -3);
416 /* go through original table */
417 while(lua_next(L
, -3))
419 /* if convert value to wtable */
420 luaA_table2wtable(L
);
422 lua_pushvalue(L
, -2);
423 /* move key before value */
425 /* set same value in content table */
428 lua_pushvalue(L
, -1);
429 /* push the new value :-> */
431 /* set orig[k] = nil */
434 /* remove content table */
438 /** Look for an item: table, function, etc.
439 * \param L The Lua VM state.
440 * \param item The pointer item.
443 luaA_hasitem(lua_State
*L
, const void *item
)
446 while(luaA_next(L
, -2))
448 if(lua_topointer(L
, -1) == item
)
450 /* remove value and key */
454 if(lua_istable(L
, -1))
455 if(luaA_hasitem(L
, item
))
457 /* remove key and value */
467 /** Browse a table pushed on top of the index, and put all its table and
468 * sub-table into an array.
469 * \param L The Lua VM state.
470 * \param elems The elements array.
471 * \return False if we encounter an elements already in list.
474 luaA_isloop_check(lua_State
*L
, cptr_array_t
*elems
)
476 if(lua_istable(L
, -1))
478 const void *object
= lua_topointer(L
, -1);
480 /* Check that the object table is not already in the list */
481 for(int i
= 0; i
< elems
->len
; i
++)
482 if(elems
->tab
[i
] == object
)
485 /* push the table in the elements list */
486 cptr_array_append(elems
, object
);
488 /* look every object in the "table" */
490 while(luaA_next(L
, -2))
492 if(!luaA_isloop_check(L
, elems
))
494 /* remove key and value */
498 /* remove value, keep key for next iteration */
505 /** Check if a table is a loop. When using tables as direct acyclic digram,
507 * \param L The Lua VM state.
508 * \param idx The index of the table in the stack
509 * \return True if the table loops.
512 luaA_isloop(lua_State
*L
, int idx
)
514 /* elems is an elements array that we will fill with all array we
515 * encounter while browsing the tables */
518 cptr_array_init(&elems
);
520 /* push table on top */
521 lua_pushvalue(L
, idx
);
523 bool ret
= luaA_isloop_check(L
, &elems
);
525 /* remove pushed table */
528 cptr_array_wipe(&elems
);
533 /** awesome global table.
534 * \param L The Lua VM state.
535 * \return The number of elements pushed on stack.
537 * \lfield font The default font.
538 * \lfield font_height The default font height.
539 * \lfield conffile The configuration file which has been loaded.
542 luaA_awesome_index(lua_State
*L
)
544 if(luaA_usemetatable(L
, 1, 2))
548 const char *buf
= luaL_checklstring(L
, 2, &len
);
550 switch(a_tokenize(buf
, len
))
554 char *font
= pango_font_description_to_string(globalconf
.font
->desc
);
555 lua_pushstring(L
, font
);
559 case A_TK_FONT_HEIGHT
:
560 lua_pushnumber(L
, globalconf
.font
->height
);
563 lua_pushstring(L
, globalconf
.conffile
);
566 luaA_pushxcolor(L
, globalconf
.colors
.fg
);
569 luaA_pushxcolor(L
, globalconf
.colors
.bg
);
572 lua_pushliteral(L
, AWESOME_VERSION
);
575 lua_pushliteral(L
, AWESOME_RELEASE
);
577 case A_TK_STARTUP_ERRORS
:
578 if (globalconf
.startup_errors
.len
== 0)
580 lua_pushstring(L
, globalconf
.startup_errors
.s
);
588 /** Newindex function for the awesome global table.
589 * \param L The Lua VM state.
590 * \return The number of elements pushed on stack.
593 luaA_awesome_newindex(lua_State
*L
)
595 if(luaA_usemetatable(L
, 1, 2))
599 const char *buf
= luaL_checklstring(L
, 2, &len
);
601 switch(a_tokenize(buf
, len
))
605 const char *newfont
= luaL_checkstring(L
, 3);
606 draw_font_delete(&globalconf
.font
);
607 globalconf
.font
= draw_font_new(newfont
);
608 /* refresh all wiboxes */
609 foreach(wibox
, globalconf
.wiboxes
)
610 (*wibox
)->need_update
= true;
611 foreach(c
, globalconf
.clients
)
613 (*c
)->titlebar
->need_update
= true;
617 if((buf
= luaL_checklstring(L
, 3, &len
)))
618 xcolor_init_reply(xcolor_init_unchecked(&globalconf
.colors
.fg
, buf
, len
));
621 if((buf
= luaL_checklstring(L
, 3, &len
)))
622 xcolor_init_reply(xcolor_init_unchecked(&globalconf
.colors
.bg
, buf
, len
));
631 /** Add a global signal.
632 * \param L The Lua VM state.
633 * \return The number of elements pushed on stack.
635 * \lparam A string with the event name.
636 * \lparam The function to call.
639 luaA_awesome_add_signal(lua_State
*L
)
641 const char *name
= luaL_checkstring(L
, 1);
642 luaA_checkfunction(L
, 2);
643 signal_add(&global_signals
, name
, luaA_object_ref(L
, 2));
647 /** Remove a global signal.
648 * \param L The Lua VM state.
649 * \return The number of elements pushed on stack.
651 * \lparam A string with the event name.
652 * \lparam The function to call.
655 luaA_awesome_remove_signal(lua_State
*L
)
657 const char *name
= luaL_checkstring(L
, 1);
658 luaA_checkfunction(L
, 2);
659 const void *func
= lua_topointer(L
, 2);
660 signal_remove(&global_signals
, name
, func
);
661 luaA_object_unref(L
, (void *) func
);
665 /** Emit a global signal.
666 * \param L The Lua VM state.
667 * \return The number of elements pushed on stack.
669 * \lparam A string with the event name.
670 * \lparam The function to call.
673 luaA_awesome_emit_signal(lua_State
*L
)
675 signal_object_emit(L
, &global_signals
, luaL_checkstring(L
, 1), lua_gettop(L
) - 1);
680 luaA_panic(lua_State
*L
)
682 warn("unprotected error in call to Lua API (%s), restarting awesome",
683 lua_tostring(L
, -1));
689 luaA_dofunction_on_error(lua_State
*L
)
691 /* duplicate string error */
692 lua_pushvalue(L
, -1);
693 /* emit error signal */
694 signal_object_emit(L
, &global_signals
, "debug::error", 1);
696 if(!luaL_dostring(L
, "return debug.traceback(\"error while running function\", 3)"))
698 /* Move traceback before error */
700 /* Insert sentence */
701 lua_pushliteral(L
, "\nerror: ");
702 /* Move it before error */
709 /** Initialize the Lua VM
710 * \param xdg An xdg handle to use to get XDG basedir.
713 luaA_init(xdgHandle
* xdg
)
716 static const struct luaL_reg awesome_lib
[] =
718 { "quit", luaA_quit
},
719 { "exec", luaA_exec
},
720 { "spawn", luaA_spawn
},
721 { "restart", luaA_restart
},
722 { "add_signal", luaA_awesome_add_signal
},
723 { "remove_signal", luaA_awesome_remove_signal
},
724 { "emit_signal", luaA_awesome_emit_signal
},
725 { "__index", luaA_awesome_index
},
726 { "__newindex", luaA_awesome_newindex
},
730 L
= globalconf
.L
= luaL_newstate();
732 /* Set panic function */
733 lua_atpanic(L
, luaA_panic
);
735 /* Set error handling function */
736 lualib_dofunction_on_error
= luaA_dofunction_on_error
;
742 luaA_object_setup(L
);
744 /* Export awesome lib */
745 luaA_openlib(L
, "awesome", awesome_lib
, awesome_lib
);
747 /* Export root lib */
748 luaL_register(L
, "root", awesome_root_lib
);
749 lua_pop(L
, 1); /* luaL_register() leaves the table on stack */
751 /* Export hooks lib */
752 luaL_register(L
, "hooks", awesome_hooks_lib
);
753 lua_pop(L
, 1); /* luaL_register() leaves the table on stack */
756 /* Export D-Bus lib */
757 luaL_register(L
, "dbus", awesome_dbus_lib
);
758 lua_pop(L
, 1); /* luaL_register() leaves the table on stack */
761 /* Export keygrabber lib */
762 luaL_register(L
, "keygrabber", awesome_keygrabber_lib
);
763 lua_pop(L
, 1); /* luaL_register() leaves the table on stack */
765 /* Export mousegrabber lib */
766 luaL_register(L
, "mousegrabber", awesome_mousegrabber_lib
);
767 lua_pop(L
, 1); /* luaL_register() leaves the table on stack */
770 luaA_openlib(L
, "screen", awesome_screen_methods
, awesome_screen_meta
);
773 luaA_openlib(L
, "mouse", awesome_mouse_methods
, awesome_mouse_meta
);
776 button_class_setup(L
);
779 image_class_setup(L
);
785 wibox_class_setup(L
);
788 widget_class_setup(L
);
791 client_class_setup(L
);
797 timer_class_setup(L
);
800 globalconf
.hooks
.manage
= LUA_REFNIL
;
801 globalconf
.hooks
.unmanage
= LUA_REFNIL
;
802 globalconf
.hooks
.focus
= LUA_REFNIL
;
803 globalconf
.hooks
.unfocus
= LUA_REFNIL
;
804 globalconf
.hooks
.mouse_enter
= LUA_REFNIL
;
805 globalconf
.hooks
.mouse_leave
= LUA_REFNIL
;
806 globalconf
.hooks
.clients
= LUA_REFNIL
;
807 globalconf
.hooks
.tags
= LUA_REFNIL
;
808 globalconf
.hooks
.tagged
= LUA_REFNIL
;
809 globalconf
.hooks
.property
= LUA_REFNIL
;
810 globalconf
.hooks
.timer
= LUA_REFNIL
;
811 globalconf
.hooks
.exit
= LUA_REFNIL
;
813 /* add Lua search paths */
814 lua_getglobal(L
, "package");
815 if (LUA_TTABLE
!= lua_type(L
, 1))
817 warn("package is not a table");
820 lua_getfield(L
, 1, "path");
821 if (LUA_TSTRING
!= lua_type(L
, 2))
823 warn("package.path is not a string");
828 /* add XDG_CONFIG_DIR as include path */
829 const char * const *xdgconfigdirs
= xdgSearchableConfigDirectories(xdg
);
830 for(; *xdgconfigdirs
; xdgconfigdirs
++)
832 size_t len
= a_strlen(*xdgconfigdirs
);
833 lua_pushliteral(L
, ";");
834 lua_pushlstring(L
, *xdgconfigdirs
, len
);
835 lua_pushliteral(L
, "/awesome/?.lua");
838 lua_pushliteral(L
, ";");
839 lua_pushlstring(L
, *xdgconfigdirs
, len
);
840 lua_pushliteral(L
, "/awesome/?/init.lua");
843 lua_concat(L
, 3); /* concatenate with package.path */
846 /* add Lua lib path (/usr/share/awesome/lib by default) */
847 lua_pushliteral(L
, ";" AWESOME_LUA_LIB_PATH
"/?.lua");
848 lua_pushliteral(L
, ";" AWESOME_LUA_LIB_PATH
"/?/init.lua");
849 lua_concat(L
, 3); /* concatenate with package.path */
850 lua_setfield(L
, 1, "path"); /* package.path = "concatenated string" */
854 luaA_startup_error(const char *err
)
856 if (globalconf
.startup_errors
.len
> 0)
857 buffer_addsl(&globalconf
.startup_errors
, "\n\n");
858 buffer_adds(&globalconf
.startup_errors
, err
);
862 luaA_loadrc(const char *confpath
, bool run
)
864 if(!luaL_loadfile(globalconf
.L
, confpath
))
868 /* Set the conffile right now so it can be used inside the
869 * configuration file. */
870 globalconf
.conffile
= a_strdup(confpath
);
871 if(lua_pcall(globalconf
.L
, 0, LUA_MULTRET
, 0))
873 const char *err
= lua_tostring(globalconf
.L
, -1);
874 luaA_startup_error(err
);
875 fprintf(stderr
, "%s\n", err
);
876 /* An error happened, so reset this. */
877 globalconf
.conffile
= NULL
;
884 lua_pop(globalconf
.L
, 1);
890 const char *err
= lua_tostring(globalconf
.L
, -1);
891 luaA_startup_error(err
);
892 fprintf(stderr
, "%s\n", err
);
898 /** Load a configuration file.
899 * \param xdg An xdg handle to use to get XDG basedir.
900 * \param confpatharg The configuration file to load.
901 * \param run Run the configuration file.
904 luaA_parserc(xdgHandle
* xdg
, const char *confpatharg
, bool run
)
906 char *confpath
= NULL
;
909 /* try to load, return if it's ok */
912 if(luaA_loadrc(confpatharg
, run
))
921 confpath
= xdgConfigFind("awesome/rc.lua", xdg
);
923 char *tmp
= confpath
;
925 /* confpath is "string1\0string2\0string3\0\0" */
928 if(luaA_loadrc(tmp
, run
))
935 tmp
+= a_strlen(tmp
) + 1;
946 luaA_on_timer(EV_P_ ev_timer
*w
, int revents
)
948 if(globalconf
.hooks
.timer
!= LUA_REFNIL
)
949 luaA_dofunction_from_registry(globalconf
.L
, globalconf
.hooks
.timer
, 0, 0);
953 luaA_class_index_miss_property(lua_State
*L
, lua_object_t
*obj
)
955 signal_object_emit(L
, &global_signals
, "debug::index::miss", 2);
960 luaA_class_newindex_miss_property(lua_State
*L
, lua_object_t
*obj
)
962 signal_object_emit(L
, &global_signals
, "debug::newindex::miss", 3);
966 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80