Re: [dwm] Suckess Code Management

2009-03-12 Thread Ali Gholami Rudi
Hi,

Amit Uttamchandani atu13...@csun.edu wrote:
  3. Text Editor - Vim

I mostly use elvis which, in my opinion, is much smaller, faster and
more suckless vi-clone than vim.  As a little example compare elvis.syn
with vim syntax files.  It even has interesting features that vim lacks
(for instance see :display or smartargs). (they might be available in
vim through scripts.)

The only problem is it is not maintained anymore, AFAIK (I have sent a
couple of patches to Steve Kirkendall but got no response; neither does
the web page show any activity).  I really hope it to be maintained once
more :-(

Regards,
Ali



Re: [dwm] Suckess Code Management

2009-03-12 Thread Ali Gholami Rudi
Hi pancake,

pancake panc...@youterm.com wrote:
 i was using elvis so far until i started using vim. I was pretty happy with
 it, but the feeling was that it was keeping so much stuff in the core
 instead of delegating to external programs or scripts.

 But thats true, elvis is smaller than vim :) you can publish a git/bzr/hg
 branch of the last commit with your patches. I will happy try it and we
 can probably use it as a playground.

I'm afraid currently I'm away and won't have access to good internet
connection for a few weeks.  If someone else volunteers to make a public
repo, it would be really cool; otherwise I'll probably do that on
repo.or.cz when I'm back.

The doc/bugs.txt file in 2.2_1 shows a list of features and bugs.  I'm
not sure which of them is implemented/fixed, already.  I've got simple
patches to support vim style global/local mark support and to make put
command accept a count.  But, I use only the termcap gui and it might
break others (though unlikely).

Somehow off-topic: tcc compiles elvis in almost one second which is
*really* cool.

Regards,
Ali



Re: [dwm] key bindings / french layout

2007-10-11 Thread Ali Gholami Rudi
On Wed, Oct 10, 2007 at 10:08:53PM +0200, Xavier wrote:
 On Wed, Oct 10, 2007 at 09:57:28PM +0200, Adrien Barilly wrote:
  You might also want to map the 'Multi_key' to a key of your keyboard (in
  my case, RAlt, keycode 113); this would make the key a 'dead key': press
  it, press the modifier and finally press the letter. Alright, that makes
  3 keys for one character; but it allows you to make a lot of other
  characters.
  
  Examples:
  Multi_key + ' + e = é
  Multi_key + ` + e = è
  Multi_key + , + c = ç
  but also
  Multi_key + c + c = č
  Multi_key + o + u = ů
  Multi_key + ~ + n = ñ
  Multi_key + c + t = ť
  or almost anything you can think of (useful if you want to write in
  several languages).
  
  
 
 Yep, that's what I was using lately, us + compose key.
 I just found 3 keys too painful : é à and ç are directly available on the
 azerty layout, and are quite frequently needed.
 Now I have them available with two keys : altgr+w, altgr+a, altgr+c, which is
 still practical.
 
 But indeed, the compose key would be very useful for writing a wide range of
 characters that are not too frequent.
 

If you use emacs, you can use its C-x 8 prefix.  Such as:

  C-x 8 ` aiso-transl-a-grave
  C-x 8 ' eiso-transl-e-acute
  C-x 8  uiso-transl-u-umlaut
  C-x 8 ^ iiso-transl-i-caret
  C-x 8 ~ niso-transl-n-tilde

Use C-x 8 C-h to see all of them.


signature.asc
Description: Digital signature


[dwm] [patch] Simplifying tag keys in config.h

2007-10-07 Thread Ali Gholami Rudi
A patch to use TAGKEYS macro for listing keys.
diff --git a/config.def.h b/config.def.h
--- a/config.def.h
+++ b/config.def.h
@@ -34,6 +34,11 @@ Layout layouts[] = {
 
 /* key definitions */
 #define MODKEY			Mod1Mask
+#define TAGKEYS(x) \
+	{ MODKEY,			XK_##x,		view,		#x }, \
+	{ MODKEY|ControlMask,		XK_##x,		toggleview,	#x }, \
+	{ MODKEY|ShiftMask,		XK_##x,		tag,		#x }, \
+	{ MODKEY|ControlMask|ShiftMask,	XK_##x,		toggletag,	#x }
 #define KEYS \
 Key keys[] = { \
 	/* modifier			key		function	argument */ \
@@ -52,42 +57,15 @@ Key keys[] = { \
 	{ MODKEY|ShiftMask,		XK_space,	togglefloating,	NULL }, \
 	{ MODKEY|ShiftMask,		XK_c,		killclient,	NULL }, \
 	{ MODKEY,			XK_0,		view,		NULL }, \
-	{ MODKEY,			XK_1,		view,		tags[0] }, \
-	{ MODKEY,			XK_2,		view,		tags[1] }, \
-	{ MODKEY,			XK_3,		view,		tags[2] }, \
-	{ MODKEY,			XK_4,		view,		tags[3] }, \
-	{ MODKEY,			XK_5,		view,		tags[4] }, \
-	{ MODKEY,			XK_6,		view,		tags[5] }, \
-	{ MODKEY,			XK_7,		view,		tags[6] }, \
-	{ MODKEY,			XK_8,		view,		tags[7] }, \
-	{ MODKEY,			XK_9,		view,		tags[8] }, \
-	{ MODKEY|ControlMask,		XK_1,		toggleview,	tags[0] }, \
-	{ MODKEY|ControlMask,		XK_2,		toggleview,	tags[1] }, \
-	{ MODKEY|ControlMask,		XK_3,		toggleview,	tags[2] }, \
-	{ MODKEY|ControlMask,		XK_4,		toggleview,	tags[3] }, \
-	{ MODKEY|ControlMask,		XK_5,		toggleview,	tags[4] }, \
-	{ MODKEY|ControlMask,		XK_6,		toggleview,	tags[5] }, \
-	{ MODKEY|ControlMask,		XK_7,		toggleview,	tags[6] }, \
-	{ MODKEY|ControlMask,		XK_8,		toggleview,	tags[7] }, \
-	{ MODKEY|ControlMask,		XK_9,		toggleview,	tags[8] }, \
 	{ MODKEY|ShiftMask,		XK_0,		tag,		NULL }, \
-	{ MODKEY|ShiftMask,		XK_1,		tag,		tags[0] }, \
-	{ MODKEY|ShiftMask,		XK_2,		tag,		tags[1] }, \
-	{ MODKEY|ShiftMask,		XK_3,		tag,		tags[2] }, \
-	{ MODKEY|ShiftMask,		XK_4,		tag,		tags[3] }, \
-	{ MODKEY|ShiftMask,		XK_5,		tag,		tags[4] }, \
-	{ MODKEY|ShiftMask,		XK_6,		tag,		tags[5] }, \
-	{ MODKEY|ShiftMask,		XK_7,		tag,		tags[6] }, \
-	{ MODKEY|ShiftMask,		XK_8,		tag,		tags[7] }, \
-	{ MODKEY|ShiftMask,		XK_9,		tag,		tags[8] }, \
-	{ MODKEY|ControlMask|ShiftMask,	XK_1,		toggletag,	tags[0] }, \
-	{ MODKEY|ControlMask|ShiftMask,	XK_2,		toggletag,	tags[1] }, \
-	{ MODKEY|ControlMask|ShiftMask,	XK_3,		toggletag,	tags[2] }, \
-	{ MODKEY|ControlMask|ShiftMask,	XK_4,		toggletag,	tags[3] }, \
-	{ MODKEY|ControlMask|ShiftMask,	XK_5,		toggletag,	tags[4] }, \
-	{ MODKEY|ControlMask|ShiftMask,	XK_6,		toggletag,	tags[5] }, \
-	{ MODKEY|ControlMask|ShiftMask,	XK_7,		toggletag,	tags[6] }, \
-	{ MODKEY|ControlMask|ShiftMask,	XK_8,		toggletag,	tags[7] }, \
-	{ MODKEY|ControlMask|ShiftMask,	XK_9,		toggletag,	tags[8] }, \
 	{ MODKEY|ShiftMask,		XK_q,		quit,		NULL }, \
+	TAGKEYS(1), \
+	TAGKEYS(2), \
+	TAGKEYS(3), \
+	TAGKEYS(4), \
+	TAGKEYS(5), \
+	TAGKEYS(6), \
+	TAGKEYS(7), \
+	TAGKEYS(8), \
+	TAGKEYS(9), \
 };


signature.asc
Description: Digital signature


Re: [dwm] Keys with prefix

2007-10-05 Thread Ali Gholami Rudi
On Thu, Oct 04, 2007 at 03:01:12PM +0330, Ali Gholami Rudi wrote:
 I've written a patch to allow prefixed keys.
 
 With this patch you can bind ``C-t k`` (where ``C-t`` is your prefix),
 for instance, to kill window or ``C-t 1`` to ``view(1)``.  You can
 change the prefix by editing the line that contains the ``setprefix``
 function in the config file.
 
 I've written this patch because:
 
 * Some of dwm's default keys conflict with emacs keybinding
 * Some emacs users, including me, don't like to push three buttons at
   the same time very oftern
 * If ``? x`` (? is the prefix and x is a tag) is bound to view(x),
   letters can be a tag like digits.
 * Prefixed and normal keys can coexist
 
 I didn't know dwm's policy for submitting patches; so I've attached
 the outcome of ``hg export``.

In the last patch prefixed keys could not contain modifiers such as
``? shift-1`` (where ``?`` is the prefix).  This patch fixes it.
So now one can bind:

* C-; x - view(x)
* C-; shift-x - tag(x)
* C-; C-x - toggleview(x)
* C-; C-shift-x - toggletag(x)

for both letters and digits (where ``C-;`` is the prefix).


--Ali
# HG changeset patch
# User Ali Gholami Rudi [EMAIL PROTECTED]
# Date 1191574032 -12600
# Node ID f66c2d9024734507164a26603a6fd29db54710ad
# Parent  3027df4b2c0d6a894818f23643ae453b99e98591
Added prefixed keys

diff --git a/config.def.h b/config.def.h
--- a/config.def.h
+++ b/config.def.h
@@ -90,4 +90,12 @@ Key keys[] = { \
 	{ MODKEY|ControlMask|ShiftMask,	XK_8,		toggletag,	tags[7] }, \
 	{ MODKEY|ControlMask|ShiftMask,	XK_9,		toggletag,	tags[8] }, \
 	{ MODKEY|ShiftMask,		XK_q,		quit,		NULL }, \
+	{ ControlMask,			XK_t,		setprefix,	NULL }, \
 };
+
+#define PREFIXEDKEYS \
+Key prefixedkeys[] = { \
+	/* modifier			key		function	argument */ \
+	{ 0,XK_1,		view,		tags[0] }, \
+	{ ShiftMask,			XK_1,		tag,		tags[0] }, \
+};
diff --git a/dwm.c b/dwm.c
--- a/dwm.c
+++ b/dwm.c
@@ -143,6 +143,7 @@ long getstate(Window w);
 long getstate(Window w);
 Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
 void grabbuttons(Client *c, Bool focused);
+void handlekey(Key keys[], unsigned int len, XEvent *e);
 unsigned int idxoftag(const char *tag);
 void initfont(const char *fontstr);
 Bool isarrange(void (*func)());
@@ -167,6 +168,7 @@ void setclientstate(Client *c, long stat
 void setclientstate(Client *c, long state);
 void setlayout(const char *arg);
 void setmwfact(const char *arg);
+void setprefix(const char *arg);
 void setup(void);
 void spawn(const char *arg);
 void tag(const char *arg);
@@ -228,6 +230,7 @@ DC dc = {0};
 DC dc = {0};
 Window barwin, root;
 Regs *regs = NULL;
+Bool prefix = False;
 
 /* configuration, allows nested code to access above variables */
 #include config.h
@@ -840,6 +843,23 @@ grabbuttons(Client *c, Bool focused) {
 GrabModeAsync, GrabModeSync, None, None);
 }
 
+void
+handlekey(Key keys[], unsigned int len, XEvent *e) {
+	XKeyEvent *ev;
+	KeySym keysym;
+	unsigned int i;
+
+	ev = e-xkey;
+	keysym = XKeycodeToKeysym(dpy, (KeyCode)ev-keycode, 0);
+	for(i = 0; i  len; i++)
+		if(keysym == keys[i].keysym
+		 CLEANMASK(keys[i].mod) == CLEANMASK(ev-state))
+		{
+			if(keys[i].func)
+keys[i].func(keys[i].arg);
+		}
+}
+
 unsigned int
 idxoftag(const char *tag) {
 	unsigned int i;
@@ -936,13 +956,20 @@ void
 void
 keypress(XEvent *e) {
 	KEYS
+	PREFIXEDKEYS
 	unsigned int len = sizeof keys / sizeof keys[0];
+	unsigned int prefixedlen = sizeof prefixedkeys / sizeof prefixedkeys[0];
 	unsigned int i;
 	KeyCode code;
 	KeySym keysym;
 	XKeyEvent *ev;
 
 	if(!e) { /* grabkeys */
+		if (prefix) {
+			XGrabKey(dpy, AnyKey, AnyModifier, root, True,
+	GrabModeAsync, GrabModeAsync);
+			return;
+		}
 		XUngrabKey(dpy, AnyKey, AnyModifier, root);
 		for(i = 0; i  len; i++) {
 			code = XKeysymToKeycode(dpy, keys[i].keysym);
@@ -957,15 +984,17 @@ keypress(XEvent *e) {
 		}
 		return;
 	}
-	ev = e-xkey;
-	keysym = XKeycodeToKeysym(dpy, (KeyCode)ev-keycode, 0);
-	for(i = 0; i  len; i++)
-		if(keysym == keys[i].keysym
-		 CLEANMASK(keys[i].mod) == CLEANMASK(ev-state))
-		{
-			if(keys[i].func)
-keys[i].func(keys[i].arg);
-		}
+	if (prefix) {
+		ev = e-xkey;
+		keysym = XKeycodeToKeysym(dpy, (KeyCode)ev-keycode, 0);
+		if (!IsModifierKey(keysym)) {
+			handlekey(prefixedkeys, prefixedlen, e);
+			prefix = False;
+			keypress(NULL);
+		}
+	}
+	else
+		handlekey(keys, len, e);
 }
 
 void
@@ -1418,6 +1447,12 @@ setmwfact(const char *arg) {
 }
 
 void
+setprefix(const char *arg) {
+	prefix = True;
+	keypress(NULL);
+}
+
+void
 setup(void) {
 	int d;
 	unsigned int i, j, mask;


signature.asc
Description: Digital signature