GNU bug report logs - #16475
24.3.50; enhancement request: remove vertical scroll bar automatically when not needed

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Fri, 17 Jan 2014 04:43:01 UTC

Severity: wishlist

Found in version 24.3.50

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; enhancement request: remove vertical scroll bar
 automatically when not needed
Date: Thu, 16 Jan 2014 20:42:17 -0800 (PST)
This was either reported as a bug/enhancement request long ago, or
else it was discussed in emacs-devel long ago.  I don't recall.

I seem to remember, though, that the answer was that this couldn't be
done, at least on MS Windows.  I don't recall the particulars, so
forgive me if I misunderstood or don't remember right.

Anyway, while fiddling a bit, in response to this request on
StackOverflow:
http://stackoverflow.com/questions/21175099/how-to-automatically-add-remove-scroll-bars-on-the-fly

I found something that seems to work OK.  I do not claim that this is a
good way to implement the feature - at all!  But it perhaps shows that
something could maybe be done for this.

I repeat here what I tried, but again, I am not proposing that a
solution would be along these lines.  Just asking that you maybe think a
bit more about whether it is feasible to come up with a satisfactory
solution.

One thing I notice is that if you shrink the text by scaling it that
does not seem to be taken into account by the code I tried: even if all
of the text is easily displayed in the window (because it is small), the
scroll bar does not seem to disappear.

Anyway, this is the code I tried, which seems to "work":

(setq-default
 mode-line-position
 '(:eval
   (progn
     (if (> (count-lines (point-min) (point-max)) (window-height))
	 (set-window-scroll-bars nil 20 t)
       (set-window-scroll-bars nil 1 t)) ; IF TRY ZERO, GET BUG #16474
     `((-3 ,(propertize
	     "%p"
	     'local-map mode-line-column-line-number-mode-map
	     'mouse-face 'mode-line-highlight
	     'help-echo "Buffer position, mouse-1: Line/col menu"))
       (line-number-mode
	((column-number-mode
	  (10 ,(propertize
		" (%l,%c)"
		'face (and (> (current-column)
			      modelinepos-column-limit)
			   'modelinepos-column-warning)
		'local-map mode-line-column-line-number-mode-map
		'mouse-face 'mode-line-highlight
		'help-echo "Line and column, mouse-1: Line/col menu"))
	  (6 ,(propertize
	       " L%l"
	       'local-map mode-line-column-line-number-mode-map
	       'mouse-face 'mode-line-highlight
	       'help-echo "Line number, mouse-1: Line/col menu"))))
	((column-number-mode
	  (5 ,(propertize
	       " C%c"
	       'face (and (> (current-column)
			     modelinepos-column-limit)
			  'modelinepos-column-warning)
	       'local-map mode-line-column-line-number-mode-map
	       'mouse-face 'mode-line-highlight
	       'help-echo "Column number, mouse-1: Line/col menu")))))))))

[BTW, another thing I noticed, after scaling the text smaller in a
buffer that was shown in two windows of the same frame, one above
the other: After evaluating the above code, the mode lines disappeared
temporarily.  I grabbed the area that should have been the mode line of
the top window and dragged it up a bit, and the mode lines showed up
again.  Seems like some redisplay was not happening immediately or
something.]


In GNU Emacs 24.3.50.1 (i686-pc-mingw32)
 of 2014-01-07 on ODIEONE
Bzr revision: 115916 bzg <at> gnu.org-20140107233629-du2solx6tmxnx0np
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/Devel/emacs/binary --enable-checking=yes,glyphs
 'CFLAGS=-O0 -g3' LDFLAGS=-Lc:/Devel/emacs/lib
 CPPFLAGS=-Ic:/Devel/emacs/include'




This bug report was last modified 7 years and 231 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.