diff options
| author | Simon Josefsson | 2002-05-24 09:53:15 +0000 |
|---|---|---|
| committer | Simon Josefsson | 2002-05-24 09:53:15 +0000 |
| commit | 02f4566a55fa0084b68b829c95387484170b1139 (patch) | |
| tree | 9d869debdf50e50ff36d438e6564fd0b0ee98aa0 | |
| parent | 8cfa1cd56cb56b3a8dbba59661628097e8d88927 (diff) | |
| download | emacs-02f4566a55fa0084b68b829c95387484170b1139.tar.gz emacs-02f4566a55fa0084b68b829c95387484170b1139.zip | |
Initial version.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/fringe.el | 165 |
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 @@ | |||
| 1 | 2002-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 | |||
| 1 | 2002-05-23 Colin Walters <walters@verbum.org> | 9 | 2002-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. | ||
| 42 | See `fringe-mode' for valid values and their effect. | ||
| 43 | This 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. | ||
| 48 | See `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. | ||
| 84 | This variable can be nil (the default) meaning the fringes should have | ||
| 85 | the default width (8 pixels), it can be an integer value specifying | ||
| 86 | the width of both left and right fringe (where 0 means no fringe), or | ||
| 87 | a cons cell where car indicates width of left fringe and cdr indicates | ||
| 88 | width of right fringe (where again 0 can be used to indicate no | ||
| 89 | fringe). | ||
| 90 | To set this variable in a Lisp program, use `set-fringe-mode' to make | ||
| 91 | it take real effect. | ||
| 92 | Setting the variable with a customization buffer also takes effect. | ||
| 93 | If you only want to modify the appearance of the fringe in one frame, | ||
| 94 | you 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. | ||
| 110 | Returns values suitable for left-fringe and right-fringe frame parameters. | ||
| 111 | If ALL-FRAMES, the negation of the fringe values in | ||
| 112 | `default-frame-alist' is used when user enters the empty string. | ||
| 113 | Otherwise the negation of the fringe value in the currently selected | ||
| 114 | frame 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. | ||
| 136 | Valid values for MODE include `none', `default', `left-only', | ||
| 137 | `right-only' and `half'. MODE can also be a cons cell where the | ||
| 138 | integer in car will be used as left fringe width and the integer in | ||
| 139 | cdr will be used as right fringe width. If MODE is not specified, the | ||
| 140 | user is queried. | ||
| 141 | It applies to all frames that exist and frames to be created in the | ||
| 142 | future. | ||
| 143 | If you want to set appearance of fringes on the selected frame only, | ||
| 144 | see `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. | ||
| 151 | Valid values for MODE include `none', `default', `left-only', | ||
| 152 | `right-only' and `half'. MODE can also be a cons cell where the | ||
| 153 | integer in car will be used as left fringe width and the integer in | ||
| 154 | cdr will be used as right fringe width. If MODE is not specified, the | ||
| 155 | user is queried. | ||
| 156 | If 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 | ||