(openp): Initialized encoded_fn before GCPRO it.
[bpt/emacs.git] / lisp / ruler-mode.el
... / ...
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 143.
CommitLineData
1;;; ruler-mode.el --- display a ruler in the header line
2
3;; Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4
5;; Author: David Ponce <david@dponce.com>
6;; Maintainer: David Ponce <david@dponce.com>
7;; Created: 24 Mar 2001
8;; Version: 1.6
9;; Keywords: convenience
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., 51 Franklin Street, Fifth Floor,
26;; Boston, MA 02110-1301, 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;;
33;; You can use the mouse to change the `fill-column' `comment-column',
34;; `goal-column', `window-margins' and `tab-stop-list' settings:
35;;
36;; [header-line (shift down-mouse-1)] set left margin end to the ruler
37;; graduation where the mouse pointer is on.
38;;
39;; [header-line (shift down-mouse-3)] set right margin beginning to
40;; the ruler graduation where the mouse pointer is on.
41;;
42;; [header-line down-mouse-2] Drag the `fill-column', `comment-column'
43;; or `goal-column' to a ruler graduation.
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
58;; the `fill-column' location, `ruler-mode-comment-column-char' shows
59;; the `comment-column' location, `ruler-mode-goal-column-char' shows
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.
63;;
64;; It is also possible to customize the following characters:
65;;
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' the ruler default face.
74;; - `ruler-mode-fill-column' the face used to highlight the
75;; `fill-column' character.
76;; - `ruler-mode-comment-column' the face used to highlight the
77;; `comment-column' character.
78;; - `ruler-mode-goal-column' the face used to highlight the
79;; `goal-column' character.
80;; - `ruler-mode-current-column' the face used to highlight the
81;; `current-column' character.
82;; - `ruler-mode-tab-stop' the face used to highlight tab stop
83;; characters.
84;; - `ruler-mode-margins' the face used to highlight graduations
85;; in the `window-margins' areas.
86;; - `ruler-mode-fringes' the face used to highlight graduations
87;; in the `window-fringes' areas.
88;; - `ruler-mode-column-number' the face used to highlight the
89;; numbered graduations.
90;;
91;; `ruler-mode-default' inherits from the built-in `default' face.
92;; All `ruler-mode' faces inherit from `ruler-mode-default'.
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.
97;;
98;; You can override the ruler format by defining an appropriate
99;; function as the buffer-local value of `ruler-mode-ruler-function'.
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;;
110\f
111;;; Code:
112(eval-when-compile
113 (require 'wid-edit))
114(require 'scroll-bar)
115(require 'fringe)
116
117(defgroup ruler-mode nil
118 "Display a ruler in the header line."
119 :version "22.1"
120 :group 'convenience)
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))))
142
143