Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
[bpt/emacs.git] / lisp / ruler-mode.el
Content-type: text/html HCoop Git - bpt/emacs.git/blame - lisp/ruler-mode.el


500 - Internal Server Error

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