unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* bug? the position of scroll-bar
@ 2003-09-17 11:48 Masatake YAMATO
  2003-09-21  0:02 ` Kim F. Storm
  0 siblings, 1 reply; 7+ messages in thread
From: Masatake YAMATO @ 2003-09-17 11:48 UTC (permalink / raw)


After evaluating (scroll-bar-mode) twice, 
both (nth 2 (window-scroll-bars)) and (frame-parameter nil 'vertical-scroll-bars)
return t. So I cannot know the position of scroll-bar(left or right). I think
this is a bug.

`ruler-mode-left-scroll-bar-cols' in ruler-mode.el expects either (nth
2 (window-scroll-bars)) or (frame-parameter nil 'vertical-scroll-bars)
returns 'left or 'right if scroll bar is displayed. 

emacs -q

(progn 
  (scroll-bar-mode)			; disable
  (scroll-bar-mode)			; enable
  (cons (nth 2 (window-scroll-bars))
  	(frame-parameter nil 'vertical-scroll-bars)))
=> (t . t)

Masatake YAMATO

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug? the position of scroll-bar
  2003-09-17 11:48 bug? the position of scroll-bar Masatake YAMATO
@ 2003-09-21  0:02 ` Kim F. Storm
  2003-09-21  5:51   ` Masatake YAMATO
  2003-09-21 22:34   ` Richard Stallman
  0 siblings, 2 replies; 7+ messages in thread
From: Kim F. Storm @ 2003-09-21  0:02 UTC (permalink / raw)
  Cc: emacs-devel

Masatake YAMATO <jet@gyve.org> writes:

> After evaluating (scroll-bar-mode) twice, 
> both (nth 2 (window-scroll-bars)) and (frame-parameter nil 'vertical-scroll-bars)
> return t. So I cannot know the position of scroll-bar(left or right). I think
> this is a bug.

A short-coming at least :-)   A value of t means to use the system default
setting.

In any case, I have installed a fix that should help you.

It adds a new built-in variable
        default-frame-scroll-bars
which reflects the default position on various window systems
(e.g. right on Windows, and left on X).

So if frame-parameter returns neither left, nor right, nor nil, you
can consult default-frame-scroll-bars to know what the actual setting
is.  

But I also modified M-x scroll-bar-mode to use this to pass on the
proper setting in case it toggles scroll-bars on (rather than pass the
value t), so normally you can now trust the value of frame-parameter
as specified below to return the actual setting.


Finally, I clarified the doc string of window-scroll-bars to explain
that the scroll-bar type may be 't' in which case the window uses the
frame's current setting.


Maybe we need to add helper functions like these to hide the somewhat
tricky relationship between windows, frames, and system defaults:

(defun frame-current-scroll-bars (&optional frame)
   (let ((type (frame-parameter frame 'vertical-scroll-bars)))
      (if (or (null type) (eq type 'left) (eq type 'right))
          type
        default-frame-scroll-bars)))

and

(defun window-current-scroll-bars (&optional window)
  (let ((type (nth 2 (window-scroll-bars window))))
    (if (eq type t)
        (frame-current-scroll-bars (window-frame (or window (selected-window))))
      type)))



> 
> `ruler-mode-left-scroll-bar-cols' in ruler-mode.el expects either (nth
> 2 (window-scroll-bars)) or (frame-parameter nil 'vertical-scroll-bars)
> returns 'left or 'right if scroll bar is displayed. 
> 
> emacs -q
> 
> (progn 
>   (scroll-bar-mode)			; disable
>   (scroll-bar-mode)			; enable
>   (cons (nth 2 (window-scroll-bars))
>   	(frame-parameter nil 'vertical-scroll-bars)))
> => (t . t)
> 
> Masatake YAMATO
> 
> 
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://mail.gnu.org/mailman/listinfo/emacs-devel
> 

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug? the position of scroll-bar
  2003-09-21  0:02 ` Kim F. Storm
@ 2003-09-21  5:51   ` Masatake YAMATO
  2003-09-22  7:56     ` Kim F. Storm
  2003-09-21 22:34   ` Richard Stallman
  1 sibling, 1 reply; 7+ messages in thread
From: Masatake YAMATO @ 2003-09-21  5:51 UTC (permalink / raw)
  Cc: emacs-devel

> > After evaluating (scroll-bar-mode) twice, 
> > both (nth 2 (window-scroll-bars)) and (frame-parameter nil 'vertical-scroll-bars)
> > return t. So I cannot know the position of scroll-bar(left or right). I think
> > this is a bug.
> 
> A short-coming at least :-)   A value of t means to use the system default
> setting.
> 
> In any case, I have installed a fix that should help you.

Thank you. I've tested your change and I'm almost satisfied with it.
But I have still one question.

(progn (set-window-scroll-bars (selected-window) 10 'hippopotamus)
       (window-scroll-bars (selected-window)))
=> (10 2 hippopotamus nil)

hippopotamus is accepted. But M-x set-window-scroll-bars shows:


    set-window-scroll-bars is a built-in function.
    (set-window-scroll-bars WINDOW WIDTH &optional VERTICAL-TYPE HORIZONTAL-TYPE)

    Set width and type of scroll bars of window WINDOW.
    If window is nil, set scroll bars of the currently selected window.
    Second parameter WIDTH specifies the pixel width for the scroll bar;
    this is automatically adjusted to a multiple of the frame column width.
    Third parameter VERTICAL-TYPE specifies the type of the vertical scroll
    bar: left, right, or nil.
    ^^^^^^^^^^^^^^^^^^^^^^^^^
    A width of nil and type of t means to use the frame's corresponding value.


Should set-window-scroll-bars return an error if hippopotamus is specified?

I've tried to add following code 

  if (!(EQ (vertical_type, Qnil)
	|| EQ (vertical_type, Qleft) 
	|| EQ (vertical_type, Qright)))
    error ("Invalid type of vertical scroll bar");

to DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars, Sset_window_scroll_bars,..
but this addition causes segmentation fault during make command running.

Masatake YAMATO

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug? the position of scroll-bar
  2003-09-21  0:02 ` Kim F. Storm
  2003-09-21  5:51   ` Masatake YAMATO
@ 2003-09-21 22:34   ` Richard Stallman
  1 sibling, 0 replies; 7+ messages in thread
From: Richard Stallman @ 2003-09-21 22:34 UTC (permalink / raw)
  Cc: jet, emacs-devel

    Maybe we need to add helper functions like these to hide the somewhat
    tricky relationship between windows, frames, and system defaults:

    (defun frame-current-scroll-bars (&optional frame)
       (let ((type (frame-parameter frame 'vertical-scroll-bars)))
	  (if (or (null type) (eq type 'left) (eq type 'right))
	      type
	    default-frame-scroll-bars)))

    and

    (defun window-current-scroll-bars (&optional window)
      (let ((type (nth 2 (window-scroll-bars window))))
	(if (eq type t)
	    (frame-current-scroll-bars (window-frame (or window (selected-window))))
	  type)))


That is a good idea.  Please add them.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug? the position of scroll-bar
  2003-09-21  5:51   ` Masatake YAMATO
@ 2003-09-22  7:56     ` Kim F. Storm
  2003-09-22  9:22       ` Masatake YAMATO
  0 siblings, 1 reply; 7+ messages in thread
From: Kim F. Storm @ 2003-09-22  7:56 UTC (permalink / raw)
  Cc: emacs-devel

Masatake YAMATO <jet@gyve.org> writes:

> (progn (set-window-scroll-bars (selected-window) 10 'hippopotamus)
>        (window-scroll-bars (selected-window)))
> => (10 2 hippopotamus nil)
> 
> hippopotamus is accepted. 

It shouldn't, so your fix is ok (read on)...

>     set-window-scroll-bars is a built-in function.
>     (set-window-scroll-bars WINDOW WIDTH &optional VERTICAL-TYPE HORIZONTAL-TYPE)
> 
>     Set width and type of scroll bars of window WINDOW.
>     If window is nil, set scroll bars of the currently selected window.
>     Second parameter WIDTH specifies the pixel width for the scroll bar;
>     this is automatically adjusted to a multiple of the frame column width.
>     Third parameter VERTICAL-TYPE specifies the type of the vertical scroll
>     bar: left, right, or nil.
>     ^^^^^^^^^^^^^^^^^^^^^^^^^
>     A width of nil and type of t means to use the frame's corresponding value.
                         ^^^^^^^^^

You need to allow Qt as well:

> I've tried to add following code 
> 
>   if (!(EQ (vertical_type, Qnil)

Add:
        || EQ (vertical_type, Qt)



-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug? the position of scroll-bar
  2003-09-22  7:56     ` Kim F. Storm
@ 2003-09-22  9:22       ` Masatake YAMATO
  2003-09-22 12:23         ` Kim F. Storm
  0 siblings, 1 reply; 7+ messages in thread
From: Masatake YAMATO @ 2003-09-22  9:22 UTC (permalink / raw)
  Cc: emacs-devel

> > (progn (set-window-scroll-bars (selected-window) 10 'hippopotamus)
> >        (window-scroll-bars (selected-window)))
> > => (10 2 hippopotamus nil)
> > 
> > hippopotamus is accepted. 
> 
> It shouldn't, so your fix is ok (read on)...
> 
> >     set-window-scroll-bars is a built-in function.
> >     (set-window-scroll-bars WINDOW WIDTH &optional VERTICAL-TYPE HORIZONTAL-TYPE)
> > 
> >     Set width and type of scroll bars of window WINDOW.
> >     If window is nil, set scroll bars of the currently selected window.
> >     Second parameter WIDTH specifies the pixel width for the scroll bar;
> >     this is automatically adjusted to a multiple of the frame column width.
> >     Third parameter VERTICAL-TYPE specifies the type of the vertical scroll
> >     bar: left, right, or nil.
> >     ^^^^^^^^^^^^^^^^^^^^^^^^^
> >     A width of nil and type of t means to use the frame's corresponding value.
>                          ^^^^^^^^^
> 
> You need to allow Qt as well:

Thank you. I've validated more strictly.
How about this one?

2003-09-22  Masatake YAMATO  <jet@gyve.org>

	* window.c (Fset_window_scroll_bars): Validate the value of 
	`vertical_type'.

Index: src/window.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/window.c,v
retrieving revision 1.447
diff -u -r1.447 window.c
--- src/window.c	20 Sep 2003 23:38:54 -0000	1.447
+++ src/window.c	22 Sep 2003 09:18:19 -0000
@@ -5873,6 +5873,12 @@
   if (XINT (width) == 0)
     vertical_type = Qnil;
 
+  if (!(EQ (vertical_type, Qnil)
+	|| EQ (vertical_type, Qleft) 
+	|| EQ (vertical_type, Qright)
+	|| (EQ (vertical_type, Qt) && NILP (width))))
+    error ("Invalid type of vertical scroll bar");
+
   if (!EQ (w->scroll_bar_width, width)
       || !EQ (w->vertical_scroll_bar_type, vertical_type))
     {

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug? the position of scroll-bar
  2003-09-22  9:22       ` Masatake YAMATO
@ 2003-09-22 12:23         ` Kim F. Storm
  0 siblings, 0 replies; 7+ messages in thread
From: Kim F. Storm @ 2003-09-22 12:23 UTC (permalink / raw)
  Cc: emacs-devel

Masatake YAMATO <jet@gyve.org> writes:

> > >     A width of nil and type of t means to use the frame's corresponding value.

> Thank you. I've validated more strictly.

That's too much now :-)

The doc string is unclear.  What it's supposed to say is:

If WIDTH is nil, use the frame's scroll-bar width.
If TYPE is t, use the frame's scroll-bar type.


So just allow type = t with no check on width...
And fix the doc string :-)



> How about this one?
> 
> 2003-09-22  Masatake YAMATO  <jet@gyve.org>
> 
> 	* window.c (Fset_window_scroll_bars): Validate the value of 
> 	`vertical_type'.
> 
> Index: src/window.c
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/src/window.c,v
> retrieving revision 1.447
> diff -u -r1.447 window.c
> --- src/window.c	20 Sep 2003 23:38:54 -0000	1.447
> +++ src/window.c	22 Sep 2003 09:18:19 -0000
> @@ -5873,6 +5873,12 @@
>    if (XINT (width) == 0)
>      vertical_type = Qnil;
>  
> +  if (!(EQ (vertical_type, Qnil)
> +	|| EQ (vertical_type, Qleft) 
> +	|| EQ (vertical_type, Qright)
> +	|| (EQ (vertical_type, Qt) && NILP (width))))
> +    error ("Invalid type of vertical scroll bar");
> +
>    if (!EQ (w->scroll_bar_width, width)
>        || !EQ (w->vertical_scroll_bar_type, vertical_type))
>      {
> 
> 

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-09-22 12:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-17 11:48 bug? the position of scroll-bar Masatake YAMATO
2003-09-21  0:02 ` Kim F. Storm
2003-09-21  5:51   ` Masatake YAMATO
2003-09-22  7:56     ` Kim F. Storm
2003-09-22  9:22       ` Masatake YAMATO
2003-09-22 12:23         ` Kim F. Storm
2003-09-21 22:34   ` Richard Stallman

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).