unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16475: 24.3.50; enhancement request: remove vertical scroll bar automatically when not needed
@ 2014-01-17  4:42 Drew Adams
  2014-01-17 14:35 ` Stefan Monnier
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Drew Adams @ 2014-01-17  4:42 UTC (permalink / raw)
  To: 16475

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@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'





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

end of thread, other threads:[~2017-10-27  8:26 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-17  4:42 bug#16475: 24.3.50; enhancement request: remove vertical scroll bar automatically when not needed Drew Adams
2014-01-17 14:35 ` Stefan Monnier
2016-02-12  2:46 ` Keith David Bershatsky
2017-10-25  5:27 ` bug#16475: " Keith David Bershatsky
2017-10-25  7:47   ` martin rudalics
2017-10-25 14:40     ` Eli Zaretskii
2017-10-26  7:56       ` martin rudalics
2017-10-26 15:59         ` Eli Zaretskii
2017-10-27  8:25           ` martin rudalics
2017-10-27  2:44         ` Richard Stallman
2017-10-25 22:25 ` Keith David Bershatsky
2017-10-26 16:30   ` Eli Zaretskii
2017-10-26 16:03 ` Keith David Bershatsky
2017-10-26 17:07   ` Eli Zaretskii
2017-10-27  8:26     ` martin rudalics

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