Re: v3 window splitting: problem

2012-01-01 Thread Roland Winkler
On Sat Dec 31 2011 Sam Steingold wrote:
  * Roland Winkler jvax...@tah.bet [2011-12-31 07:50:14 -0600]:
 That specific patch was trying to address the problem where the
 *BBDB* window was exactly the same size as the *Article* window,
 i.e., it would split the tallest window in half and take of the
 halves.

The *BBDB* window was exactly the same size as the *Article* window
before or after the splitting? Are you using multiple *BBDB*
windows? Is the *Article* window the window you want to split or do
you want to split a different window?

  The arg horiz-p is really used only by the function
  bbdb-mua-auto-update.
 
 And this is the problem.  This means that my bbdb-message-pop-up setting
 is only respected by bbdb-mua-auto-update, which is wrong.
 if you do not want to drop horiz-p altogether, please use my tallest
 window approach when horiz-p is nil.

It was the basic idea in BBDB v2 that horizontal window splitting
was used only for MUA windows (using mua-specific versions of the
command bbdb-mua-auto-update). The old behavior appeared reasonable
to me and I don't think I changed concepts here for BBDB v3 (though
details are different). As you come from BBDB v2 I have been trying
to understand this better.

  Under what circumstances does it not fit your needs and you want to
  call the command bbdb-display-records instead?
 
 Every now and then the *BBDB* window is created by a vertical split
 instead of a horizontal one despite bbdb-message-pop-up == horiz.

This every now and then has been what I was hoping to understand.
Before the code gets changed, it would help to know more
specifically which issue(s) a change is supposed to address.

Oh well. I'll look at the code to see whether it can make sense to
implement something like a value 'horiz-force for bbdb-message-pop-up.
Yet right now, I do not want to promise anything.

 Happy new year!

Happy new year to everyone reading this!

Roland

--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Re: v3 window splitting: problem

2012-01-01 Thread Sam Steingold
 * Roland Winkler jvax...@tah.bet [2012-01-01 02:15:53 -0600]:

 On Sat Dec 31 2011 Sam Steingold wrote:
  * Roland Winkler jvax...@tah.bet [2011-12-31 07:50:14 -0600]:
 That specific patch was trying to address the problem where the
 *BBDB* window was exactly the same size as the *Article* window,
 i.e., it would split the tallest window in half and take of the
 halves.

 The *BBDB* window was exactly the same size as the *Article* window
 before or after the splitting?

before: 2 windows: *Summary* (list of articles in the group) - about
20% of the frame and *Article* (the content of the current message) -
about 80% of the frame.
when I visit the article written by someone in the db, the *Article*
window is split into two windows: *Article* and *BBDB*.
v2 split it into 5 lines for *BBDB* and the rest for *Article*.
v3 split it into 1/2 (i.e., 40% of the frame) for *BBDB* and 1/2 (i.e.,
40% of the frame) for *Article*.
I want the *BBDB* window to be as small as possible so that the frame
real estate is not wasted.

 Are you using multiple *BBDB* windows?

no.

 Is the *Article* window the window you want to split or do you want to
 split a different window?

I do want *Article* to be split.

  The arg horiz-p is really used only by the function
  bbdb-mua-auto-update.
 
 And this is the problem.  This means that my bbdb-message-pop-up setting
 is only respected by bbdb-mua-auto-update, which is wrong.
 if you do not want to drop horiz-p altogether, please use my tallest
 window approach when horiz-p is nil.

 It was the basic idea in BBDB v2 that horizontal window splitting was
 used only for MUA windows (using mua-specific versions of the command
 bbdb-mua-auto-update). The old behavior appeared reasonable to me and

agreed.

 I don't think I changed concepts here for BBDB v3 (though details are
 different). As you come from BBDB v2 I have been trying to understand
 this better.

I did not use horizontal window splitting in v2.
It might well be that the bug was already there.

Whatever the original design was, I did _not_ get the horizontal split
reliably with the original code.


-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://ffii.org http://dhimmi.com http://www.memritv.org
http://pmw.org.il http://iris.org.il http://openvotingconsortium.org
The Truth does not have to look plausible.


--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Re: v3 window splitting: problem

2011-12-31 Thread Sam Steingold
 * Roland Winkler jvax...@tah.bet [2011-12-31 07:50:14 -0600]:

 On Fri Dec 30 2011 Sam Steingold wrote:
 In that case you might appreciate my shrink-window-if-larger-than-buffer
 patch: v2 created a fixed height *BBDB* window, v3 creates a *BBDB*
 window half the height of the tallest one.  Did you see the
 e-mail?

 I saw your email. I am simply trying to understand better what kind
 of issue (occuring in which context) you want to address.

That specific patch was trying to address the problem where the *BBDB*
window was exactly the same size as the *Article* window, i.e., it would
split the tallest window in half and take of the halves.

 Because the horiz-p argument is not always passed, which means that the
 my (bbdb-message-pop-up 'horiz) setting is ignored unless *BBDB* window
 is popped from a very specific place (which it is not always is).
 
 Also, a function which takes 6 (optional!) arguments is brittle by
 design.

 Are you talking about bbdb-display-records? When are you using it?

I don't think I am ever calling it directly.

 All its args are optional. You must insist on some kind of
 non-default behavior when you use its optional args.

My problem with 6 positional arguments is that they are very easy to get
wrong: you have to count them carefully when using, say, the fifth.

 The arg horiz-p is really used only by the function
 bbdb-mua-auto-update.

And this is the problem.  This means that my bbdb-message-pop-up setting
is only respected by bbdb-mua-auto-update, which is wrong.
if you do not want to drop horiz-p altogether, please use my tallest
window approach when horiz-p is nil.

 Under what circumstances does it not fit your needs and you want to
 call the command bbdb-display-records instead?

Every now and then the *BBDB* window is created by a vertical split
instead of a horizontal one despite bbdb-message-pop-up == horiz.


Happy new year!

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://palestinefacts.org http://www.PetitionOnline.com/tap12009/
http://mideasttruth.com http://honestreporting.com http://www.memritv.org
Good judgment comes from experience and experience comes from bad judgment.

--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Re: v3 window splitting: problem

2011-12-30 Thread Roland Winkler
On Thu Dec 29 2011 Sam Steingold wrote:
 here is the complete patch:
 basically, I sacrifice the failed attempt to only split the mua windows
 for the sake of robustness.

The current concept was really taken from BBDB v2. I am not using
it. In that sense, I do not have strong feelings / much personal
experience. Yet I want to understand what happens.

In what sense is it more robust if BBDB splits a window that is
the tallest window, but possibly completely unrelated with BBDB? Why
is it not working for you if BBDB tries to select a window that is
displaying something related to BBDB (in addition to the criterion
that the window should be as tall as possible)?

Roland

--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Re: v3 window splitting: problem

2011-12-30 Thread Sam Steingold
 * Roland Winkler jvax...@tah.bet [2011-12-30 02:23:37 -0600]:

 On Thu Dec 29 2011 Sam Steingold wrote:
 here is the complete patch:
 basically, I sacrifice the failed attempt to only split the mua windows
 for the sake of robustness.

 The current concept was really taken from BBDB v2. I am not using
 it. In that sense, I do not have strong feelings / much personal
 experience.

In that case you might appreciate my shrink-window-if-larger-than-buffer
patch: v2 created a fixed height *BBDB* window, v3 creates a *BBDB*
window half the height of the tallest one.  Did you see the e-mail?

 In what sense is it more robust if BBDB splits a window that is the
 tallest window, but possibly completely unrelated with BBDB? Why is it
 not working for you if BBDB tries to select a window that is
 displaying something related to BBDB (in addition to the criterion
 that the window should be as tall as possible)?

Because the horiz-p argument is not always passed, which means that the
my (bbdb-message-pop-up 'horiz) setting is ignored unless *BBDB* window
is popped from a very specific place (which it is not always is).

Also, a function which takes 6 (optional!) arguments is brittle by design.


-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://dhimmi.com http://truepeace.org http://www.PetitionOnline.com/tap12009/
http://palestinefacts.org http://iris.org.il http://pmw.org.il
If you have no enemies, you are probably dead.


--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Re: v3 window splitting: problem

2011-12-29 Thread Roland Winkler
On Wed Dec 28 2011 Sam Steingold wrote:
  * Sam Steingold f...@tah.bet [2011-12-28 12:44:25 -0500]:
 
  When I use the tall display, the *BBDB* window is vertical
  (i.e., it is split sideways, which is precisely what I want)
  When I use the wide display, the *BBDB* window is horizontal
  (i.e., it is split on the bottom top of another windows,
  which is _NOT_ what I want).
 
 I still have the problem, but now it's the other way around: wide
 display is split according to bbdb-message-pop-up == horiz and the tall
 display ignores is.
 The only difference I see is that after I restarted emacs, the first
 frame is tall and the second is wide.
 I.e., it appears that bbdb-message-pop-up is ignored in the first frame.
 
 Still confused...

Have you looked at bbdb-horiz-pop-up-window-size?

The new code for horizontal window splitting should give you the
same behavior as the old code, except for hard-coded numbers being
replaced by the user variable bbdb-horiz-pop-up-window-size.

Yet part of the problem might be that different people might have
different expectations what they consider meaningful and appropriate
here. If you have some ideas how to improve the code for everybody,
they will be appreciated.

Roland

--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Re: v3 window splitting: problem

2011-12-29 Thread Sam Steingold
 * Roland Winkler jvax...@tah.bet [2011-12-29 04:31:47 -0600]:

 On Wed Dec 28 2011 Sam Steingold wrote:
  * Sam Steingold f...@tah.bet [2011-12-28 12:44:25 -0500]:
 
  When I use the tall display, the *BBDB* window is vertical
  (i.e., it is split sideways, which is precisely what I want)
  When I use the wide display, the *BBDB* window is horizontal
  (i.e., it is split on the bottom top of another windows,
  which is _NOT_ what I want).
 
 I still have the problem, but now it's the other way around: wide
 display is split according to bbdb-message-pop-up == horiz and the tall
 display ignores is.
 The only difference I see is that after I restarted emacs, the first
 frame is tall and the second is wide.
 I.e., it appears that bbdb-message-pop-up is ignored in the first frame.

nope, it is now appears to be completely unpredictable...

 Have you looked at bbdb-horiz-pop-up-window-size?

yes, it looks fine.
all my frames are big enough to be split horizontally.

 The new code for horizontal window splitting should give you the
 same behavior as the old code, except for hard-coded numbers being
 replaced by the user variable bbdb-horiz-pop-up-window-size.

I did not use the old code.

 Yet part of the problem might be that different people might have
 different expectations what they consider meaningful and appropriate
 here. If you have some ideas how to improve the code for everybody,
 they will be appreciated.

Okay, here is the patch.
It makes bbdb-pop-up-window IGNORE the horiz-p argument which I do not
understand and it makes it split horizontally the tallest window.
It seems to force the horizontal behavior when I want it.

diff --git a/lisp/bbdb.el b/lisp/bbdb.el
index 87f6c9f..4dc6a08 100644
--- a/lisp/bbdb.el
+++ b/lisp/bbdb.el
@@ -2982,6 +2982,13 @@ The *BBDB* buffer must be current when this is called.
 
 
 
+(defun bbdb-tallest-window ()
+  Find the tallest window.
+  (let ((tallest-window (selected-window)))
+(dolist (window (window-list) tallest-window)
+  (when ( (window-height window) (window-height tallest-window))
+(setq tallest-window window)
+
 ;;; window configuration hackery
 (defun bbdb-pop-up-window (optional select horiz-p)
   Find the largest window on the screen, and split it, displaying the
@@ -2997,25 +3004,21 @@ will be split vertically rather than horizontally.
 
 ;; try horizontal split
 ((and (eq bbdb-message-pop-up 'horiz)
-  horiz-p
   (= (frame-width) (car bbdb-horiz-pop-up-window-size))
   (let ((cbuffer (current-buffer))
-(window-list (window-list))
 (selected-window (selected-window))
 (b-width (cdr bbdb-horiz-pop-up-window-size))
-(search t) window)
-(while (and (setq window (pop window-list))
-(setq search (funcall horiz-p window
-(unless (or search (= (window-width window)
-   (car bbdb-horiz-pop-up-window-size)))
-  (select-window window)
+(tallest-window (bbdb-tallest-window)))
+(when ( (window-width tallest-window)
+ (car bbdb-horiz-pop-up-window-size))
+  (select-window tallest-window)
   (condition-case nil ; `split-window-horizontally' might fail
   (progn
 (split-window-horizontally
  (if (integerp b-width)
- (- (window-width window) b-width)
-   (round (* (- 1 b-width) (window-width window)
-(select-window (next-window window))
+ (- (window-width tallest-window) b-width)
+   (round (* (- 1 b-width) (window-width 
tallest-window)
+(select-window (next-window tallest-window))
 (let (pop-up-windows)
   (switch-to-buffer (get-buffer-create 
bbdb-buffer-name)))
 (unless select
@@ -3027,11 +3030,7 @@ will be split vertically rather than horizontally.
 (t ;; vertical split
  (let* ((cbuffer (current-buffer))
 (selected-window (selected-window))
-(tallest-window selected-window))
-   ;; find the tallest window...
-   (dolist (window (window-list))
- (if ( (window-height window) (window-height tallest-window))
- (setq tallest-window window)))
+(tallest-window (bbdb-tallest-window)))
(select-window tallest-window)   ; select it and split it...
(if (eql bbdb-pop-up-window-size 1.0)
;; select `bbdb-buffer-name'



-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://mideasttruth.com http://iris.org.il http://memri.org

Re: v3 window splitting: problem

2011-12-29 Thread Sam Steingold
here is the complete patch:
basically, I sacrifice the failed attempt to only split the mua windows
for the sake of robustness.

diff --git a/ChangeLog b/ChangeLog
index 6bbbe47..29b211c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-12-29  Sam Steingold  s...@gnu.org
+   * lisp/bbdb.el (bbdb-display-records)
+   (bbdb-display-records-internal): Do not accept horiz-p.
+   (bbdb-tallest-window): Extract from `bbdb-pop-up-window'.
+   (bbdb-pop-up-window): Do not accept horiz-p; always split the
+   tallest window when possible, whether horizontally or vertically.
+   * lisp/bbdb-mua.el (bbdb-mua-auto-update):
+   Do not pass horiz-p to `bbdb-display-records-internal'.
+
 2011-12-28  Sam Steingold  s...@gnu.org
* lisp/bbdb.el (bbdb-pop-up-window):
Shrink the vertical *BBDB* window when possible.
diff --git a/lisp/bbdb-mua.el b/lisp/bbdb-mua.el
index e0059a1..2f93b6f 100644
--- a/lisp/bbdb-mua.el
+++ b/lisp/bbdb-mua.el
@@ -786,22 +786,11 @@ See `bbdb-mua-display-records' and friends for 
interactive commands.
  (records (bbdb-mua-update-records header-class
(or update-p
bbdb-mua-auto-update-p
-(if bbdb-message-pop-up
-(let* ((mua (bbdb-mua))
-   (mode (cond ((eq mua 'vm) 'vm-mode)
-   ((eq mua 'gnus) 'gnus-article-mode)
-   ((eq mua 'rmail) 'rmail-mode)
-   ((eq mua 'mh) 'mh-folder-mode)
-   ((eq mua 'message) 'message-mode)
-   ((eq mua 'mail) 'mail-mode
-  (if records
-  (bbdb-display-records-internal
-   records nil nil nil
-   `(lambda (window)
-  (with-current-buffer (window-buffer window)
-(eq major-mode ',mode
-;; If there are no records, empty the BBDB window.
-(bbdb-undisplay-records
+(when bbdb-message-pop-up
+  (if records
+  (bbdb-display-records-internal records)
+;; If there are no records, empty the BBDB window.
+(bbdb-undisplay-records)))
 records))
 
 ;; Should the following be replaced by a minor mode??
diff --git a/lisp/bbdb.el b/lisp/bbdb.el
index 87f6c9f..ab6ace2 100644
--- a/lisp/bbdb.el
+++ b/lisp/bbdb.el
@@ -2801,7 +2801,7 @@ Move point to the end of the inserted record.
   (put-text-property beg (point) 'bbdb-record-number number
 
 (defun bbdb-display-records (optional records layout append
-   select horiz-p electric-p)
+   select electric-p)
   Display RECORDS using LAYOUT.
   (interactive (list (bbdb-completing-read-records Display records: )
  (bbdb-layout-prefix)))
@@ -2812,14 +2812,13 @@ Move point to the end of the inserted record.
 (progn
   (define-key bbdb-mode-map   'bbdb-electric-done)
   (bbdb-electric-display-records records))
-  (bbdb-display-records-internal records layout append select horiz-p)
+  (bbdb-display-records-internal records layout append select)
   ;; do not smash keybinding if they invoked `bbdb-display'
   ;; from inside an electric loop.
   (unless bbdb-inside-electric-display
 (define-key bbdb-mode-map   'undefined)
 
-(defun bbdb-display-records-internal (records optional layout append
-  select horiz-p)
+(defun bbdb-display-records-internal (records optional layout append select)
   Low-level function overlooking the setup of the *BBDB* buffer.
   (if (bbdb-append-display-p) (setq append t))
 
@@ -2852,7 +2851,7 @@ Move point to the end of the inserted record.
 (set (make-local-variable 'bbdb-buffer-name) new-name)
 
 (unless (get-buffer-window bbdb-buffer-name)
-  (bbdb-pop-up-window select horiz-p))
+  (bbdb-pop-up-window select))
 (set-buffer bbdb-buffer-name) ;; *BBDB*
 
 ;; If we're appending RECORDS to the ones already displayed,
@@ -2982,40 +2981,43 @@ The *BBDB* buffer must be current when this is called.
 
 
 
+(defun bbdb-tallest-window ()
+  Find the tallest window.
+  (let ((tallest-window (selected-window)))
+(dolist (window (window-list) tallest-window)
+  (when ( (window-height window) (window-height tallest-window))
+(setq tallest-window window)
+
 ;;; window configuration hackery
-(defun bbdb-pop-up-window (optional select horiz-p)
+(defun bbdb-pop-up-window (optional select)
   Find the largest window on the screen, and split it, displaying the
 *BBDB* buffer in the bottom `bbdb-pop-up-window-size' lines (unless
 the *BBDB* buffer is already visible, in which case do nothing.)
 Select this window if SELECT is non-nil.
 
-If `bbdb-message-pop-up' is 'horiz, and the first window matching
-HORIZ-P is sufficiently wide ( 112 

v3 window splitting: problem

2011-12-28 Thread Sam Steingold
Hi,
I have the following problem:
I want the *BBDB* window to be split horizontally, so I set
bbdb-message-pop-up to 'horiz.
Alas, sometimes is works, sometimes it does not.
Specifically, I have two displays:
wide (X: 1366x768, Emacs frame: 221x54)
tall (X: 1200x1920, Emacs frame: 193x143)
When I use the tall display, the *BBDB* window is vertical
(i.e., it is split sideways, which is precisely what I want)
When I use the wide display, the *BBDB* window is horizontal
(i.e., it is split on the bottom top of another windows,
which is _NOT_ what I want).

I can't seem to be able to debug this; the horiz-p argument to
bbdb-pop-up-window is very confusing.

Can someone enlighten me?

PS. Also, I think having more control over the horiz splitting would be
nice.  right now the current (*Summary* in gnus) window is split; I
think two other options: split the tallest window and split _all_
windows would be nice too.  WDYT?


-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://jihadwatch.org http://pmw.org.il http://www.memritv.org
http://memri.org http://mideasttruth.com http://dhimmi.com http://camera.org
Unix roulette: `dd if=/dev/urandom of=/dev/kmem bs=1 count=1 seek=$RANDOM`


--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/