| 1 | ;;; ruler-mode.el --- display a ruler in the header line |
| 2 | |
| 3 | ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, |
| 4 | ;; 2006 Free Software Foundation, Inc. |
| 5 | |
| 6 | ;; Author: David Ponce <david@dponce.com> |
| 7 | ;; Maintainer: David Ponce <david@dponce.com> |
| 8 | ;; Created: 24 Mar 2001 |
| 9 | ;; Version: 1.6 |
| 10 | ;; Keywords: convenience |
| 11 | |
| 12 | ;; This file is part of GNU Emacs. |
| 13 | |
| 14 | ;; This program is free software; you can redistribute it and/or |
| 15 | ;; modify it under the terms of the GNU General Public License as |
| 16 | ;; published by the Free Software Foundation; either version 2, or (at |
| 17 | ;; your option) any later version. |
| 18 | |
| 19 | ;; This program is distributed in the hope that it will be useful, but |
| 20 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | ;; General Public License for more details. |
| 23 | |
| 24 | ;; You should have received a copy of the GNU General Public License |
| 25 | ;; along with this program; see the file COPYING. If not, write to |
| 26 | ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 27 | ;; Boston, MA 02110-1301, USA. |
| 28 | |
| 29 | ;;; Commentary: |
| 30 | |
| 31 | ;; This library provides a minor mode to display a ruler in the header |
| 32 | ;; line. It works only on Emacs 21. |
| 33 | ;; |
| 34 | ;; You can use the mouse to change the `fill-column' `comment-column', |
| 35 | ;; `goal-column', `window-margins' and `tab-stop-list' settings: |
| 36 | ;; |
| 37 | ;; [header-line (shift down-mouse-1)] set left margin end to the ruler |
| 38 | ;; graduation where the mouse pointer is on. |
| 39 | ;; |
| 40 | ;; [header-line (shift down-mouse-3)] set right margin beginning to |
| 41 | ;; the ruler graduation where the mouse pointer is on. |
| 42 | ;; |
| 43 | ;; [header-line down-mouse-2] Drag the `fill-column', `comment-column' |
| 44 | ;; or `goal-column' to a ruler graduation. |
| 45 | ;; |
| 46 | ;; [header-line (control down-mouse-1)] add a tab stop to the ruler |
| 47 | ;; graduation where the mouse pointer is on. |
| 48 | ;; |
| 49 | ;; [header-line (control down-mouse-3)] remove the tab stop at the |
| 50 | ;; ruler graduation where the mouse pointer is on. |
| 51 | ;; |
| 52 | ;; [header-line (control down-mouse-2)] or M-x |
| 53 | ;; `ruler-mode-toggle-show-tab-stops' toggle showing and visually |
| 54 | ;; editing `tab-stop-list' setting. The `ruler-mode-show-tab-stops' |
| 55 | ;; option controls if the ruler shows tab stops by default. |
| 56 | ;; |
| 57 | ;; In the ruler the character `ruler-mode-current-column-char' shows |
| 58 | ;; the `current-column' location, `ruler-mode-fill-column-char' shows |
| 59 | ;; the `fill-column' location, `ruler-mode-comment-column-char' shows |
| 60 | ;; the `comment-column' location, `ruler-mode-goal-column-char' shows |
| 61 | ;; the `goal-column' and `ruler-mode-tab-stop-char' shows tab stop |
| 62 | ;; locations. Graduations in `window-margins' and `window-fringes' |
| 63 | ;; areas are shown with a different foreground color. |
| 64 | ;; |
| 65 | ;; It is also possible to customize the following characters: |
| 66 | ;; |
| 67 | ;; - `ruler-mode-basic-graduation-char' character used for basic |
| 68 | ;; graduations ('.' by default). |
| 69 | ;; - `ruler-mode-inter-graduation-char' character used for |
| 70 | ;; intermediate graduations ('!' by default). |
| 71 | ;; |
| 72 | ;; The following faces are customizable: |
| 73 | ;; |
| 74 | ;; - `ruler-mode-default' the ruler default face. |
| 75 | ;; - `ruler-mode-fill-column' the face used to highlight the |
| 76 | ;; `fill-column' character. |
| 77 | ;; - `ruler-mode-comment-column' the face used to highlight the |
| 78 | ;; `comment-column' character. |
| 79 | ;; - `ruler-mode-goal-column' the face used to highlight the |
| 80 | ;; `goal-column' character. |
| 81 | ;; - `ruler-mode-current-column' the face used to highlight the |
| 82 | ;; `current-column' character. |
| 83 | ;; - `ruler-mode-tab-stop' the face used to highlight tab stop |
| 84 | ;; characters. |
| 85 | ;; - `ruler-mode-margins' the face used to highlight graduations |
| 86 | ;; in the `window-margins' areas. |
| 87 | ;; - `ruler-mode-fringes' the face used to highlight graduations |
| 88 | ;; in the `window-fringes' areas. |
| 89 | ;; - `ruler-mode-column-number' the face used to highlight the |
| 90 | ;; numbered graduations. |
| 91 | ;; |
| 92 | ;; `ruler-mode-default' inherits from the built-in `default' face. |
| 93 | ;; All `ruler-mode' faces inherit from `ruler-mode-default'. |
| 94 | ;; |
| 95 | ;; WARNING: To keep ruler graduations aligned on text columns it is |
| 96 | ;; important to use the same font family and size for ruler and text |
| 97 | ;; areas. |
| 98 | ;; |
| 99 | ;; You can override the ruler format by defining an appropriate |
| 100 | ;; function as the buffer-local value of `ruler-mode-ruler-function'. |
| 101 | |
| 102 | ;; Installation |
| 103 | ;; |
| 104 | ;; To automatically display the ruler in specific major modes use: |
| 105 | ;; |
| 106 | ;; (add-hook '<major-mode>-hook 'ruler-mode) |
| 107 | ;; |
| 108 | |
| 109 | ;;; History: |
| 110 | ;; |
| 111 | \f |
| 112 | ;;; Code: |
| 113 | (eval-when-compile |
| 114 | (require 'wid-edit)) |
| 115 | (require 'scroll-bar) |
| 116 | (require 'fringe) |
| 117 | |
| 118 | (defgroup ruler-mode nil |
| 119 | "Display a ruler in the header line." |
| 120 | :version "22.1" |
| 121 | :group 'convenience) |
| 122 | |
| 123 | (defcustom ruler-mode-show-tab-stops nil |
| 124 | "*If non-nil the ruler shows tab stop positions. |
| 125 | Also allowing to visually change `tab-stop-list' setting using |
| 126 | <C-down-mouse-1> and <C-down-mouse-3> on the ruler to respectively add |
| 127 | or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or |
| 128 | <C-down-mouse-2> on the ruler toggles showing/editing of tab stops." |
| 129 | :group 'ruler-mode |
| 130 | :type 'boolean) |
| 131 | |
| 132 | ;; IMPORTANT: This function must be defined before the following |
| 133 | ;; defcustoms because it is used in their :validate clause. |
| 134 | (defun ruler-mode-character-validate (widget) |
| 135 | "Ensure WIDGET value is a valid character value." |
| 136 | (save-excursion |
| 137 | (let ((value (widget-value widget))) |
| 138 | (if (char-valid-p value) |
| 139 | nil |
| 140 | (widget-put widget :error |
| 141 | (format "Invalid character value: %S" value)) |
| 142 | widget)))) |
| 143 | |
| 144 | Content-type: text/html
HCoop Git - bpt/emacs.git/blame_incremental - lisp/ruler-mode.el
500 - Internal Server Error
Malformed UTF-8 character (fatal) at (eval 8) line 1, <$fd> line 144.