From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joakim@verona.se Newsgroups: gmane.emacs.devel Subject: Re: Adding parameters to windows Date: Fri, 23 May 2008 22:28:21 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1211574799 17245 80.91.229.12 (23 May 2008 20:33:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 May 2008 20:33:19 +0000 (UTC) Cc: klaus.berndl@sdm.de, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 23 22:33:56 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JzdxT-0005IT-Hm for ged-emacs-devel@m.gmane.org; Fri, 23 May 2008 22:33:47 +0200 Original-Received: from localhost ([127.0.0.1]:37914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jzdwi-0006Tc-VC for ged-emacs-devel@m.gmane.org; Fri, 23 May 2008 16:33:01 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jzdwd-0006RA-Bu for emacs-devel@gnu.org; Fri, 23 May 2008 16:32:55 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jzdwc-0006QQ-LW for emacs-devel@gnu.org; Fri, 23 May 2008 16:32:55 -0400 Original-Received: from [199.232.76.173] (port=57319 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jzdwc-0006QJ-J1 for emacs-devel@gnu.org; Fri, 23 May 2008 16:32:54 -0400 Original-Received: from iwfs.imcode.com ([82.115.149.64]:47873 helo=gate.verona.se) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Jzdwc-0004K7-3y for emacs-devel@gnu.org; Fri, 23 May 2008 16:32:54 -0400 Original-Received: from chopper (IDENT:1005@localhost [127.0.0.1]) by gate.verona.se (8.13.4/8.11.4) with ESMTP id m4NKWkJb020575; Fri, 23 May 2008 22:32:49 +0200 In-Reply-To: (Stefan Monnier's message of "Fri, 23 May 2008 15:47:17 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:97614 Archived-At: --=-=-= Stefan Monnier writes: > Your patch needs a few tweaks, e.g. to adjust it to the coding > conventions: > - The docstring of window-parameters is poor. > E.g. the first line doesn't say anything. The second line is indented > in the source, which looks bad when you do C-h f window-parameters. > nil is an aliast as well, so there's no need to mention it explicitly. > - I'd prefer to have `window-parameter' rather than `window-parameters'. > - The docstring of set-window-parameter needs to start with a capital > letter and end with a "." and should mention its arguments. > Feel free to plagiarize set-frame-parameter. > - The comment for window_parameters refers to `pin' and `group'. > - See http://www.gnu.org/prep/standards/standards.html#Change-Logs for > the format to use in ChangeLogs: > - put together changes to a file. > - your changelog seems to say you've changed `DEFUN'. > - there's a missing space after colon in "(window:Added". > - And the "Added" should be "Add" of course. I will address your concerns shortly. I'm slowed down a bit because I havent got a pleasing SCM setup yet for working on different parts of the patch. I should probably have two bzr branches to work in, one for the basic winprop part, one for the pin/group feature. The Changelog entry was basically generated by the Emacs diff mode, I'll fix it. > > Thank you very much for your help. BTW, could you point me to your > latest version of the pin&group patch? > Please find it attached. Some notes: - Richard prefered some other wording than "pin" which I cant remember, but I will change that. - I lazily removed a caching of the full window list. I could presumably bring it back for the case when iterating all windows. Comments? - If I understood Klaus correctly It appears one might need some kind of "buffer group" concept when switching buffers inside a "window group". Should that be implemented in a similar way as window-properties, or at the elisp level? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=winpropp.diff === modified file 'src/window.c' --- src/window.c 2008-04-03 02:15:43 +0000 +++ src/window.c 2008-04-29 09:40:34 +0000 @@ -55,6 +55,8 @@ Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p; Lisp_Object Qscroll_up, Qscroll_down; +Lisp_Object Qpin; +Lisp_Object Qgroup; Lisp_Object Qwindow_size_fixed; extern Lisp_Object Qleft_margin, Qright_margin; @@ -82,7 +84,8 @@ Lisp_Object *)); static int foreach_window_1 P_ ((struct window *, int (* fn) (struct window *, void *), - void *)); + void *, + int)); static Lisp_Object window_list_1 P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); /* This is the window in which the terminal's cursor should @@ -275,6 +278,7 @@ p->frame = Qnil; p->display_table = Qnil; p->dedicated = Qnil; + p->window_parameters = Qnil; p->pseudo_window_p = 0; bzero (&p->cursor, sizeof (p->cursor)); bzero (&p->last_cursor, sizeof (p->last_cursor)); @@ -1082,7 +1086,7 @@ window = Qnil; cw.window = &window, cw.x = &x, cw.y = &y; cw.part = part; - foreach_window (f, check_window_containing, &cw); + foreach_window (f, check_window_containing, &cw, 1); /* If not found above, see if it's in the tool bar window, if a tool bar exists. */ @@ -1325,6 +1329,38 @@ return w->dedicated; } +DEFUN ("window-parameters", Fwindow_parameters, Swindow_parameters, + 1, 1, 0, + doc: /* Return WINDOW's window-parameters. + returns nil or an alist where values affect window operations. */) + (window) + Lisp_Object window; +{ + return decode_window (window)->window_parameters; +} + + +DEFUN ("set-window-parameter", Fset_window_parameter, + Sset_window_parameter, 3, 3, 0, + doc: /* set window parameters */) + (window, prop, val) + Lisp_Object window, prop, val; +{ + register struct window *w = decode_window (window); + register Lisp_Object old_alist_elt; + + old_alist_elt = Fassq (prop, w->window_parameters); + if (EQ (old_alist_elt, Qnil)) + w->window_parameters = Fcons (Fcons (prop, val), w->window_parameters); + else + Fsetcdr (old_alist_elt, val); + + //Fplist_put(w->window_parameters,key,value); + + return w->window_parameters; +} + + DEFUN ("window-display-table", Fwindow_display_table, Swindow_display_table, 0, 1, 0, doc: /* Return the display-table that WINDOW is using. @@ -1729,7 +1765,8 @@ static Lisp_Object window_list () { - if (!CONSP (Vwindow_list)) + //if(!CONSP (Vwindow_list)) + if (1) //never cache the window list for now FIXME { Lisp_Object tail; @@ -1742,7 +1779,7 @@ new windows at the front of args[1], which means we have to reverse this list at the end. */ args[1] = Qnil; - foreach_window (XFRAME (XCAR (tail)), add_window_to_list, &args[1]); + foreach_window (XFRAME (XCAR (tail)), add_window_to_list, &args[1], 0); args[0] = Vwindow_list; args[1] = Fnreverse (args[1]); Vwindow_list = Fnconc (2, args); @@ -2209,7 +2246,10 @@ break; case DELETE_OTHER_WINDOWS: - if (!EQ (window, obj)) + // + if ((!EQ (window, obj)) && //obj is not the current window + //current window doesnt have "pin" prop set + (NILP(Fassq (Qpin, w->window_parameters)))) Fdelete_window (window); break; @@ -7159,17 +7199,20 @@ /* Call FN for all leaf windows on frame F. FN is called with the first argument being a pointer to the leaf window, and with - additional argument USER_DATA. Stops when FN returns 0. */ + additional argument USER_DATA. Stops when FN returns 0. + ALLWINDOWS 1 means iterate every window, else only the group of the selected window +*/ void -foreach_window (f, fn, user_data) +foreach_window (f, fn, user_data, allwindows) struct frame *f; int (* fn) P_ ((struct window *, void *)); void *user_data; + int allwindows; { /* Fdelete_frame may set FRAME_ROOT_WINDOW (f) to Qnil. */ if (WINDOWP (FRAME_ROOT_WINDOW (f))) - foreach_window_1 (XWINDOW (FRAME_ROOT_WINDOW (f)), fn, user_data); + foreach_window_1 (XWINDOW (FRAME_ROOT_WINDOW (f)), fn, user_data,allwindows); } @@ -7179,22 +7222,29 @@ Stop when FN returns 0. Value is 0 if stopped by FN. */ static int -foreach_window_1 (w, fn, user_data) +foreach_window_1 (w, fn, user_data, allwindows) struct window *w; int (* fn) P_ ((struct window *, void *)); void *user_data; + int allwindows; { int cont; - + struct window *current_window=XWINDOW(selected_window); + register Lisp_Object group = Fcdr(Fassq(Qgroup, current_window->window_parameters)); + Lisp_Object group2; for (cont = 1; w && cont;) { if (!NILP (w->hchild)) - cont = foreach_window_1 (XWINDOW (w->hchild), fn, user_data); + cont = foreach_window_1 (XWINDOW (w->hchild), fn, user_data,allwindows); else if (!NILP (w->vchild)) - cont = foreach_window_1 (XWINDOW (w->vchild), fn, user_data); - else - cont = fn (w, user_data); - + cont = foreach_window_1 (XWINDOW (w->vchild), fn, user_data,allwindows); + else{ + //only call fn if the group of the frames selected window + //is the same as the group of the current window in the loop. + group2=Fcdr(Fassq(Qgroup,w->window_parameters)); + if (allwindows || EQ(group , group2 )) + cont = fn (w, user_data); + } w = NILP (w->next) ? 0 : XWINDOW (w->next); } @@ -7233,7 +7283,7 @@ struct frame *f; int freeze_p; { - foreach_window (f, freeze_window_start, (void *) (freeze_p ? f : 0)); + foreach_window (f, freeze_window_start, (void *) (freeze_p ? f : 0),1); } @@ -7398,6 +7448,13 @@ void syms_of_window () { + + Qpin = intern ("pin"); + Qgroup = intern ("group"); + + staticpro (&Qpin); + staticpro (&Qgroup); + Qscroll_up = intern ("scroll-up"); staticpro (&Qscroll_up); @@ -7714,6 +7771,9 @@ defsubr (&Sset_window_vscroll); defsubr (&Scompare_window_configurations); defsubr (&Swindow_list); + defsubr (&Swindow_parameters); + defsubr (&Sset_window_parameter); + } void === modified file 'src/window.h' --- src/window.h 2008-01-29 02:05:10 +0000 +++ src/window.h 2008-04-29 10:04:07 +0000 @@ -229,6 +229,11 @@ enlarged. */ Lisp_Object orig_total_lines, orig_top_line; + /* an alist with flags that modifies behaviour of certain window operations. + currently "pin" and "group" are special + */ + Lisp_Object window_parameters; + /* No Lisp data may follow below this point without changing mark_object in alloc.c. The member current_matrix must be the first non-Lisp member. */ @@ -786,7 +791,8 @@ extern void freeze_window_starts P_ ((struct frame *, int)); extern void foreach_window P_ ((struct frame *, int (* fn) (struct window *, void *), - void *)); + void *, + int allwindows)); extern void grow_mini_window P_ ((struct window *, int)); extern void shrink_mini_window P_ ((struct window *)); --=-=-= -- Joakim Verona --=-=-=--