summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2014-09-05 12:29:34 +0200
committerMartin Rudalics <rudalics@gmx.at>2014-09-05 12:29:34 +0200
commit510a4a4e93a06557c62dcb622f8f8e9c3d533f53 (patch)
tree95af00ed2046c6a9769958b4494bc8502990d0a0
parent04b134e174b7ce4ce49f26c56791d92dd08fbee1 (diff)
Add and use function horizontal-scroll-bars-available-p.
* scroll-bar.el (horizontal-scroll-bars-available-p): New function. (horizontal-scroll-bar-mode): Rewrite using horizontal-scroll-bars-available-p. * menu-bar.el (menu-bar-showhide-scroll-bar-menu): Rewrite using horizontal-scroll-bars-available-p.
-rw-r--r--etc/NEWS2
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/menu-bar.el14
-rw-r--r--lisp/scroll-bar.el28
4 files changed, 37 insertions, 16 deletions
diff --git a/etc/NEWS b/etc/NEWS
index bdda3ed067..3b7516dd81 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -240,6 +240,8 @@ optional repeat-count argument.
** Emacs can now draw horizontal scroll bars on some platforms that
provide toolkit scroll bars, namely Gtk, Lucid, Motif and Windows.
Horizontal scroll bars are turned off by default.
+*** New function `horizontal-scroll-bars-available-p' telling whether
+ horizontal scroll bars are available on the underlying system.
*** New mode `horizontal-scroll-bar-mode' to toggle horizontal scroll
bars on all existing and future frames.
*** New frame parameters `horizontal-scroll-bars' and
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2cc27412da..c6469006b8 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
+2014-09-05 Martin Rudalics <rudalics@gmx.at>
+
+ * scroll-bar.el (horizontal-scroll-bars-available-p): New
+ function.
+ (horizontal-scroll-bar-mode): Rewrite using
+ horizontal-scroll-bars-available-p.
+ * menu-bar.el (menu-bar-showhide-scroll-bar-menu): Rewrite using
+ horizontal-scroll-bars-available-p.
+
2014-09-05 Stefan Monnier <monnier@iro.umontreal.ca>
* subr.el (call-process-shell-command, process-file-shell-command):
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 57acbbe648..9657c5924f 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -903,19 +903,17 @@ by \"Save Options\" in Custom buffers.")
'(menu-item "Horizontal"
menu-bar-horizontal-scroll-bar
:help "Horizontal scroll bar"
- :visible (display-graphic-p)
- :button (:radio . (eq (cdr (assq 'horizontal-scroll-bars
- (frame-parameters)))
- t))))
+ :visible (horizontal-scroll-bars-available-p)
+ :button (:radio . (cdr (assq 'horizontal-scroll-bars
+ (frame-parameters))))))
(bindings--define-key menu [none-horizontal]
'(menu-item "None-horizontal"
menu-bar-no-horizontal-scroll-bar
:help "Turn off horizontal scroll bars"
- :visible (display-graphic-p)
- :button (:radio . (eq (cdr (assq 'horizontal-scroll-bars
- (frame-parameters)))
- nil))))
+ :visible (horizontal-scroll-bars-available-p)
+ :button (:radio . (not (cdr (assq 'horizontal-scroll-bars
+ (frame-parameters)))))))
(bindings--define-key menu [right]
'(menu-item "On the Right"
diff --git a/lisp/scroll-bar.el b/lisp/scroll-bar.el
index 588ac3b0f8..63713c24a6 100644
--- a/lisp/scroll-bar.el
+++ b/lisp/scroll-bar.el
@@ -144,6 +144,13 @@ created in the future."
(if v (or previous-scroll-bar-mode
default-frame-scroll-bars))))))
+(defun horizontal-scroll-bars-available-p ()
+ "Return non-nil when horizontal scroll bars are available on this system."
+ (and (display-graphic-p)
+ (boundp 'x-toolkit-scroll-bars)
+ x-toolkit-scroll-bars
+ (not (eq (window-system) 'ns))))
+
(define-minor-mode horizontal-scroll-bar-mode
"Toggle horizontal scroll bars on all frames (Horizontal Scroll Bar mode).
With a prefix argument ARG, enable Horizontal Scroll Bar mode if
@@ -155,14 +162,19 @@ created in the future."
:init-value nil
:global t
:group 'frames
- (dolist (frame (frame-list))
- (set-frame-parameter
- frame 'horizontal-scroll-bars horizontal-scroll-bar-mode))
- ;; Handle `default-frame-alist' entry.
- (setq default-frame-alist
- (cons (cons 'horizontal-scroll-bars horizontal-scroll-bar-mode)
- (assq-delete-all 'horizontal-scroll-bars
- default-frame-alist))))
+ (if (and horizontal-scroll-bar-mode
+ (not (horizontal-scroll-bars-available-p)))
+ (progn
+ (setq horizontal-scroll-bar-mode nil)
+ (message "Horizontal scroll bars are not implemented on this system"))
+ (dolist (frame (frame-list))
+ (set-frame-parameter
+ frame 'horizontal-scroll-bars horizontal-scroll-bar-mode))
+ ;; Handle `default-frame-alist' entry.
+ (setq default-frame-alist
+ (cons (cons 'horizontal-scroll-bars horizontal-scroll-bar-mode)
+ (assq-delete-all 'horizontal-scroll-bars
+ default-frame-alist)))))
(defun toggle-scroll-bar (arg)
"Toggle whether or not the selected frame has vertical scroll bars.