From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Simon Josefsson Newsgroups: gmane.emacs.devel Subject: Customize fringe Date: Thu, 09 May 2002 14:05:50 +0200 Sender: emacs-devel-admin@gnu.org Message-ID: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1020945982 25099 127.0.0.1 (9 May 2002 12:06:22 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 9 May 2002 12:06:22 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 175mgf-0006Wi-00 for ; Thu, 09 May 2002 14:06:21 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 175mpG-0001U5-00 for ; Thu, 09 May 2002 14:15:14 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 175mgZ-0002my-00; Thu, 09 May 2002 08:06:15 -0400 Original-Received: from 178.230.13.217.in-addr.dgcsystems.net ([217.13.230.178] helo=yxa.extundo.com) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 175mgC-0002l6-00 for ; Thu, 09 May 2002 08:05:52 -0400 Original-Received: from localhost.localdomain (yxa.extundo.com [217.13.230.178]) (authenticated bits=0) by yxa.extundo.com (8.12.3/8.12.3) with ESMTP id g49C5j5p002073 for ; Thu, 9 May 2002 14:05:50 +0200 Original-To: emacs-devel@gnu.org Original-Lines: 183 User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2.50 (i686-pc-linux-gnu) Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:3765 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:3765 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 +;; 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