773pages on
this wiki
Browse all patches

Author Edit

Teika kazura

Synopsis Edit

This patch improves the treatment of the boolean property of the window. It modifies the function `window-get', by adding an optional argument. It has no side effect (I mean the ordinary, not lisp side effect), not requiring any fix in existing codes.

The author thanks Tkorvola for the useful comment.


(window-get window prop &optional checker)

The function `window-get' returns the value of the property PROP of WINDOW.

The current version of `window-get' returns nil either when the property value is nil, or the property is not set at all. There isn't a way to distinguish these two different situations.

In this patch, the function can take an optional argument CHECKER. If it is non-nil and PROP is unset, then it returns CHECKER.


As a practical application of this patch, see my another patch focus policy improvement.

If this patch is to be accepted, then I would write the manual entry, too. The patch for the manual is now included. -Teika kazura 05:24, 25 June 2008 (UTC)

Thank you for reading.

Patch testing Edit

  1. Copy/paste the patch listed below into some file, eg. TEST.diff.
  2. If you don't have sawfish sources yet, have one, as described get it from GIT repo.
  3. Go into the directory where sawfish sources reside, eg. cd sawfish
  4. Test if the patch applies cleanly with this command:
    patch -p1 --ignore-whitespace --dry-run < TEST.diff
    in case of problems try also: -p0 or -p2
  5. If it applies cleanly, then remove the --dry-run from above command and run it again, otherwise ask on the mailing list.
  6. Compile sawfish: ./ && make
  7. Install it for testing, but it depends on your linux distribution.
    1. It is always better to install sawfish as your distribution package, but it is different for each distribution.
    2. So you may try make install, which will install sawifish in /usr/local/share/sawfish/ (if you have write access). But then make sure that you run the correct version and delete it from that directory afterwards, to avoid any conflicts.
  8. Se also

PS: edit this template if you feel that those instructions can be improved.

Patch Edit

diff -ur sawfish-1.3.3.orig/src/frames.c sawfish-1.3.3/src/frames.c
--- sawfish-1.3.3.orig/src/frames.c	2007-07-29 18:45:03.000000000 +0900
+++ sawfish-1.3.3/src/frames.c	2008-06-21 17:25:53.000000000 +0900
@@ -1179,7 +1179,7 @@
     tem = Fassq (Qremovable, fp->alist);
     if (tem && tem != Qnil && rep_CDR(tem) != Qnil)
-	tem = Fwindow_get (rep_VAL(w), Qremoved_classes);	/* XXX hoist */
+       tem = Fwindow_get (rep_VAL(w), Qremoved_classes, Qnil);	/* XXX hoist */
 	if (tem && rep_CONSP(tem))
 	    tem = Fmemq (class, tem);
@@ -1464,7 +1464,7 @@
     /* bounding box of frame */
     int left_x, top_y, right_x, bottom_y;
-    tem = Fwindow_get (rep_VAL(w), Qhide_client);
+    tem = Fwindow_get (rep_VAL(w), Qhide_client, Qnil);
     if (tem && tem != Qnil)
 	w->client_hidden = 1;
diff -ur sawfish-1.3.3.orig/src/keys.c sawfish-1.3.3/src/keys.c
--- sawfish-1.3.3.orig/src/keys.c	2007-07-29 18:45:03.000000000 +0900
+++ sawfish-1.3.3/src/keys.c	2008-06-21 17:27:02.000000000 +0900
@@ -477,7 +477,7 @@
 	    if (!k && current_window)
 		/* 3. search focused/pointer window keymap property */
-		tem = Fwindow_get (rep_VAL(current_window), Qkeymap);
+	        tem = Fwindow_get (rep_VAL(current_window), Qkeymap, Qnil);
 		if (tem && tem != Qnil)
 		    k = search_keymap(tem, code, mods, callback);
@@ -1778,7 +1778,7 @@
 	if (!WINDOW_IS_GONE_P (w))
-	    repv tem = Fwindow_get (rep_VAL(w), Qkeymap);
+	    repv tem = Fwindow_get (rep_VAL(w), Qkeymap, Qnil);
 	    if (rep_SYMBOLP(tem) && tem != Qnil)
 		tem = Fsymbol_value (tem, Qt);
 	    if (km == global || tem == km)
@@ -1838,7 +1838,7 @@
     tem = Fsymbol_value (Qglobal_keymap, Qt);
     if (tem != Qnil && !rep_VOIDP(tem) && !WINDOW_IS_GONE_P (w))
 	grab_keymap_events (w->id, tem, grab);
-    tem = Fwindow_get (rep_VAL(w), Qkeymap);
+    tem = Fwindow_get (rep_VAL(w), Qkeymap, Qnil);
     if (tem && tem != Qnil && !WINDOW_IS_GONE_P (w))
 	grab_keymap_events (w->id, tem, grab);
diff -ur sawfish-1.3.3.orig/src/sawmill_subrs.h sawfish-1.3.3/src/sawmill_subrs.h
--- sawfish-1.3.3.orig/src/sawmill_subrs.h	2008-01-19 20:58:51.000000000 +0900
+++ sawfish-1.3.3/src/sawmill_subrs.h	2008-06-21 18:15:48.000000000 +0900
@@ -318,7 +318,7 @@
 extern Lisp_Window *add_window (Window id);
 extern void remove_window (Lisp_Window *win, bool destroyed, bool from_error);
 extern void emit_pending_destroys (void);
-extern repv Fwindow_get (repv win, repv prop);
+extern repv Fwindow_get (repv win, repv prop, repv checker);
 extern void register_property_monitor (repv prop, void (*callback)
 				       (Lisp_Window *, repv, repv, repv));
 extern repv Fwindow_put (repv win, repv prop, repv value);
diff -ur sawfish-1.3.3.orig/src/windows.c sawfish-1.3.3/src/windows.c
--- sawfish-1.3.3.orig/src/windows.c	2008-02-19 04:27:34.000000000 +0900
+++ sawfish-1.3.3/src/windows.c	2008-06-21 18:18:34.000000000 +0900
@@ -536,7 +536,7 @@
 	if (!WINDOW_IS_GONE_P (w))
-	    repv tem = Fwindow_get (rep_VAL(w), Qplaced);
+           repv tem = Fwindow_get (rep_VAL(w), Qplaced, Qnil);
 	    if (initialising || (tem && tem == Qnil))
 		/* ..then the place-window-hook.. */
@@ -639,13 +639,19 @@
 /* Lisp functions */
 DEFUN("window-get", Fwindow_get, Swindow_get,
-      (repv win, repv prop), rep_Subr2) /*
+      (repv win, repv prop, repv checker), rep_Subr3) /*
+window-get WINDOW PROPERTY &optional CHECKER
 Return the value of the property named PROPERTY (a symbol) of WINDOW.
 Note that these are Lisp properties not X properties.
+If the optional argument CHECKER is nil, then the return value is
+nil, either when the property value is nil, or the property is absent.
+If CHECKER is non-nil, than it returns CHECKER if the property
+is unset.
 ::end:: */
     repv plist;
@@ -661,7 +667,7 @@
 	plist = rep_CDR(rep_CDR(plist));
-    return Qnil;
+    return checker;
 DEFUN("map-window-properties", Fmap_window_properties,
@@ -1292,7 +1298,7 @@
     rep_PUSHGC(gc_hook, hook);
     rep_PUSHGC(gc_args, args);
     rep_PUSHGC(gc_type, type);
-    tem = Fwindow_get (win, hook);
+    tem = Fwindow_get (win, hook, Qnil);
     if (tem && tem != Qnil)
 	tem = Fcall_hook (tem, args, type);
diff -ur sawfish-1.3.3.orig/man/sawmill.texi sawfish-1.3.3/man/sawmill.texi
--- sawfish-1.3.3.orig/man/sawmill.texi	2007-07-29 23:33:15.000000000 +0900
+++ sawfish-1.3.3/man/sawmill.texi	2008-06-24 20:43:34.000000000 +0900
@@ -824,10 +824,14 @@
 properties not X properties.
 @end defun
-@defun window-get window property
+@defun window-get window property &optional checker
 Return the window property named @var{property} (a symbol) associated
 with the window object @var{window}, or @code{nil} if no such property
 exists.  Note that these are Lisp properties not X properties.
+If the optional third argument @var{checker} is non-nil, then @var{checker}
+is returned if the requested property does not exist. This is used to
+distinguish the assigned value of @code{nil} from property's absence.
 @end defun
 @defun map-window-properties function window

`window-get' is defined in src/windows.c, and it is also declared in src/sawmill_subrs.h. They get patched.

Invocations of `window-get' in windows.c and other two files are modified, by explicitly giving 'nil' as the new optional argument, but it may be unnecessary.

The manual item in 'sawmill.texi' is also patched.

History Edit

This patch first appeared in lisp. I'd defined a new function.

Then Tkorvola referred to the above design which is present in common lisp (absent in emacs lisp). It was clear that the new idea is better, and I re-implemented it in C.

Community's reasons for inclusion or rejection Edit

When voting anonymously please write your name, so that it can be associated with your posts on the mailing list. If you are logged in you can sign yourself by typing four tilda characters: ~~~~.

The discussion before the current version patch is here.

  • Yes vote: yes. Seems to work, although to make this useful we also need window-remprop. window-plist and window-setplist would also be nice. Tkorvola 23:13, 23 June 2008 (UTC)
The issue of the suggested functions is further discussed in focus policy improvement. It would be better to separate the stuff to be solved from here, because the conclusion for this patch seems near. - Teika kazura 05:24, 25 June 2008 (UTC)
  • Yes vote: yes. Tested and applied. I hope that by applying it I will motivate you to also write window-setplist patch. Other patches (window-remprop and window-plist are in Window prop list & prop del) Also tested by Andrea Janek Kozicki 13:01, 4 August 2008 (UTC)

Around Wikia's network

Random Wiki