]> code.delx.au - gnu-emacs/blobdiff - lisp/scroll-bar.el
Add and use function horizontal-scroll-bars-available-p.
[gnu-emacs] / lisp / scroll-bar.el
index 588ac3b0f8acd7a3076f07e4482d880156ac159a..63713c24a64644b53dcd8e7cddb27dd3edb96f75 100644 (file)
@@ -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.