Mercurial > emacs
annotate lisp/ruler-mode.el @ 111790:c27f24c79b6a
message.el (message-from-style): Fix previous commit.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Thu, 02 Dec 2010 22:25:01 +0000 |
parents | 4de0b34e2c2e |
children | 417b1e4d63cd |
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 | 2 |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
106815 | 4 ;; 2008, 2009, 2010 Free Software Foundation, Inc. |
39731 | 5 |
6 ;; Author: David Ponce <david@dponce.com> | |
7 ;; Maintainer: David Ponce <david@dponce.com> | |
8 ;; Created: 24 Mar 2001 | |
51389 | 9 ;; Version: 1.6 |
47183
865837df3fe7
(defgroup ruler-mode): Use `convenience' as parent.
Richard M. Stallman <rms@gnu.org>
parents:
45255
diff
changeset
|
10 ;; Keywords: convenience |
39731 | 11 |
12 ;; This file is part of GNU Emacs. | |
13 | |
94693
9276b559433c
Standardize permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
14 ;; GNU Emacs is free software: you can redistribute it and/or modify |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; it under the terms of the GNU General Public License as published by |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
16 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
17 ;; (at your option) any later version. |
39731 | 18 |
94693
9276b559433c
Standardize permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
19 ;; GNU Emacs is distributed in the hope that it will be useful, |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; GNU General Public License for more details. |
39731 | 23 |
24 ;; You should have received a copy of the GNU General Public License | |
94693
9276b559433c
Standardize permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
39731 | 26 |
27 ;;; Commentary: | |
28 | |
29 ;; This library provides a minor mode to display a ruler in the header | |
78041
5872a3a471bd
(ruler-mode): Prevent clobbering the original `header-line-format'
Juanma Barranquero <lekktu@gmail.com>
parents:
75229
diff
changeset
|
30 ;; line. It works from Emacs 21 onwards. |
39731 | 31 ;; |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
32 ;; You can use the mouse to change the `fill-column' `comment-column', |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
33 ;; `goal-column', `window-margins' and `tab-stop-list' settings: |
39731 | 34 ;; |
51389 | 35 ;; [header-line (shift down-mouse-1)] set left margin end to the ruler |
39731 | 36 ;; graduation where the mouse pointer is on. |
37 ;; | |
51389 | 38 ;; [header-line (shift down-mouse-3)] set right margin beginning to |
39 ;; the ruler graduation where the mouse pointer is on. | |
39731 | 40 ;; |
51389 | 41 ;; [header-line down-mouse-2] Drag the `fill-column', `comment-column' |
42 ;; or `goal-column' to a ruler graduation. | |
39731 | 43 ;; |
44 ;; [header-line (control down-mouse-1)] add a tab stop to the ruler | |
45 ;; graduation where the mouse pointer is on. | |
46 ;; | |
47 ;; [header-line (control down-mouse-3)] remove the tab stop at the | |
48 ;; ruler graduation where the mouse pointer is on. | |
49 ;; | |
50 ;; [header-line (control down-mouse-2)] or M-x | |
51 ;; `ruler-mode-toggle-show-tab-stops' toggle showing and visually | |
52 ;; editing `tab-stop-list' setting. The `ruler-mode-show-tab-stops' | |
53 ;; option controls if the ruler shows tab stops by default. | |
54 ;; | |
55 ;; In the ruler the character `ruler-mode-current-column-char' shows | |
56 ;; the `current-column' location, `ruler-mode-fill-column-char' shows | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
57 ;; the `fill-column' location, `ruler-mode-comment-column-char' shows |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
58 ;; the `comment-column' location, `ruler-mode-goal-column-char' shows |
51389 | 59 ;; the `goal-column' and `ruler-mode-tab-stop-char' shows tab stop |
60 ;; locations. Graduations in `window-margins' and `window-fringes' | |
61 ;; areas are shown with a different foreground color. | |
39731 | 62 ;; |
63 ;; It is also possible to customize the following characters: | |
64 ;; | |
65 ;; - `ruler-mode-basic-graduation-char' character used for basic | |
66 ;; graduations ('.' by default). | |
67 ;; - `ruler-mode-inter-graduation-char' character used for | |
68 ;; intermediate graduations ('!' by default). | |
69 ;; | |
70 ;; The following faces are customizable: | |
71 ;; | |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
72 ;; - `ruler-mode-default' the ruler default face. |
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
73 ;; - `ruler-mode-fill-column' the face used to highlight the |
39731 | 74 ;; `fill-column' character. |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
75 ;; - `ruler-mode-comment-column' the face used to highlight the |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
76 ;; `comment-column' character. |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
77 ;; - `ruler-mode-goal-column' the face used to highlight the |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
78 ;; `goal-column' character. |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
79 ;; - `ruler-mode-current-column' the face used to highlight the |
39731 | 80 ;; `current-column' character. |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
81 ;; - `ruler-mode-tab-stop' the face used to highlight tab stop |
39731 | 82 ;; characters. |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
83 ;; - `ruler-mode-margins' the face used to highlight graduations |
51389 | 84 ;; in the `window-margins' areas. |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
85 ;; - `ruler-mode-fringes' the face used to highlight graduations |
51389 | 86 ;; in the `window-fringes' areas. |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
87 ;; - `ruler-mode-column-number' the face used to highlight the |
51389 | 88 ;; numbered graduations. |
39731 | 89 ;; |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
90 ;; `ruler-mode-default' inherits from the built-in `default' face. |
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
91 ;; All `ruler-mode' faces inherit from `ruler-mode-default'. |
39731 | 92 ;; |
93 ;; WARNING: To keep ruler graduations aligned on text columns it is | |
94 ;; important to use the same font family and size for ruler and text | |
95 ;; areas. | |
54399
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52889
diff
changeset
|
96 ;; |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
97 ;; You can override the ruler format by defining an appropriate |
54399
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52889
diff
changeset
|
98 ;; function as the buffer-local value of `ruler-mode-ruler-function'. |
39731 | 99 |
100 ;; Installation | |
101 ;; | |
102 ;; To automatically display the ruler in specific major modes use: | |
103 ;; | |
104 ;; (add-hook '<major-mode>-hook 'ruler-mode) | |
105 ;; | |
106 | |
107 ;;; History: | |
108 ;; | |
41461 | 109 |
39731 | 110 ;;; Code: |
111 (eval-when-compile | |
112 (require 'wid-edit)) | |
54399
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52889
diff
changeset
|
113 (require 'scroll-bar) |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52889
diff
changeset
|
114 (require 'fringe) |
39731 | 115 |
116 (defgroup ruler-mode nil | |
117 "Display a ruler in the header line." | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
54440
diff
changeset
|
118 :version "22.1" |
47183
865837df3fe7
(defgroup ruler-mode): Use `convenience' as parent.
Richard M. Stallman <rms@gnu.org>
parents:
45255
diff
changeset
|
119 :group 'convenience) |
39731 | 120 |
121 (defcustom ruler-mode-show-tab-stops nil | |
100171 | 122 "If non-nil the ruler shows tab stop positions. |
39731 | 123 Also allowing to visually change `tab-stop-list' setting using |
124 <C-down-mouse-1> and <C-down-mouse-3> on the ruler to respectively add | |
125 or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or | |
126 <C-down-mouse-2> on the ruler toggles showing/editing of tab stops." | |
127 :group 'ruler-mode | |
128 :type 'boolean) | |
129 | |
130 ;; IMPORTANT: This function must be defined before the following | |
131 ;; defcustoms because it is used in their :validate clause. | |
132 (defun ruler-mode-character-validate (widget) | |
133 "Ensure WIDGET value is a valid character value." | |
134 (save-excursion | |
135 (let ((value (widget-value widget))) | |
88997
71bcf52caa3b
(ruler-mode-character-validate): Use characterp.
Dave Love <fx@gnu.org>
parents:
42836
diff
changeset
|
136 (unless (characterp value) |
39731 | 137 (widget-put widget :error |
138 (format "Invalid character value: %S" value)) | |
139 widget)))) | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
140 |
52430 | 141 (defcustom ruler-mode-fill-column-char (if (char-displayable-p ?¶) |
39731 | 142 ?\¶ |
143 ?\|) | |
100171 | 144 "Character used at the `fill-column' location." |
39731 | 145 :group 'ruler-mode |
146 :type '(choice | |
147 (character :tag "Character") | |
148 (integer :tag "Integer char value" | |
149 :validate ruler-mode-character-validate))) | |
150 | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
151 (defcustom ruler-mode-comment-column-char ?\# |
100171 | 152 "Character used at the `comment-column' location." |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
153 :group 'ruler-mode |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
154 :type '(choice |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
155 (character :tag "Character") |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
156 (integer :tag "Integer char value" |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
157 :validate ruler-mode-character-validate))) |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
158 |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
159 (defcustom ruler-mode-goal-column-char ?G |
100171 | 160 "Character used at the `goal-column' location." |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
161 :group 'ruler-mode |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
162 :type '(choice |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
163 (character :tag "Character") |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
164 (integer :tag "Integer char value" |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
165 :validate ruler-mode-character-validate))) |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
166 |
52430 | 167 (defcustom ruler-mode-current-column-char (if (char-displayable-p ?¦) |
39731 | 168 ?\¦ |
169 ?\@) | |
100171 | 170 "Character used at the `current-column' location." |
39731 | 171 :group 'ruler-mode |
172 :type '(choice | |
173 (character :tag "Character") | |
174 (integer :tag "Integer char value" | |
175 :validate ruler-mode-character-validate))) | |
176 | |
177 (defcustom ruler-mode-tab-stop-char ?\T | |
100171 | 178 "Character used at `tab-stop-list' locations." |
39731 | 179 :group 'ruler-mode |
180 :type '(choice | |
181 (character :tag "Character") | |
182 (integer :tag "Integer char value" | |
183 :validate ruler-mode-character-validate))) | |
184 | |
185 (defcustom ruler-mode-basic-graduation-char ?\. | |
100171 | 186 "Character used for basic graduations." |
39731 | 187 :group 'ruler-mode |
188 :type '(choice | |
189 (character :tag "Character") | |
190 (integer :tag "Integer char value" | |
191 :validate ruler-mode-character-validate))) | |
192 | |
193 (defcustom ruler-mode-inter-graduation-char ?\! | |
100171 | 194 "Character used for intermediate graduations." |
39731 | 195 :group 'ruler-mode |
196 :type '(choice | |
197 (character :tag "Character") | |
198 (integer :tag "Integer char value" | |
199 :validate ruler-mode-character-validate))) | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
200 |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
201 (defcustom ruler-mode-set-goal-column-ding-flag t |
100171 | 202 "Non-nil means do `ding' when `goal-column' is set." |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
203 :group 'ruler-mode |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
204 :type 'boolean) |
41461 | 205 |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
206 (defface ruler-mode-default |
39731 | 207 '((((type tty)) |
208 (:inherit default | |
209 :background "grey64" | |
210 :foreground "grey50" | |
211 )) | |
212 (t | |
213 (:inherit default | |
214 :background "grey76" | |
215 :foreground "grey64" | |
216 :box (:color "grey76" | |
217 :line-width 1 | |
218 :style released-button) | |
219 ))) | |
220 "Default face used by the ruler." | |
221 :group 'ruler-mode) | |
222 | |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
223 (defface ruler-mode-pad |
51389 | 224 '((((type tty)) |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
225 (:inherit ruler-mode-default |
51389 | 226 :background "grey50" |
227 )) | |
228 (t | |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
229 (:inherit ruler-mode-default |
51389 | 230 :background "grey64" |
231 ))) | |
232 "Face used to pad inactive ruler areas." | |
233 :group 'ruler-mode) | |
234 | |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
235 (defface ruler-mode-margins |
51389 | 236 '((t |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
237 (:inherit ruler-mode-default |
51389 | 238 :foreground "white" |
239 ))) | |
240 "Face used to highlight margin areas." | |
241 :group 'ruler-mode) | |
242 | |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
243 (defface ruler-mode-fringes |
51389 | 244 '((t |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
245 (:inherit ruler-mode-default |
51389 | 246 :foreground "green" |
247 ))) | |
248 "Face used to highlight fringes areas." | |
249 :group 'ruler-mode) | |
250 | |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
251 (defface ruler-mode-column-number |
39731 | 252 '((t |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
253 (:inherit ruler-mode-default |
39731 | 254 :foreground "black" |
255 ))) | |
256 "Face used to highlight number graduations." | |
257 :group 'ruler-mode) | |
258 | |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
259 (defface ruler-mode-fill-column |
39731 | 260 '((t |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
261 (:inherit ruler-mode-default |
39731 | 262 :foreground "red" |
263 ))) | |
264 "Face used to highlight the fill column character." | |
265 :group 'ruler-mode) | |
266 | |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
267 (defface ruler-mode-comment-column |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
268 '((t |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
269 (:inherit ruler-mode-default |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
270 :foreground "red" |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
271 ))) |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
272 "Face used to highlight the comment column character." |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
273 :group 'ruler-mode) |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
274 |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
275 (defface ruler-mode-goal-column |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
276 '((t |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
277 (:inherit ruler-mode-default |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
278 :foreground "red" |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
279 ))) |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
280 "Face used to highlight the goal column character." |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
281 :group 'ruler-mode) |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
282 |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
283 (defface ruler-mode-tab-stop |
39731 | 284 '((t |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
285 (:inherit ruler-mode-default |
39731 | 286 :foreground "steelblue" |
287 ))) | |
288 "Face used to highlight tab stop characters." | |
289 :group 'ruler-mode) | |
290 | |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
291 (defface ruler-mode-current-column |
39731 | 292 '((t |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
293 (:inherit ruler-mode-default |
39731 | 294 :weight bold |
295 :foreground "yellow" | |
296 ))) | |
297 "Face used to highlight the `current-column' character." | |
298 :group 'ruler-mode) | |
41461 | 299 |
51389 | 300 |
301 (defsubst ruler-mode-full-window-width () | |
302 "Return the full width of the selected window." | |
303 (let ((edges (window-edges))) | |
304 (- (nth 2 edges) (nth 0 edges)))) | |
305 | |
306 (defsubst ruler-mode-window-col (n) | |
307 "Return a column number relative to the selected window. | |
308 N is a column number relative to selected frame." | |
309 (- n | |
310 (car (window-edges)) | |
311 (or (car (window-margins)) 0) | |
54401
7f6dab15e141
2004-03-15 David Ponce <david@dponce.com>
Masatake YAMATO <jet@gyve.org>
parents:
54399
diff
changeset
|
312 (fringe-columns 'left) |
7f6dab15e141
2004-03-15 David Ponce <david@dponce.com>
Masatake YAMATO <jet@gyve.org>
parents:
54399
diff
changeset
|
313 (scroll-bar-columns 'left))) |
51389 | 314 |
39731 | 315 (defun ruler-mode-mouse-set-left-margin (start-event) |
51389 | 316 "Set left margin end to the graduation where the mouse pointer is on. |
39731 | 317 START-EVENT is the mouse click event." |
318 (interactive "e") | |
319 (let* ((start (event-start start-event)) | |
320 (end (event-end start-event)) | |
51389 | 321 col w lm rm) |
322 (when (eq start end) ;; mouse click | |
323 (save-selected-window | |
324 (select-window (posn-window start)) | |
325 (setq col (- (car (posn-col-row start)) (car (window-edges)) | |
54401
7f6dab15e141
2004-03-15 David Ponce <david@dponce.com>
Masatake YAMATO <jet@gyve.org>
parents:
54399
diff
changeset
|
326 (scroll-bar-columns 'left)) |
51389 | 327 w (- (ruler-mode-full-window-width) |
54401
7f6dab15e141
2004-03-15 David Ponce <david@dponce.com>
Masatake YAMATO <jet@gyve.org>
parents:
54399
diff
changeset
|
328 (scroll-bar-columns 'left) |
7f6dab15e141
2004-03-15 David Ponce <david@dponce.com>
Masatake YAMATO <jet@gyve.org>
parents:
54399
diff
changeset
|
329 (scroll-bar-columns 'right))) |
51389 | 330 (when (and (>= col 0) (< col w)) |
331 (setq lm (window-margins) | |
332 rm (or (cdr lm) 0) | |
333 lm (or (car lm) 0)) | |
334 (message "Left margin set to %d (was %d)" col lm) | |
335 (set-window-margins nil col rm)))))) | |
39731 | 336 |
337 (defun ruler-mode-mouse-set-right-margin (start-event) | |
51389 | 338 "Set right margin beginning to the graduation where the mouse pointer is on. |
39731 | 339 START-EVENT is the mouse click event." |
340 (interactive "e") | |
341 (let* ((start (event-start start-event)) | |
342 (end (event-end start-event)) | |
51389 | 343 col w lm rm) |
344 (when (eq start end) ;; mouse click | |
345 (save-selected-window | |
346 (select-window (posn-window start)) | |
347 (setq col (- (car (posn-col-row start)) (car (window-edges)) | |
54401
7f6dab15e141
2004-03-15 David Ponce <david@dponce.com>
Masatake YAMATO <jet@gyve.org>
parents:
54399
diff
changeset
|
348 (scroll-bar-columns 'left)) |
51389 | 349 w (- (ruler-mode-full-window-width) |
54401
7f6dab15e141
2004-03-15 David Ponce <david@dponce.com>
Masatake YAMATO <jet@gyve.org>
parents:
54399
diff
changeset
|
350 (scroll-bar-columns 'left) |
7f6dab15e141
2004-03-15 David Ponce <david@dponce.com>
Masatake YAMATO <jet@gyve.org>
parents:
54399
diff
changeset
|
351 (scroll-bar-columns 'right))) |
51389 | 352 (when (and (>= col 0) (< col w)) |
353 (setq lm (window-margins) | |
354 rm (or (cdr lm) 0) | |
355 lm (or (car lm) 0) | |
356 col (- w col 1)) | |
357 (message "Right margin set to %d (was %d)" col rm) | |
358 (set-window-margins nil lm col)))))) | |
39731 | 359 |
51389 | 360 (defvar ruler-mode-dragged-symbol nil |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
361 "Column symbol dragged in the ruler. |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
362 That is `fill-column', `comment-column', `goal-column', or nil when |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
363 nothing is dragged.") |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
364 |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
365 (defun ruler-mode-mouse-grab-any-column (start-event) |
51389 | 366 "Drag a column symbol on the ruler. |
367 Start dragging on mouse down event START-EVENT, and update the column | |
368 symbol value with the current value of the ruler graduation while | |
369 dragging. See also the variable `ruler-mode-dragged-symbol'." | |
39731 | 370 (interactive "e") |
51389 | 371 (setq ruler-mode-dragged-symbol nil) |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
372 (let* ((start (event-start start-event)) |
51389 | 373 col newc oldc) |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
374 (save-selected-window |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
375 (select-window (posn-window start)) |
51389 | 376 (setq col (ruler-mode-window-col (car (posn-col-row start))) |
377 newc (+ col (window-hscroll))) | |
378 (and | |
379 (>= col 0) (< col (window-width)) | |
380 (cond | |
381 | |
382 ;; Handle the fill column. | |
383 ((eq newc fill-column) | |
384 (setq oldc fill-column | |
385 ruler-mode-dragged-symbol 'fill-column) | |
386 t) ;; Start dragging | |
387 | |
388 ;; Handle the comment column. | |
389 ((eq newc comment-column) | |
390 (setq oldc comment-column | |
391 ruler-mode-dragged-symbol 'comment-column) | |
392 t) ;; Start dragging | |
393 | |
394 ;; Handle the goal column. | |
395 ;; A. On mouse down on the goal column character on the ruler, | |
396 ;; update the `goal-column' value while dragging. | |
397 ;; B. If `goal-column' is nil, set the goal column where the | |
398 ;; mouse is clicked. | |
399 ;; C. On mouse click on the goal column character on the | |
400 ;; ruler, unset the goal column. | |
401 ((eq newc goal-column) ; A. Drag the goal column. | |
402 (setq oldc goal-column | |
403 ruler-mode-dragged-symbol 'goal-column) | |
404 t) ;; Start dragging | |
405 | |
406 ((null goal-column) ; B. Set the goal column. | |
407 (setq oldc goal-column | |
408 goal-column newc) | |
409 ;; mouse-2 coming AFTER drag-mouse-2 invokes `ding'. This | |
410 ;; `ding' flushes the next messages about setting goal | |
411 ;; column. So here I force fetch the event(mouse-2) and | |
412 ;; throw away. | |
413 (read-event) | |
414 ;; Ding BEFORE `message' is OK. | |
415 (when ruler-mode-set-goal-column-ding-flag | |
416 (ding)) | |
417 (message "Goal column set to %d (click on %s again to unset it)" | |
418 newc | |
419 (propertize (char-to-string ruler-mode-goal-column-char) | |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
420 'face 'ruler-mode-goal-column)) |
51389 | 421 nil) ;; Don't start dragging. |
422 ) | |
423 (if (eq 'click (ruler-mode-mouse-drag-any-column-iteration | |
424 (posn-window start))) | |
425 (when (eq 'goal-column ruler-mode-dragged-symbol) | |
426 ;; C. Unset the goal column. | |
427 (set-goal-column t)) | |
428 ;; At end of dragging, report the updated column symbol. | |
429 (message "%s is set to %d (was %d)" | |
430 ruler-mode-dragged-symbol | |
431 (symbol-value ruler-mode-dragged-symbol) | |
432 oldc)))))) | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
433 |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
434 (defun ruler-mode-mouse-drag-any-column-iteration (window) |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
435 "Update the ruler while dragging the mouse. |
51389 | 436 WINDOW is the window where occurred the last down-mouse event. |
437 Return the symbol `drag' if the mouse has been dragged, or `click' if | |
438 the mouse has been clicked." | |
439 (let ((drags 0) | |
440 event) | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
441 (track-mouse |
51389 | 442 (while (mouse-movement-p (setq event (read-event))) |
443 (setq drags (1+ drags)) | |
444 (when (eq window (posn-window (event-end event))) | |
445 (ruler-mode-mouse-drag-any-column event) | |
446 (force-mode-line-update)))) | |
447 (if (and (zerop drags) (eq 'click (car (event-modifiers event)))) | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
448 'click |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
449 'drag))) |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
450 |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
451 (defun ruler-mode-mouse-drag-any-column (start-event) |
51389 | 452 "Update the value of the symbol dragged on the ruler. |
453 Called on each mouse motion event START-EVENT." | |
39731 | 454 (let* ((start (event-start start-event)) |
455 (end (event-end start-event)) | |
51389 | 456 col newc) |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
457 (save-selected-window |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
458 (select-window (posn-window start)) |
51389 | 459 (setq col (ruler-mode-window-col (car (posn-col-row end))) |
460 newc (+ col (window-hscroll))) | |
461 (when (and (>= col 0) (< col (window-width))) | |
462 (set ruler-mode-dragged-symbol newc))))) | |
41461 | 463 |
39731 | 464 (defun ruler-mode-mouse-add-tab-stop (start-event) |
465 "Add a tab stop to the graduation where the mouse pointer is on. | |
466 START-EVENT is the mouse click event." | |
467 (interactive "e") | |
51389 | 468 (when ruler-mode-show-tab-stops |
469 (let* ((start (event-start start-event)) | |
470 (end (event-end start-event)) | |
471 col ts) | |
472 (when (eq start end) ;; mouse click | |
473 (save-selected-window | |
474 (select-window (posn-window start)) | |
475 (setq col (ruler-mode-window-col (car (posn-col-row start))) | |
476 ts (+ col (window-hscroll))) | |
477 (and (>= col 0) (< col (window-width)) | |
478 (not (member ts tab-stop-list)) | |
479 (progn | |
480 (message "Tab stop set to %d" ts) | |
481 (setq tab-stop-list (sort (cons ts tab-stop-list) | |
482 #'<))))))))) | |
39731 | 483 |
484 (defun ruler-mode-mouse-del-tab-stop (start-event) | |
485 "Delete tab stop at the graduation where the mouse pointer is on. | |
486 START-EVENT is the mouse click event." | |
487 (interactive "e") | |
51389 | 488 (when ruler-mode-show-tab-stops |
489 (let* ((start (event-start start-event)) | |
490 (end (event-end start-event)) | |
491 col ts) | |
492 (when (eq start end) ;; mouse click | |
493 (save-selected-window | |
494 (select-window (posn-window start)) | |
495 (setq col (ruler-mode-window-col (car (posn-col-row start))) | |
496 ts (+ col (window-hscroll))) | |
497 (and (>= col 0) (< col (window-width)) | |
498 (member ts tab-stop-list) | |
499 (progn | |
500 (message "Tab stop at %d deleted" ts) | |
501 (setq tab-stop-list (delete ts tab-stop-list))))))))) | |
39731 | 502 |
503 (defun ruler-mode-toggle-show-tab-stops () | |
504 "Toggle showing of tab stops on the ruler." | |
505 (interactive) | |
41461 | 506 (setq ruler-mode-show-tab-stops (not ruler-mode-show-tab-stops)) |
507 (force-mode-line-update)) | |
508 | |
39731 | 509 (defvar ruler-mode-map |
510 (let ((km (make-sparse-keymap))) | |
511 (define-key km [header-line down-mouse-1] | |
512 #'ignore) | |
513 (define-key km [header-line down-mouse-3] | |
514 #'ignore) | |
515 (define-key km [header-line down-mouse-2] | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
516 #'ruler-mode-mouse-grab-any-column) |
39731 | 517 (define-key km [header-line (shift down-mouse-1)] |
518 #'ruler-mode-mouse-set-left-margin) | |
519 (define-key km [header-line (shift down-mouse-3)] | |
520 #'ruler-mode-mouse-set-right-margin) | |
521 (define-key km [header-line (control down-mouse-1)] | |
522 #'ruler-mode-mouse-add-tab-stop) | |
523 (define-key km [header-line (control down-mouse-3)] | |
524 #'ruler-mode-mouse-del-tab-stop) | |
525 (define-key km [header-line (control down-mouse-2)] | |
526 #'ruler-mode-toggle-show-tab-stops) | |
73777
461d1ed79b75
(ruler-mode-map): Add bindings for up-events so that they aren't undefined.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
527 (define-key km [header-line (shift mouse-1)] |
461d1ed79b75
(ruler-mode-map): Add bindings for up-events so that they aren't undefined.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
528 'ignore) |
461d1ed79b75
(ruler-mode-map): Add bindings for up-events so that they aren't undefined.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
529 (define-key km [header-line (shift mouse-3)] |
461d1ed79b75
(ruler-mode-map): Add bindings for up-events so that they aren't undefined.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
530 'ignore) |
461d1ed79b75
(ruler-mode-map): Add bindings for up-events so that they aren't undefined.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
531 (define-key km [header-line (control mouse-1)] |
461d1ed79b75
(ruler-mode-map): Add bindings for up-events so that they aren't undefined.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
532 'ignore) |
461d1ed79b75
(ruler-mode-map): Add bindings for up-events so that they aren't undefined.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
533 (define-key km [header-line (control mouse-3)] |
461d1ed79b75
(ruler-mode-map): Add bindings for up-events so that they aren't undefined.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
534 'ignore) |
461d1ed79b75
(ruler-mode-map): Add bindings for up-events so that they aren't undefined.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
535 (define-key km [header-line (control mouse-2)] |
461d1ed79b75
(ruler-mode-map): Add bindings for up-events so that they aren't undefined.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
536 'ignore) |
39731 | 537 km) |
538 "Keymap for ruler minor mode.") | |
539 | |
540 (defvar ruler-mode-header-line-format-old nil | |
541 "Hold previous value of `header-line-format'.") | |
542 | |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
543 (defvar ruler-mode-ruler-function 'ruler-mode-ruler |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
544 "Function to call to return ruler header line format. |
54399
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52889
diff
changeset
|
545 This variable is expected to be made buffer-local by modes.") |
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52889
diff
changeset
|
546 |
39731 | 547 (defconst ruler-mode-header-line-format |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
548 '(:eval (funcall ruler-mode-ruler-function)) |
54399
ad02f6299e9a
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
52889
diff
changeset
|
549 "`header-line-format' used in ruler mode. |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
550 Call `ruler-mode-ruler-function' to compute the ruler value.") |
39731 | 551 |
552 ;;;###autoload | |
109084
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
553 (defvar ruler-mode nil |
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
554 "Non-nil if Ruler mode is enabled. |
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
555 Use the command `ruler-mode' to change this variable.") |
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
556 (make-variable-buffer-local 'ruler-mode) |
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
557 |
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
558 (defun ruler--save-header-line-format () |
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
559 "Install the header line format for Ruler mode. |
109090
4de0b34e2c2e
* ruler-mode.el (ruler--save-header-line-format): Fix typos.
Chong Yidong <cyd@stupidchicken.com>
parents:
109084
diff
changeset
|
560 Unless Ruler mode is already enabled, save the old header line |
109084
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
561 format first." |
109090
4de0b34e2c2e
* ruler-mode.el (ruler--save-header-line-format): Fix typos.
Chong Yidong <cyd@stupidchicken.com>
parents:
109084
diff
changeset
|
562 (when (and (not ruler-mode) |
4de0b34e2c2e
* ruler-mode.el (ruler--save-header-line-format): Fix typos.
Chong Yidong <cyd@stupidchicken.com>
parents:
109084
diff
changeset
|
563 (local-variable-p 'header-line-format) |
4de0b34e2c2e
* ruler-mode.el (ruler--save-header-line-format): Fix typos.
Chong Yidong <cyd@stupidchicken.com>
parents:
109084
diff
changeset
|
564 (not (local-variable-p 'ruler-mode-header-line-format-old))) |
4de0b34e2c2e
* ruler-mode.el (ruler--save-header-line-format): Fix typos.
Chong Yidong <cyd@stupidchicken.com>
parents:
109084
diff
changeset
|
565 (set (make-local-variable 'ruler-mode-header-line-format-old) |
4de0b34e2c2e
* ruler-mode.el (ruler--save-header-line-format): Fix typos.
Chong Yidong <cyd@stupidchicken.com>
parents:
109084
diff
changeset
|
566 header-line-format)) |
4de0b34e2c2e
* ruler-mode.el (ruler--save-header-line-format): Fix typos.
Chong Yidong <cyd@stupidchicken.com>
parents:
109084
diff
changeset
|
567 (setq header-line-format ruler-mode-header-line-format)) |
109084
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
568 |
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
569 ;;;###autoload |
39731 | 570 (define-minor-mode ruler-mode |
109084
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
571 "Toggle Ruler mode. |
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
572 In Ruler mode, Emacs displays a ruler in the header line." |
39731 | 573 nil nil |
574 ruler-mode-map | |
575 :group 'ruler-mode | |
109084
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
576 :variable (ruler-mode |
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
577 . (lambda (enable) |
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
578 (when enable |
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
579 (ruler--save-header-line-format)) |
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
580 (setq ruler-mode enable))) |
39731 | 581 (if ruler-mode |
109084
9e474f641740
Don't always set ruler-mode-header-line-format-old (Bug#5370).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
582 (add-hook 'post-command-hook 'force-mode-line-update nil t) |
39731 | 583 ;; When `ruler-mode' is off restore previous header line format if |
584 ;; the current one is the ruler header line format. | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
585 (when (eq header-line-format ruler-mode-header-line-format) |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
586 (kill-local-variable 'header-line-format) |
51389 | 587 (when (local-variable-p 'ruler-mode-header-line-format-old) |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
588 (setq header-line-format ruler-mode-header-line-format-old) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
589 (kill-local-variable 'ruler-mode-header-line-format-old))) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
590 (remove-hook 'post-command-hook 'force-mode-line-update t))) |
41461 | 591 |
42706 | 592 ;; Add ruler-mode to the minor mode menu in the mode line |
39731 | 593 (define-key mode-line-mode-menu [ruler-mode] |
594 `(menu-item "Ruler" ruler-mode | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
595 :button (:toggle . ruler-mode))) |
39731 | 596 |
597 (defconst ruler-mode-ruler-help-echo | |
598 "\ | |
599 S-mouse-1/3: set L/R margin, \ | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
600 mouse-2: set goal column, \ |
39731 | 601 C-mouse-2: show tabs" |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
602 "Help string shown when mouse is over the ruler. |
39731 | 603 `ruler-mode-show-tab-stops' is nil.") |
604 | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
605 (defconst ruler-mode-ruler-help-echo-when-goal-column |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
606 "\ |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
607 S-mouse-1/3: set L/R margin, \ |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
608 C-mouse-2: show tabs" |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
609 "Help string shown when mouse is over the ruler. |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
610 `goal-column' is set and `ruler-mode-show-tab-stops' is nil.") |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
611 |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
612 (defconst ruler-mode-ruler-help-echo-when-tab-stops |
39731 | 613 "\ |
614 C-mouse1/3: set/unset tab, \ | |
615 C-mouse-2: hide tabs" | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
616 "Help string shown when mouse is over the ruler. |
39731 | 617 `ruler-mode-show-tab-stops' is non-nil.") |
618 | |
49195
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
619 (defconst ruler-mode-fill-column-help-echo |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
620 "drag-mouse-2: set fill column" |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
621 "Help string shown when mouse is on the fill column character.") |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
622 |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
623 (defconst ruler-mode-comment-column-help-echo |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
624 "drag-mouse-2: set comment column" |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
625 "Help string shown when mouse is on the comment column character.") |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
626 |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
627 (defconst ruler-mode-goal-column-help-echo |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
628 "\ |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
629 drag-mouse-2: set goal column, \ |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
630 mouse-2: unset goal column" |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
631 "Help string shown when mouse is on the goal column character.") |
c297d31ef382
(ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents:
47425
diff
changeset
|
632 |
51389 | 633 (defconst ruler-mode-margin-help-echo |
634 "%s margin %S" | |
635 "Help string shown when mouse is over a margin area.") | |
42020
6e891121e1cc
(ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents:
42003
diff
changeset
|
636 |
51389 | 637 (defconst ruler-mode-fringe-help-echo |
638 "%s fringe %S" | |
639 "Help string shown when mouse is over a fringe area.") | |
52889
615ebe291578
(ruler-mode-left-fringe-cols): Add new optional
Richard M. Stallman <rms@gnu.org>
parents:
52430
diff
changeset
|
640 |
615ebe291578
(ruler-mode-left-fringe-cols): Add new optional
Richard M. Stallman <rms@gnu.org>
parents:
52430
diff
changeset
|
641 (defsubst ruler-mode-space (width &rest props) |
615ebe291578
(ruler-mode-left-fringe-cols): Add new optional
Richard M. Stallman <rms@gnu.org>
parents:
52430
diff
changeset
|
642 "Return a single space string of WIDTH times the normal character width. |
615ebe291578
(ruler-mode-left-fringe-cols): Add new optional
Richard M. Stallman <rms@gnu.org>
parents:
52430
diff
changeset
|
643 Optional argument PROPS specifies other text properties to apply." |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
644 (apply 'propertize " " 'display (list 'space :width width) props)) |
41461 | 645 |
39731 | 646 (defun ruler-mode-ruler () |
75229
26181d6e6a87
(ruler-mode-ruler): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
73777
diff
changeset
|
647 "Compute and return a header line ruler." |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
648 (let* ((w (window-width)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
649 (m (window-margins)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
650 (f (window-fringes)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
651 (i 0) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
652 (j (window-hscroll)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
653 ;; Setup the scrollbar, fringes, and margins areas. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
654 (lf (ruler-mode-space |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
655 'left-fringe |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
656 'face 'ruler-mode-fringes |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
657 'help-echo (format ruler-mode-fringe-help-echo |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
658 "Left" (or (car f) 0)))) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
659 (rf (ruler-mode-space |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
660 'right-fringe |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
661 'face 'ruler-mode-fringes |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
662 'help-echo (format ruler-mode-fringe-help-echo |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
663 "Right" (or (cadr f) 0)))) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
664 (lm (ruler-mode-space |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
665 'left-margin |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
666 'face 'ruler-mode-margins |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
667 'help-echo (format ruler-mode-margin-help-echo |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
668 "Left" (or (car m) 0)))) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
669 (rm (ruler-mode-space |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
670 'right-margin |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
671 'face 'ruler-mode-margins |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
672 'help-echo (format ruler-mode-margin-help-echo |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
673 "Right" (or (cdr m) 0)))) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
674 (sb (ruler-mode-space |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
675 'scroll-bar |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
676 'face 'ruler-mode-pad)) |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
677 ;; Remember the scrollbar vertical type. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
678 (sbvt (car (window-current-scroll-bars))) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
679 ;; Create an "clean" ruler. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
680 (ruler |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
681 (propertize |
100171 | 682 (string-to-multibyte |
90660
242b6dccacc1
(ruler-mode-ruler): Make the string `ruler'
Kenichi Handa <handa@m17n.org>
parents:
90650
diff
changeset
|
683 (make-string w ruler-mode-basic-graduation-char)) |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
684 'face 'ruler-mode-default |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
685 'local-map ruler-mode-map |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
686 'help-echo (cond |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
687 (ruler-mode-show-tab-stops |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
688 ruler-mode-ruler-help-echo-when-tab-stops) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
689 (goal-column |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
690 ruler-mode-ruler-help-echo-when-goal-column) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
691 (ruler-mode-ruler-help-echo)))) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
692 k c) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
693 ;; Setup the active area. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
694 (while (< i w) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
695 ;; Graduations. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
696 (cond |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
697 ;; Show a number graduation. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
698 ((= (mod j 10) 0) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
699 (setq c (number-to-string (/ j 10)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
700 m (length c) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
701 k i) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
702 (put-text-property |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
703 i (1+ i) 'face 'ruler-mode-column-number |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
704 ruler) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
705 (while (and (> m 0) (>= k 0)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
706 (aset ruler k (aref c (setq m (1- m)))) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
707 (setq k (1- k)))) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
708 ;; Show an intermediate graduation. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
709 ((= (mod j 5) 0) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
710 (aset ruler i ruler-mode-inter-graduation-char))) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
711 ;; Special columns. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
712 (cond |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
713 ;; Show the `current-column' marker. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
714 ((= j (current-column)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
715 (aset ruler i ruler-mode-current-column-char) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
716 (put-text-property |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
717 i (1+ i) 'face 'ruler-mode-current-column |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
718 ruler)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
719 ;; Show the `goal-column' marker. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
720 ((and goal-column (= j goal-column)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
721 (aset ruler i ruler-mode-goal-column-char) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
722 (put-text-property |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
723 i (1+ i) 'face 'ruler-mode-goal-column |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
724 ruler) |
62651
8d965863dd8c
Supprot mouse-face on mode-line.
Masatake YAMATO <jet@gyve.org>
parents:
59996
diff
changeset
|
725 (put-text-property |
8d965863dd8c
Supprot mouse-face on mode-line.
Masatake YAMATO <jet@gyve.org>
parents:
59996
diff
changeset
|
726 i (1+ i) 'mouse-face 'mode-line-highlight |
8d965863dd8c
Supprot mouse-face on mode-line.
Masatake YAMATO <jet@gyve.org>
parents:
59996
diff
changeset
|
727 ruler) |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
728 (put-text-property |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
729 i (1+ i) 'help-echo ruler-mode-goal-column-help-echo |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
730 ruler)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
731 ;; Show the `comment-column' marker. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
732 ((= j comment-column) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
733 (aset ruler i ruler-mode-comment-column-char) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
734 (put-text-property |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
735 i (1+ i) 'face 'ruler-mode-comment-column |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
736 ruler) |
62651
8d965863dd8c
Supprot mouse-face on mode-line.
Masatake YAMATO <jet@gyve.org>
parents:
59996
diff
changeset
|
737 (put-text-property |
8d965863dd8c
Supprot mouse-face on mode-line.
Masatake YAMATO <jet@gyve.org>
parents:
59996
diff
changeset
|
738 i (1+ i) 'mouse-face 'mode-line-highlight |
8d965863dd8c
Supprot mouse-face on mode-line.
Masatake YAMATO <jet@gyve.org>
parents:
59996
diff
changeset
|
739 ruler) |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
740 (put-text-property |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
741 i (1+ i) 'help-echo ruler-mode-comment-column-help-echo |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
742 ruler)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
743 ;; Show the `fill-column' marker. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
744 ((= j fill-column) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
745 (aset ruler i ruler-mode-fill-column-char) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
746 (put-text-property |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
747 i (1+ i) 'face 'ruler-mode-fill-column |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
748 ruler) |
62651
8d965863dd8c
Supprot mouse-face on mode-line.
Masatake YAMATO <jet@gyve.org>
parents:
59996
diff
changeset
|
749 (put-text-property |
8d965863dd8c
Supprot mouse-face on mode-line.
Masatake YAMATO <jet@gyve.org>
parents:
59996
diff
changeset
|
750 i (1+ i) 'mouse-face 'mode-line-highlight |
8d965863dd8c
Supprot mouse-face on mode-line.
Masatake YAMATO <jet@gyve.org>
parents:
59996
diff
changeset
|
751 ruler) |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
752 (put-text-property |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
753 i (1+ i) 'help-echo ruler-mode-fill-column-help-echo |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
754 ruler)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
755 ;; Show the `tab-stop-list' markers. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
756 ((and ruler-mode-show-tab-stops (member j tab-stop-list)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
757 (aset ruler i ruler-mode-tab-stop-char) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
758 (put-text-property |
63201
c1af317747bc
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372
Miles Bader <miles@gnu.org>
parents:
62651
diff
changeset
|
759 i (1+ i) 'face 'ruler-mode-tab-stop |
54440
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
760 ruler))) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
761 (setq i (1+ i) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
762 j (1+ j))) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
763 ;; Return the ruler propertized string. Using list here, |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
764 ;; instead of concat visually separate the different areas. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
765 (if (nth 2 (window-fringes)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
766 ;; fringes outside margins. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
767 (list "" (and (eq 'left sbvt) sb) lf lm |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
768 ruler rm rf (and (eq 'right sbvt) sb)) |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
769 ;; fringes inside margins. |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
770 (list "" (and (eq 'left sbvt) sb) lm lf |
aabf30299e6c
From David Ponce <david@dponce.com>
Kim F. Storm <storm@cua.dk>
parents:
54401
diff
changeset
|
771 ruler rf rm (and (eq 'right sbvt) sb))))) |
39731 | 772 |
773 (provide 'ruler-mode) | |
774 | |
775 ;; Local Variables: | |
776 ;; coding: iso-latin-1 | |
777 ;; End: | |
778 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91327
diff
changeset
|
779 ;; arch-tag: b2f24546-5605-44c4-b67b-c9a4eeba3ee8 |
39731 | 780 ;;; ruler-mode.el ends here |