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