emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Customize fringe


From: Simon Josefsson
Subject: Customize fringe
Date: Thu, 09 May 2002 14:05:50 +0200
User-agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2.50 (i686-pc-linux-gnu)

What do you think of this?

Index: loadup.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/loadup.el,v
retrieving revision 1.122
diff -u -p -r1.122 loadup.el
--- loadup.el   27 Apr 2002 03:48:19 -0000      1.122
+++ loadup.el   9 May 2002 12:04:20 -0000
@@ -135,6 +135,7 @@
       (and (boundp 'x-toolkit-scroll-bars)
           (load "scroll-bar"))
       (load "select")))
+(load "fringe")
 (load "timer")
 (load "isearch")
 
Index: menu-bar.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/menu-bar.el,v
retrieving revision 1.216
diff -u -p -r1.216 menu-bar.el
--- menu-bar.el 1 May 2002 22:01:16 -0000       1.216
+++ menu-bar.el 9 May 2002 12:04:21 -0000
@@ -707,6 +707,23 @@ Do the same for the keys of the same nam
              :help "Toggle menu-bar on/off"
              :button (:toggle . menu-bar-mode)))
 
+(defun showhide-fringe ()
+  "Toggle whether to turn fringe on/off."
+  (interactive)
+  (fringe-mode)
+  (if (not fringe-mode)
+      (message "Fringe mode enabled.")
+    (message "Fringe mode disabled.")))
+
+(define-key menu-bar-showhide-menu [showhide-fringe]
+  '(menu-item "Fringe"
+             (lambda ()
+               (interactive)
+               (showhide-fringe)
+               (customize-mark-as-set 'fringe-mode))
+             :help "Toggle fringe on/off"
+             :button (:toggle . (not fringe-mode))))
+
 (defun showhide-tool-bar ()
   "Toggle whether to turn tool-bar on/off."
   (interactive)
Index: fringe.el
===================================================================
RCS file: fringe.el
diff -N fringe.el
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ fringe.el   9 May 2002 12:04:21 -0000
@@ -0,0 +1,128 @@
+;;; fringe.el --- window system-independent fringe support
+
+;; Copyright (C) 2001 Free Software Foundation, Inc.
+
+;; Author: Simon Josefsson <address@hidden>
+;; Maintainer: FSF
+;; Keywords: hardware
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; This file contains helpful functions for enabling and disabling the
+;; fringe.
+
+;; It is based on scroll-bar.el.
+
+;;; Code:
+
+(defvar fringe-mode)
+
+(defvar fringe-mode-explicit nil
+  "Non-nil means `set-fringe-mode' should really do something.
+This is nil while loading `fringe.el', and t afterward.")
+
+(defun set-fringe-mode-1 (ignore value)
+  "Call `set-fringe-mode' with VALUE.
+See `fringe-mode' for possible modes and their effect.
+This is usually invoked when setting `fringe-mode' via customize."
+  (set-fringe-mode value))
+
+(defun set-fringe-mode (value)
+  "Set `fringe-mode' to VALUE and put the new value into effect.
+See `fringe-mode' for possible modes and their effect."
+  (setq fringe-mode value)
+
+  (when fringe-mode-explicit
+    ;; Apply it to default-frame-alist.
+    (let ((parameter (assq 'left-fringe default-frame-alist)))
+      (if (consp parameter)
+         (setcdr parameter fringe-mode)
+       (setq default-frame-alist
+             (cons (cons 'left-fringe fringe-mode)
+                   default-frame-alist))))
+    (let ((parameter (assq 'right-fringe default-frame-alist)))
+      (if (consp parameter)
+         (setcdr parameter fringe-mode)
+       (setq default-frame-alist
+             (cons (cons 'right-fringe fringe-mode)
+                   default-frame-alist))))
+
+    ;; Apply it to existing frames.
+    (let ((frames (frame-list)))
+      (while frames
+       (modify-frame-parameters
+        (car frames)
+        (list (cons 'left-fringe fringe-mode)
+              (cons 'right-fringe fringe-mode)))
+       (setq frames (cdr frames))))))
+
+(defcustom fringe-mode nil
+  "*Specify presence and width of fringes.
+This variable can take on a integer value specifying the fringe
+width (both left and right) or nil meaning default fringe width.
+To set this variable in a Lisp program, use `set-fringe-mode' to make
+it take real effect.
+Setting the variable with a customization buffer also takes effect."
+  :type '(choice (const :tag "Default width" nil)
+                (const :tag "No fringes" 0)
+                (integer :tag "Specific width"))
+  :group 'frames
+  :set 'set-fringe-mode-1)
+
+;; We just set fringe-mode, but that was the default.
+;; If it is set again, that is for real.
+(setq fringe-mode-explicit t)
+
+(defun fringe-mode (&optional flag)
+  "Toggle display of the fringe on all frames.
+This command applies to all frames that exist and frames to be
+created in the future.
+With a numeric argument, if the argument is negative,
+turn off the fringe; otherwise, turn on the fringe."
+  (interactive "P")
+  (if flag (setq flag (prefix-numeric-value flag)))
+
+  ;; Tweedle the variable according to the argument.
+  (set-fringe-mode
+   (if (null flag)
+       (if (eq (cdr-safe (assq 'left-fringe default-frame-alist)) 0)
+          nil
+        0)
+     (and (numberp flag) (< flag 0) 0))))
+
+(defun toggle-fringe (arg)
+  "Toggle whether or not the selected frame has a left and right fringe.
+With arg, turn fringes on if and only if arg is positive."
+  (interactive "P")
+  (if (null arg)
+      (setq arg
+           (if (eq (cdr (assq 'left-fringe
+                              (frame-parameters (selected-frame)))) 0)
+               nil
+             0))
+    (setq arg (prefix-numeric-value arg)))
+  (modify-frame-parameters
+   (selected-frame)
+   (list (cons 'left-fringe arg)
+        (cons 'right-fringe arg))))
+
+(provide 'fringe)
+
+;;; fringe.el ends here




reply via email to

[Prev in Thread] Current Thread [Next in Thread]