annotate lisp/ruler-mode.el @ 89294:57eceaa28da0

Register devanagari-composable-function in composition-function-table for Devanagari characters.
author Kenichi Handa <handa@m17n.org>
date Thu, 07 Nov 2002 06:29:07 +0000
parents 71bcf52caa3b
children 2f877ed80fa6
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."
42836
c6bcb27e426f (ruler-mode): New keyword. Fix :version.
Pavel Janík <Pavel@Janik.cz>
parents: 42706
diff changeset
108 :version "21.3"
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)))
88997
71bcf52caa3b (ruler-mode-character-validate): Use characterp.
Dave Love <fx@gnu.org>
parents: 42836
diff changeset
126 (unless (characterp value)
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 (widget-put widget :error
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 (format "Invalid character value: %S" value))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 widget))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 (defcustom ruler-mode-fill-column-char (if window-system
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 ?\¶
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 "*Character used at the `fill-column' location."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 :type '(choice
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 (character :tag "Character")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 (integer :tag "Integer char value"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 :validate ruler-mode-character-validate)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 (defcustom ruler-mode-current-column-char (if window-system
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 ?\¦
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 "*Character used at the `current-column' location."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 :type '(choice
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 (character :tag "Character")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 (integer :tag "Integer char value"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 :validate ruler-mode-character-validate)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 (defcustom ruler-mode-tab-stop-char ?\T
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 "*Character used at `tab-stop-list' locations."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 :type '(choice
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 (character :tag "Character")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 (integer :tag "Integer char value"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 :validate ruler-mode-character-validate)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 (defcustom ruler-mode-margins-char ?\
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 "*Character used in margin areas."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 :type '(choice
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 (character :tag "Character")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 (integer :tag "Integer char value"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 :validate ruler-mode-character-validate)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 (defcustom ruler-mode-basic-graduation-char ?\.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 "*Character used for basic graduations."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 :type '(choice
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 (character :tag "Character")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 (integer :tag "Integer char value"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 :validate ruler-mode-character-validate)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 (defcustom ruler-mode-inter-graduation-char ?\!
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 "*Character used for intermediate graduations."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 :type '(choice
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 (character :tag "Character")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 (integer :tag "Integer char value"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 :validate ruler-mode-character-validate)))
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
182
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 (defface ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 '((((type tty))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 (:inherit default
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 :background "grey64"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 :foreground "grey50"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 ))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 (t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 (:inherit default
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 :background "grey76"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 :foreground "grey64"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 :box (:color "grey76"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 :line-width 1
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 :style released-button)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 "Default face used by the ruler."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 (defface ruler-mode-column-number-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 '((t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 :foreground "black"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 "Face used to highlight number graduations."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 (defface ruler-mode-fill-column-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 '((t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 :foreground "red"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 "Face used to highlight the fill column character."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 (defface ruler-mode-tab-stop-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 '((t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 :foreground "steelblue"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 "Face used to highlight tab stop characters."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 (defface ruler-mode-margins-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 '((((type tty))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 :background "grey50"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 ))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 (t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 :background "grey64"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 "Face used to highlight the `window-margins' areas."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 (defface ruler-mode-current-column-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 '((t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 :weight bold
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 :foreground "yellow"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 "Face used to highlight the `current-column' character."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 :group 'ruler-mode)
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
244
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 (defun ruler-mode-mouse-set-left-margin (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 "Set left margin to the graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 w col m lm0 lm rm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 lm0 (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 rm (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 col (car (posn-col-row start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 lm (min (- w rm) col))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 (message "Left margin set to %d (was %d)" lm lm0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (set-window-margins nil lm rm)))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 (defun ruler-mode-mouse-set-right-margin (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 "Set right margin to the graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 m col w lm rm0 rm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 rm0 (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 lm (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 col (car (posn-col-row start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 rm (max 0 (- w col)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 (message "Right margin set to %d (was %d)" rm rm0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 (set-window-margins nil lm rm)))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 (defun ruler-mode-mouse-set-fill-column (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 "Set `fill-column' to the graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 m col w lm rm hs fc)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 lm (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 rm (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 col (- (car (posn-col-row start)) lm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 hs (window-hscroll)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 fc (+ col hs))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 (and (>= col 0) (< (+ col lm rm) w)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 (progn
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 (message "Fill column set to %d (was %d)" fc fill-column)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 (setq fill-column fc)))))))
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
304
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (defun ruler-mode-mouse-add-tab-stop (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 "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
307 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 (if ruler-mode-show-tab-stops
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 m col w lm rm hs ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 lm (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 rm (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 col (- (car (posn-col-row start)) lm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 hs (window-hscroll)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 ts (+ col hs))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 (and (>= col 0) (< (+ col lm rm) w)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (not (member ts tab-stop-list))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 (progn
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 (message "Tab stop set to %d" ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 (setq tab-stop-list
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328 (sort (cons ts tab-stop-list)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329 #'<)))))))))
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 (defun ruler-mode-mouse-del-tab-stop (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 "Delete tab stop at the graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 (if ruler-mode-show-tab-stops
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 m col w lm rm hs ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 lm (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 rm (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 col (- (car (posn-col-row start)) lm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 hs (window-hscroll)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 ts (+ col hs))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 (and (>= col 0) (< (+ col lm rm) w)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 (member ts tab-stop-list)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 (progn
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 (message "Tab stop at %d deleted" ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 (setq tab-stop-list
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 (delete ts tab-stop-list)))))))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 (defun ruler-mode-toggle-show-tab-stops ()
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 "Toggle showing of tab stops on the ruler."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 (interactive)
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
359 (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
360 (force-mode-line-update))
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
361
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 (defvar ruler-mode-map
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 (let ((km (make-sparse-keymap)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 (define-key km [header-line down-mouse-1]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 #'ignore)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 (define-key km [header-line down-mouse-3]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 #'ignore)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 (define-key km [header-line down-mouse-2]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 #'ruler-mode-mouse-set-fill-column)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 (define-key km [header-line (shift down-mouse-1)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 #'ruler-mode-mouse-set-left-margin)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 (define-key km [header-line (shift down-mouse-3)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 #'ruler-mode-mouse-set-right-margin)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 (define-key km [header-line (control down-mouse-1)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 #'ruler-mode-mouse-add-tab-stop)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 (define-key km [header-line (control down-mouse-3)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 #'ruler-mode-mouse-del-tab-stop)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 (define-key km [header-line (control down-mouse-2)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 #'ruler-mode-toggle-show-tab-stops)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 km)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 "Keymap for ruler minor mode.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 (defvar ruler-mode-header-line-format-old nil
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 "Hold previous value of `header-line-format'.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 (make-variable-buffer-local 'ruler-mode-header-line-format-old)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 (defconst ruler-mode-header-line-format
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 '(:eval (ruler-mode-ruler))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 "`header-line-format' used in ruler mode.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 ;;;###autoload
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 (define-minor-mode ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 "Display a ruler in the header line if ARG > 0."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 nil nil
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 ruler-mode-map
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (if ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (progn
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 ;; When `ruler-mode' is on save previous header line format
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 ;; and install the ruler header line format.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 (setq ruler-mode-header-line-format-old header-line-format
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 header-line-format ruler-mode-header-line-format)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 (add-hook 'post-command-hook ; add local hook
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 #'force-mode-line-update nil t))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 ;; When `ruler-mode' is off restore previous header line format if
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 ;; the current one is the ruler header line format.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 (if (eq header-line-format ruler-mode-header-line-format)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 (setq header-line-format ruler-mode-header-line-format-old))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 (remove-hook 'post-command-hook ; remove local hook
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 #'force-mode-line-update t)))
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
411
42706
be541feb06cc Fix typo.
Pavel Janík <Pavel@Janik.cz>
parents: 42020
diff changeset
412 ;; 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
413 (define-key mode-line-mode-menu [ruler-mode]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 `(menu-item "Ruler" ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 :button (:toggle . ruler-mode)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 (defconst ruler-mode-ruler-help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 "\
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 S-mouse-1/3: set L/R margin, \
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 mouse-2: set fill col, \
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 C-mouse-2: show tabs"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 "Help string shown when mouse pointer is over the ruler.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 `ruler-mode-show-tab-stops' is nil.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 (defconst ruler-mode-ruler-help-echo-tab
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 "\
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 C-mouse1/3: set/unset tab, \
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 C-mouse-2: hide tabs"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 "Help string shown when mouse pointer is over the ruler.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 `ruler-mode-show-tab-stops' is non-nil.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 (defconst ruler-mode-left-margin-help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 "Left margin %S"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 "Help string shown when mouse is over the left margin area.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 (defconst ruler-mode-right-margin-help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 "Right margin %S"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 "Help string shown when mouse is over the right margin area.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439
42020
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
440 (defmacro ruler-mode-left-fringe-cols ()
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
441 "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
442 '(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
443 (frame-char-width)))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
444
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
445 (defmacro ruler-mode-right-fringe-cols ()
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
446 "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
447 '(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
448 (frame-char-width)))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
449
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
450 (defmacro ruler-mode-left-scroll-bar-cols ()
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
451 "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
452 '(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
453 (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
454 (frame-char-width))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
455 0))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
456
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
457 (defmacro ruler-mode-right-scroll-bar-cols ()
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
458 "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
459 '(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
460 (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
461 (frame-char-width))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
462 0))
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
463
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 (defun ruler-mode-ruler ()
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 "Return a string ruler."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 (if ruler-mode
42020
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
467 (let* ((j (+ (ruler-mode-left-fringe-cols)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
468 (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
469 (w (+ (window-width) j))
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (m (window-margins))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 (l (or (car m) 0))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (r (or (cdr m) 0))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 (o (- (window-hscroll) l j))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (i 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 (ruler (concat
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 ;; unit graduations
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 (make-string w ruler-mode-basic-graduation-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 ;; 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
479 (make-string (+ (ruler-mode-right-fringe-cols)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
480 (ruler-mode-right-scroll-bar-cols))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
481 ?\ )))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
482 c k)
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 ;; Setup default face and help echo.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (put-text-property 0 (length ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 'face 'ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 (put-text-property 0 (length ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 'help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 (if ruler-mode-show-tab-stops
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 ruler-mode-ruler-help-echo-tab
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 ruler-mode-ruler-help-echo)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494 ;; Setup the local map.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 (put-text-property 0 (length ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496 'local-map ruler-mode-map
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 (setq j (+ l j))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 ;; Setup the left margin area.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 i j 'face 'ruler-mode-margins-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 i j 'help-echo (format ruler-mode-left-margin-help-echo l)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 (while (< i j)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 (aset ruler i ruler-mode-margins-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 (setq i (1+ i)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 ;; Setup the ruler area.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 (setq r (- w r))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513 (while (< i r)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
514 (setq j (+ i o))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 (cond
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 ((= (mod j 10) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 (setq c (number-to-string (/ j 10))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 m (length c)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 k i)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 i (1+ i) 'face 'ruler-mode-column-number-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523 (while (and (> m 0) (>= k 0))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 (aset ruler k (aref c (setq m (1- m))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 (setq k (1- k)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 )
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 ((= (mod j 5) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 (aset ruler i ruler-mode-inter-graduation-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 )
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 (setq i (1+ i)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 ;; Setup the right margin area.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 i (length ruler) 'face 'ruler-mode-margins-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 i (length ruler) 'help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 (format ruler-mode-right-margin-help-echo (- w r))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 (while (< i (length ruler))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 (aset ruler i ruler-mode-margins-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 (setq i (1+ i)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 ;; Show the `fill-column' marker.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (setq i (- fill-column o))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 (and (>= i 0) (< i r)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 (aset ruler i ruler-mode-fill-column-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 i (1+ i) 'face 'ruler-mode-fill-column-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 ruler))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 ;; Show the `tab-stop-list' markers.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 (if ruler-mode-show-tab-stops
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 (let ((tsl tab-stop-list) ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 (while tsl
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 (setq ts (car tsl)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 tsl (cdr tsl)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 i (- ts o))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 (and (>= i 0) (< i r)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 (aset ruler i ruler-mode-tab-stop-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563 i (1+ i)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 'face (cond
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 ;; Don't override the fill-column face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566 ((eq ts fill-column)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 'ruler-mode-fill-column-face)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 (t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 'ruler-mode-tab-stop-face))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570 ruler)))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572 ;; Show the `current-column' marker.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 (setq i (- (current-column) o))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 (and (>= i 0) (< i r)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 (aset ruler i ruler-mode-current-column-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 i (1+ i) 'face 'ruler-mode-current-column-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 ruler))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580 ruler)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 (provide 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584 ;; Local Variables:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585 ;; coding: iso-latin-1
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 ;; End:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588 ;;; ruler-mode.el ends here