annotate lisp/ruler-mode.el @ 45359:6dbb4ce89a70

*** empty log message ***
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 19 May 2002 02:11:24 +0000
parents 20c79f08a7da
children 865837df3fe7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42836
c6bcb27e426f (ruler-mode): New keyword. Fix :version.
Pavel Janík <Pavel@Janik.cz>
parents: 42706
diff changeset
1 ;;; ruler-mode.el --- display a ruler in the header line
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 2001 Free Software Foundation, Inc.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; Author: David Ponce <david@dponce.com>
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Maintainer: David Ponce <david@dponce.com>
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; Created: 24 Mar 2001
42003
a22f2256bce0 (ruler-mode-left-fringe-cols): Variable removed.
Richard M. Stallman <rms@gnu.org>
parents: 41461
diff changeset
8 ;; Version: 1.4
42836
c6bcb27e426f (ruler-mode): New keyword. Fix :version.
Pavel Janík <Pavel@Janik.cz>
parents: 42706
diff changeset
9 ;; Keywords: environment convenience
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; This program is free software; you can redistribute it and/or
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; modify it under the terms of the GNU General Public License as
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; published by the Free Software Foundation; either version 2, or (at
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; your option) any later version.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; This program is distributed in the hope that it will be useful, but
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; General Public License for more details.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 ;; along with this program; see the file COPYING. If not, write to
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;; Boston, MA 02111-1307, USA.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 ;;; Commentary:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; This library provides a minor mode to display a ruler in the header
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;; line. It works only on Emacs 21.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;; You can use the mouse to change the `fill-column', `window-margins'
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;; and `tab-stop-list' settings:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;; [header-line (shift down-mouse-1)] set left margin to the ruler
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;; graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;; [header-line (shift down-mouse-3)] set right margin to the ruler
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;; graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;; [header-line down-mouse-2] set `fill-column' to the ruler
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;; graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;; [header-line (control down-mouse-1)] add a tab stop to the ruler
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;; graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;; [header-line (control down-mouse-3)] remove the tab stop at the
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 ;; ruler graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 ;; [header-line (control down-mouse-2)] or M-x
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;; `ruler-mode-toggle-show-tab-stops' toggle showing and visually
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;; editing `tab-stop-list' setting. The `ruler-mode-show-tab-stops'
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;; option controls if the ruler shows tab stops by default.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 ;; In the ruler the character `ruler-mode-current-column-char' shows
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 ;; the `current-column' location, `ruler-mode-fill-column-char' shows
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 ;; the `fill-column' location and `ruler-mode-tab-stop-char' shows tab
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 ;; stop locations. `window-margins' areas are shown with a different
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 ;; background color.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 ;; It is also possible to customize the following characters:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 ;; - `ruler-mode-margins-char' character used to pad margin areas
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 ;; (space by default).
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 ;; - `ruler-mode-basic-graduation-char' character used for basic
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 ;; graduations ('.' by default).
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 ;; - `ruler-mode-inter-graduation-char' character used for
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 ;; intermediate graduations ('!' by default).
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 ;; The following faces are customizable:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 ;; - `ruler-mode-default-face' the ruler default face.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 ;; - `ruler-mode-fill-column-face' the face used to highlight the
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 ;; `fill-column' character.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 ;; - `ruler-mode-current-column-face' the face used to highlight the
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 ;; `current-column' character.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 ;; - `ruler-mode-tab-stop-face' the face used to highlight tab stop
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 ;; characters.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 ;; - `ruler-mode-margins-face' the face used to highlight the
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 ;; `window-margins' areas.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 ;; - `ruler-mode-column-number-face' the face used to highlight the
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 ;; number graduations.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 ;; `ruler-mode-default-face' inherits from the built-in `default' face.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 ;; All `ruler-mode' faces inerit from `ruler-mode-default-face'.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 ;; WARNING: To keep ruler graduations aligned on text columns it is
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 ;; important to use the same font family and size for ruler and text
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 ;; areas.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 ;; Installation
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 ;; To automatically display the ruler in specific major modes use:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 ;; (add-hook '<major-mode>-hook 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 ;;; History:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 ;;
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
101
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 ;;; Code:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 (eval-when-compile
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 (require 'wid-edit))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 (defgroup ruler-mode nil
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 "Display a ruler in the header line."
45255
20c79f08a7da Change all post-21.1 :version attributes to 21.4.
Eli Zaretskii <eliz@gnu.org>
parents: 42836
diff changeset
108 :version "21.4"
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 :group 'environment)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 (defcustom ruler-mode-show-tab-stops nil
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 "*If non-nil the ruler shows tab stop positions.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 Also allowing to visually change `tab-stop-list' setting using
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 <C-down-mouse-1> and <C-down-mouse-3> on the ruler to respectively add
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 <C-down-mouse-2> on the ruler toggles showing/editing of tab stops."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 :type 'boolean)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 ;; IMPORTANT: This function must be defined before the following
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 ;; defcustoms because it is used in their :validate clause.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 (defun ruler-mode-character-validate (widget)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 "Ensure WIDGET value is a valid character value."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 (save-excursion
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 (let ((value (widget-value widget)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 (if (char-valid-p value)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 nil
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 (widget-put widget :error
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 (format "Invalid character value: %S" value))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 widget))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 (defcustom ruler-mode-fill-column-char (if window-system
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 ?\¶
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 ?\|)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 "*Character used at the `fill-column' location."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 :type '(choice
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 (character :tag "Character")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 (integer :tag "Integer char value"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 :validate ruler-mode-character-validate)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 (defcustom ruler-mode-current-column-char (if window-system
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 ?\¦
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 ?\@)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 "*Character used at the `current-column' location."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 :type '(choice
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 (character :tag "Character")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 (integer :tag "Integer char value"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 :validate ruler-mode-character-validate)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 (defcustom ruler-mode-tab-stop-char ?\T
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 "*Character used at `tab-stop-list' locations."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 :type '(choice
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 (character :tag "Character")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 (integer :tag "Integer char value"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 :validate ruler-mode-character-validate)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 (defcustom ruler-mode-margins-char ?\
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 "*Character used in margin areas."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 :type '(choice
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 (character :tag "Character")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 (integer :tag "Integer char value"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 :validate ruler-mode-character-validate)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 (defcustom ruler-mode-basic-graduation-char ?\.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 "*Character used for basic graduations."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 :type '(choice
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 (character :tag "Character")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 (integer :tag "Integer char value"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 :validate ruler-mode-character-validate)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 (defcustom ruler-mode-inter-graduation-char ?\!
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 "*Character used for intermediate graduations."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 :type '(choice
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 (character :tag "Character")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 (integer :tag "Integer char value"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 :validate ruler-mode-character-validate)))
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
183
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 (defface ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 '((((type tty))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 (:inherit default
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 :background "grey64"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 :foreground "grey50"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 ))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 (t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 (:inherit default
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 :background "grey76"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 :foreground "grey64"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 :box (:color "grey76"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 :line-width 1
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 :style released-button)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 "Default face used by the ruler."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 (defface ruler-mode-column-number-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 '((t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 :foreground "black"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 "Face used to highlight number graduations."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 (defface ruler-mode-fill-column-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 '((t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 :foreground "red"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 "Face used to highlight the fill column character."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 (defface ruler-mode-tab-stop-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 '((t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 :foreground "steelblue"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 "Face used to highlight tab stop characters."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 (defface ruler-mode-margins-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 '((((type tty))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 :background "grey50"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 ))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 (t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 :background "grey64"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 "Face used to highlight the `window-margins' areas."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 (defface ruler-mode-current-column-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 '((t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 :weight bold
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 :foreground "yellow"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 "Face used to highlight the `current-column' character."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 :group 'ruler-mode)
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
245
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 (defun ruler-mode-mouse-set-left-margin (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 "Set left margin to the graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 w col m lm0 lm rm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 lm0 (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 rm (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 col (car (posn-col-row start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 lm (min (- w rm) col))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (message "Left margin set to %d (was %d)" lm lm0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 (set-window-margins nil lm rm)))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 (defun ruler-mode-mouse-set-right-margin (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 "Set right margin to the graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 m col w lm rm0 rm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 rm0 (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 lm (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 col (car (posn-col-row start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 rm (max 0 (- w col)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 (message "Right margin set to %d (was %d)" rm rm0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282 (set-window-margins nil lm rm)))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 (defun ruler-mode-mouse-set-fill-column (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 "Set `fill-column' to the graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 m col w lm rm hs fc)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 lm (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 rm (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 col (- (car (posn-col-row start)) lm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 hs (window-hscroll)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 fc (+ col hs))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 (and (>= col 0) (< (+ col lm rm) w)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 (progn
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 (message "Fill column set to %d (was %d)" fc fill-column)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 (setq fill-column fc)))))))
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
305
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 (defun ruler-mode-mouse-add-tab-stop (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 "Add a tab stop to the graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (if ruler-mode-show-tab-stops
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 m col w lm rm hs ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 lm (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 rm (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 col (- (car (posn-col-row start)) lm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 hs (window-hscroll)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 ts (+ col hs))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (and (>= col 0) (< (+ col lm rm) w)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 (not (member ts tab-stop-list))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 (progn
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 (message "Tab stop set to %d" ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328 (setq tab-stop-list
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329 (sort (cons ts tab-stop-list)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 #'<)))))))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 (defun ruler-mode-mouse-del-tab-stop (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 "Delete tab stop at the graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 (if ruler-mode-show-tab-stops
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 m col w lm rm hs ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 lm (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 rm (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 col (- (car (posn-col-row start)) lm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 hs (window-hscroll)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 ts (+ col hs))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 (and (>= col 0) (< (+ col lm rm) w)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 (member ts tab-stop-list)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 (progn
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 (message "Tab stop at %d deleted" ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 (setq tab-stop-list
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 (delete ts tab-stop-list)))))))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 (defun ruler-mode-toggle-show-tab-stops ()
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 "Toggle showing of tab stops on the ruler."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 (interactive)
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
360 (setq ruler-mode-show-tab-stops (not ruler-mode-show-tab-stops))
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
361 (force-mode-line-update))
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
362
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 (defvar ruler-mode-map
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 (let ((km (make-sparse-keymap)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 (define-key km [header-line down-mouse-1]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 #'ignore)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 (define-key km [header-line down-mouse-3]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 #'ignore)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 (define-key km [header-line down-mouse-2]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 #'ruler-mode-mouse-set-fill-column)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 (define-key km [header-line (shift down-mouse-1)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 #'ruler-mode-mouse-set-left-margin)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 (define-key km [header-line (shift down-mouse-3)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 #'ruler-mode-mouse-set-right-margin)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 (define-key km [header-line (control down-mouse-1)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 #'ruler-mode-mouse-add-tab-stop)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 (define-key km [header-line (control down-mouse-3)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 #'ruler-mode-mouse-del-tab-stop)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 (define-key km [header-line (control down-mouse-2)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 #'ruler-mode-toggle-show-tab-stops)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 km)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 "Keymap for ruler minor mode.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 (defvar ruler-mode-header-line-format-old nil
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 "Hold previous value of `header-line-format'.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 (make-variable-buffer-local 'ruler-mode-header-line-format-old)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 (defconst ruler-mode-header-line-format
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 '(:eval (ruler-mode-ruler))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 "`header-line-format' used in ruler mode.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 ;;;###autoload
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 (define-minor-mode ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 "Display a ruler in the header line if ARG > 0."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 nil nil
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 ruler-mode-map
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (if ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 (progn
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 ;; When `ruler-mode' is on save previous header line format
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 ;; and install the ruler header line format.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 (setq ruler-mode-header-line-format-old header-line-format
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 header-line-format ruler-mode-header-line-format)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 (add-hook 'post-command-hook ; add local hook
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 #'force-mode-line-update nil t))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 ;; When `ruler-mode' is off restore previous header line format if
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 ;; the current one is the ruler header line format.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 (if (eq header-line-format ruler-mode-header-line-format)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 (setq header-line-format ruler-mode-header-line-format-old))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (remove-hook 'post-command-hook ; remove local hook
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 #'force-mode-line-update t)))
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
412
42706
be541feb06cc Fix typo.
Pavel Janík <Pavel@Janik.cz>
parents: 42020
diff changeset
413 ;; Add ruler-mode to the minor mode menu in the mode line
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 (define-key mode-line-mode-menu [ruler-mode]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 `(menu-item "Ruler" ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 :button (:toggle . ruler-mode)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 (defconst ruler-mode-ruler-help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 "\
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 S-mouse-1/3: set L/R margin, \
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 mouse-2: set fill col, \
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 C-mouse-2: show tabs"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 "Help string shown when mouse pointer is over the ruler.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 `ruler-mode-show-tab-stops' is nil.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (defconst ruler-mode-ruler-help-echo-tab
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 "\
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 C-mouse1/3: set/unset tab, \
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 C-mouse-2: hide tabs"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 "Help string shown when mouse pointer is over the ruler.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 `ruler-mode-show-tab-stops' is non-nil.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 (defconst ruler-mode-left-margin-help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 "Left margin %S"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 "Help string shown when mouse is over the left margin area.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (defconst ruler-mode-right-margin-help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 "Right margin %S"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 "Help string shown when mouse is over the right margin area.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440
42020
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
441 (defmacro ruler-mode-left-fringe-cols ()
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
442 "Return the width, measured in columns, of the left fringe area."
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
443 '(round (or (frame-parameter nil 'left-fringe) 0)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
444 (frame-char-width)))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
445
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
446 (defmacro ruler-mode-right-fringe-cols ()
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
447 "Return the width, measured in columns, of the right fringe area."
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
448 '(round (or (frame-parameter nil 'right-fringe) 0)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
449 (frame-char-width)))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
450
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
451 (defmacro ruler-mode-left-scroll-bar-cols ()
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
452 "Return the width, measured in columns, of the left vertical scrollbar."
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
453 '(if (eq (frame-parameter nil 'vertical-scroll-bars) 'left)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
454 (round (or (frame-parameter nil 'scroll-bar-width) 0)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
455 (frame-char-width))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
456 0))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
457
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
458 (defmacro ruler-mode-right-scroll-bar-cols ()
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
459 "Return the width, measured in columns, of the right vertical scrollbar."
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
460 '(if (eq (frame-parameter nil 'vertical-scroll-bars) 'right)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
461 (round (or (frame-parameter nil 'scroll-bar-width) 0)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
462 (frame-char-width))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
463 0))
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
464
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 (defun ruler-mode-ruler ()
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 "Return a string ruler."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 (if ruler-mode
42020
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
468 (let* ((j (+ (ruler-mode-left-fringe-cols)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
469 (ruler-mode-left-scroll-bar-cols)))
42003
a22f2256bce0 (ruler-mode-left-fringe-cols): Variable removed.
Richard M. Stallman <rms@gnu.org>
parents: 41461
diff changeset
470 (w (+ (window-width) j))
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 (m (window-margins))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (l (or (car m) 0))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 (r (or (cdr m) 0))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (o (- (window-hscroll) l j))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 (i 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 (ruler (concat
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 ;; unit graduations
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (make-string w ruler-mode-basic-graduation-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 ;; extra space to fill the header line
42020
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
480 (make-string (+ (ruler-mode-right-fringe-cols)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
481 (ruler-mode-right-scroll-bar-cols))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
482 ?\ )))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
483 c k)
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 ;; Setup default face and help echo.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 (put-text-property 0 (length ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 'face 'ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 (put-text-property 0 (length ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 'help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 (if ruler-mode-show-tab-stops
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 ruler-mode-ruler-help-echo-tab
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 ruler-mode-ruler-help-echo)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 ;; Setup the local map.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496 (put-text-property 0 (length ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 'local-map ruler-mode-map
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 (setq j (+ l j))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 ;; Setup the left margin area.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 i j 'face 'ruler-mode-margins-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 i j 'help-echo (format ruler-mode-left-margin-help-echo l)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 (while (< i j)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 (aset ruler i ruler-mode-margins-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 (setq i (1+ i)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 ;; Setup the ruler area.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513 (setq r (- w r))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
514 (while (< i r)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 (setq j (+ i o))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 (cond
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 ((= (mod j 10) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 (setq c (number-to-string (/ j 10))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 m (length c)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 k i)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 i (1+ i) 'face 'ruler-mode-column-number-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 (while (and (> m 0) (>= k 0))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 (aset ruler k (aref c (setq m (1- m))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 (setq k (1- k)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 )
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 ((= (mod j 5) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 (aset ruler i ruler-mode-inter-graduation-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 )
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 )
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 (setq i (1+ i)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 ;; Setup the right margin area.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 i (length ruler) 'face 'ruler-mode-margins-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 i (length ruler) 'help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 (format ruler-mode-right-margin-help-echo (- w r))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 (while (< i (length ruler))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 (aset ruler i ruler-mode-margins-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544 (setq i (1+ i)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 ;; Show the `fill-column' marker.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 (setq i (- fill-column o))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 (and (>= i 0) (< i r)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549 (aset ruler i ruler-mode-fill-column-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 i (1+ i) 'face 'ruler-mode-fill-column-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 ruler))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 ;; Show the `tab-stop-list' markers.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 (if ruler-mode-show-tab-stops
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 (let ((tsl tab-stop-list) ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 (while tsl
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 (setq ts (car tsl)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 tsl (cdr tsl)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 i (- ts o))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 (and (>= i 0) (< i r)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 (aset ruler i ruler-mode-tab-stop-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 i (1+ i)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 'face (cond
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566 ;; Don't override the fill-column face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 ((eq ts fill-column)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 'ruler-mode-fill-column-face)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 (t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570 'ruler-mode-tab-stop-face))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571 ruler)))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 ;; Show the `current-column' marker.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 (setq i (- (current-column) o))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 (and (>= i 0) (< i r)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 (aset ruler i ruler-mode-current-column-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 i (1+ i) 'face 'ruler-mode-current-column-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 ruler))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581 ruler)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583 (provide 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585 ;; Local Variables:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 ;; coding: iso-latin-1
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587 ;; End:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589 ;;; ruler-mode.el ends here