aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Josefsson2002-05-24 09:53:15 +0000
committerSimon Josefsson2002-05-24 09:53:15 +0000
commit02f4566a55fa0084b68b829c95387484170b1139 (patch)
tree9d869debdf50e50ff36d438e6564fd0b0ee98aa0
parent8cfa1cd56cb56b3a8dbba59661628097e8d88927 (diff)
downloademacs-02f4566a55fa0084b68b829c95387484170b1139.tar.gz
emacs-02f4566a55fa0084b68b829c95387484170b1139.zip
Initial version.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/fringe.el165
2 files changed, 173 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ca19ad08a76..ec70fba6e12 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12002-05-20 Simon Josefsson <jas@extundo.com>
2
3 * fringe.el: New file.
4
5 * menu-bar.el (menu-bar-options-save): Add fringe-mode.
6 (menu-bar-showhide-fringe-menu): New menu.
7 (menu-bar-showhide-menu): Add Fringe sub-menu.
8
12002-05-23 Colin Walters <walters@verbum.org> 92002-05-23 Colin Walters <walters@verbum.org>
2 10
3 * replace.el (occur-engine): Include all text properties except 11 * replace.el (occur-engine): Include all text properties except
diff --git a/lisp/fringe.el b/lisp/fringe.el
new file mode 100644
index 00000000000..67dae5c1b49
--- /dev/null
+++ b/lisp/fringe.el
@@ -0,0 +1,165 @@
1;;; fringe.el --- change fringes appearance in various ways
2
3;; Copyright (C) 2002 Free Software Foundation, Inc.
4
5;; Author: Simon Josefsson <simon@josefsson.org>
6;; Maintainer: FSF
7;; Keywords: frames
8
9;; This file is part of GNU Emacs.
10
11;; GNU Emacs is free software; you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
13;; the Free Software Foundation; either version 2, or (at your option)
14;; any later version.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
22;; along with GNU Emacs; see the file COPYING. If not, write to the
23;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24;; Boston, MA 02111-1307, USA.
25
26;;; Commentary:
27
28;; This file contains helpful functions for customizing the appearance
29;; of the fringe.
30
31;; The code is influenced by scroll-bar.el and avoid.el. The author
32;; gratefully acknowledge comments and suggestions made by Miles
33;; Bader, Eli Zaretski, Richard Stallman, Pavel Janík and others which
34;; improved this package.
35
36;;; Code:
37
38(defvar fringe-mode)
39
40(defun set-fringe-mode-1 (ignore value)
41 "Call `set-fringe-mode' with VALUE.
42See `fringe-mode' for valid values and their effect.
43This is usually invoked when setting `fringe-mode' via customize."
44 (set-fringe-mode value))
45
46(defun set-fringe-mode (value)
47 "Set `fringe-mode' to VALUE and put the new value into effect.
48See `fringe-mode' for possible values and their effect."
49 (setq fringe-mode value)
50
51 ;; Apply it to default-frame-alist.
52 (let ((parameter (assq 'left-fringe default-frame-alist)))
53 (if (consp parameter)
54 (setcdr parameter fringe-mode)
55 (setq default-frame-alist
56 (cons (cons 'left-fringe (if (consp fringe-mode)
57 (car fringe-mode)
58 fringe-mode))
59 default-frame-alist))))
60 (let ((parameter (assq 'right-fringe default-frame-alist)))
61 (if (consp parameter)
62 (setcdr parameter fringe-mode)
63 (setq default-frame-alist
64 (cons (cons 'right-fringe (if (consp fringe-mode)
65 (cdr fringe-mode)
66 fringe-mode))
67 default-frame-alist))))
68
69 ;; Apply it to existing frames.
70 (let ((frames (frame-list)))
71 (while frames
72 (modify-frame-parameters
73 (car frames)
74 (list (cons 'left-fringe (if (consp fringe-mode)
75 (car fringe-mode)
76 fringe-mode))
77 (cons 'right-fringe (if (consp fringe-mode)
78 (cdr fringe-mode)
79 fringe-mode))))
80 (setq frames (cdr frames)))))
81
82(defcustom fringe-mode nil
83 "*Specify appearance of fringes on all frames.
84This variable can be nil (the default) meaning the fringes should have
85the default width (8 pixels), it can be an integer value specifying
86the width of both left and right fringe (where 0 means no fringe), or
87a cons cell where car indicates width of left fringe and cdr indicates
88width of right fringe (where again 0 can be used to indicate no
89fringe).
90To set this variable in a Lisp program, use `set-fringe-mode' to make
91it take real effect.
92Setting the variable with a customization buffer also takes effect.
93If you only want to modify the appearance of the fringe in one frame,
94you can use the interactive function `toggle-fringe'"
95 :type '(choice (const :tag "Default width" nil)
96 (const :tag "No fringes" 0)
97 (const :tag "Only right" (0 . nil))
98 (const :tag "Only left" (nil . 0))
99 (const :tag "Half width" (5 . 5))
100 (integer :tag "Specific width")
101 (cons :tag "Different left/right sizes"
102 (integer :tag "Left width")
103 (integer :tag "Right width")))
104 :group 'frames
105 :require 'fringe
106 :set 'set-fringe-mode-1)
107
108(defun fringe-query-style (&optional all-frames)
109 "Query user for fringe style.
110Returns values suitable for left-fringe and right-fringe frame parameters.
111If ALL-FRAMES, the negation of the fringe values in
112`default-frame-alist' is used when user enters the empty string.
113Otherwise the negation of the fringe value in the currently selected
114frame parameter is used."
115 (let ((mode (intern (completing-read
116 "Select fringe mode for all frames (SPACE for list): "
117 '(("none") ("default") ("left-only")
118 ("right-only") ("half"))
119 nil t))))
120 (cond ((eq mode 'none) 0)
121 ((eq mode 'default) nil)
122 ((eq mode 'left-only) '(nil . 0))
123 ((eq mode 'right-only) '(0 . nil))
124 ((eq mode 'half) '(5 . 5))
125 ((eq mode (intern ""))
126 (if (eq 0 (cdr (assq 'left-fringe
127 (if all-frames
128 default-frame-alist
129 (frame-parameters (selected-frame))))))
130 nil
131 0)))))
132
133;;;###autoload
134(defun fringe-mode (&optional mode)
135 "Toggle appearance of fringes on all frames.
136Valid values for MODE include `none', `default', `left-only',
137`right-only' and `half'. MODE can also be a cons cell where the
138integer in car will be used as left fringe width and the integer in
139cdr will be used as right fringe width. If MODE is not specified, the
140user is queried.
141It applies to all frames that exist and frames to be created in the
142future.
143If you want to set appearance of fringes on the selected frame only,
144see `set-fringe-style'."
145 (interactive (list (fringe-query-style 'all-frames)))
146 (set-fringe-mode mode))
147
148;;;###autoload
149(defun set-fringe-style (&optional mode)
150 "Set appearance of fringes on selected frame.
151Valid values for MODE include `none', `default', `left-only',
152`right-only' and `half'. MODE can also be a cons cell where the
153integer in car will be used as left fringe width and the integer in
154cdr will be used as right fringe width. If MODE is not specified, the
155user is queried.
156If you want to set appearance of fringes on all frames, see `fringe-mode'."
157 (interactive (list (fringe-query-style)))
158 (modify-frame-parameters
159 (selected-frame)
160 (list (cons 'left-fringe (if (consp mode) (car mode) mode))
161 (cons 'right-fringe (if (consp mode) (cdr mode) mode)))))
162
163(provide 'fringe)
164
165;;; fringe.el ends here