unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: joakim@verona.se
To: emacs-devel@gnu.org
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	"Richard M. Stallman" <rms@gnu.org>,
	klaus.berndl@sdm.de
Subject: Re: patch for optional inhibit of delete-other-windows(IDE feature)
Date: Tue, 29 Apr 2008 13:05:48 +0200	[thread overview]
Message-ID: <m3od7svs37.fsf@verona.se> (raw)
In-Reply-To: <m3fxt9a7h8.fsf@verona.se> (joakim@verona.se's message of "Sat, 26 Apr 2008 00:35:15 +0200")

[-- Attachment #1: Type: text/plain, Size: 800 bytes --]

Heres a new version of the patch. New stuff:

- The interface is now an alist tied to the window.
I think Stefan prefered this.

acessors:
set-window-parameter
window-parameter

- set "pin" to t, and the window will not go away on delete-other-winows
- set "group" to something, and all windows with the same value will be
considered in the same window group, which affects other-window for
instance.

- I also have some hackish elisp code to show how the interface works.

This is all only lightly tested, but looks IMHO promising.

Issues:

- I didn't adress Klaus concern with switch-to-buffer yet, I'm not sure how
to proceed there.

- I broke an optimization, marked as FIXME in windows.c. It doesnt look
  especially important so I wont not spend time on it until everything
  works properly.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bzr.diff --]
[-- Type: text/x-patch, Size: 7131 bytes --]

=== 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 @@
 \f
 /* 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);
 }
 
 \f
@@ -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 *));
 


[-- Attachment #3: pin-group-demo.el --]
[-- Type: application/emacs-lisp, Size: 1840 bytes --]

[-- Attachment #4: Type: text/plain, Size: 20 bytes --]



-- 
Joakim Verona

  parent reply	other threads:[~2008-04-29 11:05 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-25 22:35 patch for optional inhibit of delete-other-windows(IDE feature) joakim
2008-04-26  1:25 ` Stefan Monnier
2008-04-26  6:56   ` joakim
2008-04-28  1:20     ` Stefan Monnier
2008-04-28 11:26       ` joakim
2008-04-28 11:41         ` Miles Bader
2008-04-28 11:55           ` joakim
2008-04-28 18:26           ` Re[2]: " Eric M. Ludlam
2008-04-28 14:27         ` Stefan Monnier
2008-04-28 14:38           ` joakim
2008-04-28 15:04             ` klaus.berndl
2008-04-28 12:56     ` Jason Rumney
2008-04-30  8:09       ` klaus.berndl
2008-05-08 10:06   ` joakim
2008-05-08 14:03     ` Stefan Monnier
2008-04-26 14:49 ` Richard M Stallman
2008-04-28  1:21   ` Stefan Monnier
2008-04-29 11:05 ` joakim [this message]
2008-04-29 12:13   ` klaus.berndl
2008-04-29 13:31     ` martin rudalics
2008-04-29 13:47       ` klaus.berndl
2008-04-29 15:47         ` martin rudalics
2008-04-29 18:29           ` klaus.berndl
2008-04-29 20:31       ` Stefan Monnier
2008-04-29 23:16       ` Richard M Stallman
2008-04-29 23:16   ` Richard M Stallman
2008-04-30  5:57     ` joakim
2008-04-30  7:24       ` Stefan Monnier
2008-04-30  8:15         ` joakim
2008-04-30  9:34           ` Stefan Monnier
2008-04-30 10:47             ` klaus.berndl
2008-04-30 22:01           ` Richard M Stallman
2008-04-30 22:01       ` Richard M Stallman
2008-05-01  2:57         ` Miles Bader
2008-05-01 23:44           ` Richard M Stallman
     [not found] <m37iela60f.fsf@verona.se>
     [not found] ` <84D8FEFE8D23E94E9C2A6F0C58EE07E3429A02@mucmail3.sdm.de>
2008-04-28 11:14   ` joakim
2008-04-28 11:50     ` klaus.berndl
2008-04-28 15:34       ` martin rudalics
2008-04-28 15:55         ` klaus.berndl
2008-04-28 15:58           ` klaus.berndl
2008-04-28 22:01           ` martin rudalics
2008-04-29  8:46             ` klaus.berndl
2008-04-29 13:30               ` martin rudalics
2008-04-29 14:27                 ` klaus.berndl
2008-04-29 15:47                   ` martin rudalics
2008-04-29 16:35             ` Richard M Stallman
2008-04-29 18:04               ` Re[2]: " Eric M. Ludlam
2008-04-29 18:27                 ` klaus.berndl
2008-04-29 19:04                   ` Eric M. Ludlam
2008-04-29 20:35                   ` Stefan Monnier
2008-04-29 21:28                     ` martin rudalics
2008-04-29 21:27                 ` martin rudalics
2008-04-29 23:08                   ` Eric M. Ludlam
2008-04-30  5:37                     ` martin rudalics
2008-04-30 11:55                       ` Re[2]: " Eric M. Ludlam
2008-04-30 13:43                         ` martin rudalics
2008-04-30 15:29                           ` Eric M. Ludlam
2008-04-30 15:38                         ` Robert J. Chassell
2008-04-29 21:27               ` martin rudalics
2008-04-30  3:26                 ` Stefan Monnier
2008-04-28 19:45     ` Richard M Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3od7svs37.fsf@verona.se \
    --to=joakim@verona.se \
    --cc=emacs-devel@gnu.org \
    --cc=klaus.berndl@sdm.de \
    --cc=monnier@iro.umontreal.ca \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).