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