unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Customize fringe
@ 2002-05-09 12:05 Simon Josefsson
  2002-05-09 12:28 ` Miles Bader
                   ` (2 more replies)
  0 siblings, 3 replies; 40+ messages in thread
From: Simon Josefsson @ 2002-05-09 12:05 UTC (permalink / raw)


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 <simon@josefsson.org>
+;; 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

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

end of thread, other threads:[~2002-05-13 14:18 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-09 12:05 Customize fringe Simon Josefsson
2002-05-09 12:28 ` Miles Bader
2002-05-09 17:36   ` Simon Josefsson
2002-05-09 18:48     ` Miles Bader
2002-05-09 19:46       ` Simon Josefsson
2002-05-10  1:32         ` Miles Bader
2002-05-10  6:52           ` Eli Zaretskii
2002-05-10  7:23             ` Miles Bader
2002-05-10  9:40             ` Kim F. Storm
2002-05-10 11:07               ` Robert J. Chassell
2002-05-10 11:08               ` Robert J. Chassell
2002-05-10 10:44             ` Robert J. Chassell
2002-05-10 12:17               ` Eli Zaretskii
2002-05-10 13:37                 ` Robert J. Chassell
2002-05-13  2:16                 ` Miles Bader
2002-05-11  6:31           ` Richard Stallman
2002-05-11  8:04             ` Simon Josefsson
2002-05-09 18:07   ` Eli Zaretskii
2002-05-09 18:35     ` Stefan Monnier
2002-05-09 19:39       ` Simon Josefsson
2002-05-09 21:18         ` Stefan Monnier
2002-05-09 22:13           ` Simon Josefsson
2002-05-09 22:24             ` Simon Josefsson
2002-05-11  8:16               ` Pavel Janík
2002-05-11  9:14                 ` Simon Josefsson
2002-05-11 10:13                   ` Eli Zaretskii
2002-05-11 12:24                     ` Simon Josefsson
2002-05-11 23:28                   ` Kim F. Storm
2002-05-11  6:31             ` Richard Stallman
2002-05-09 23:31 ` Kim F. Storm
2002-05-11  9:12   ` Simon Josefsson
2002-05-11 23:44     ` Kim F. Storm
2002-05-11 23:11       ` Simon Josefsson
2002-05-12  4:49         ` Eli Zaretskii
2002-05-12  9:51           ` Simon Josefsson
2002-05-12 10:06             ` Eli Zaretskii
2002-05-12 10:30               ` Simon Josefsson
2002-05-12 12:37                 ` Eli Zaretskii
2002-05-13 14:18       ` Richard Stallman
2002-05-10  0:29 ` Richard Stallman

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