comparison lisp/ruler-mode.el @ 49195:c297d31ef382

(ruler-mode-comment-column-char, ruler-mode-goal-column-char) (ruler-mode-set-goal-column-ding-flag, ruler-mode-mouse-current-grab-object): New variables. (ruler-mode-comment-column-face, ruler-mode-goal-column-face): New faces. (ruler-mode-mouse-set-fill-column): Removed. (ruler-mode-mouse-grab-any-column, ruler-mode-mouse-drag-any-column-iteration) (ruler-mode-mouse-drag-any-column): New functions. (ruler-mode-map): [header-line down-mouse-2] Bound to `ruler-mode-mouse-grab-any-column' instead of `ruler-mode-mouse-set-fill-column'. (ruler-mode): Cleanup buffer local variable `header-line-format' if it didn't exist when `ruler-mode' was enabled. (ruler-mode-ruler-help-echo): Updated its value. (ruler-mode-ruler-help-echo-when-goal-column): New help string used when goal-column is already set. (ruler-mode-ruler-help-echo-tab): Renamed to... (ruler-mode-ruler-help-echo-when-tab-stops): New. (ruler-mode-fill-column-help-echo, ruler-mode-comment-column-help-echo) (ruler-mode-goal-column-help-echo): New help strings. (ruler-mode-ruler): Use `ruler-mode-ruler-help-echo-when-goal-column' instead of `ruler-mode-ruler-help-echo' if `goal-column' is set. Show `comment-column' and `goal-column'. Echo the different help string for each *-column characters on the ruler.
author Juanma Barranquero <lekktu@gmail.com>
date Mon, 13 Jan 2003 08:22:50 +0000
parents 525668986222
children e88404e8f2cf
comparison
equal deleted inserted replaced
49194:f3184bd36737 49195:c297d31ef382
1 ;;; ruler-mode.el --- display a ruler in the header line 1 ;;; ruler-mode.el --- display a ruler in the header line
2 2
3 ;; Copyright (C) 2001 Free Software Foundation, Inc. 3 ;; Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
4 4
5 ;; Author: David Ponce <david@dponce.com> 5 ;; Author: David Ponce <david@dponce.com>
6 ;; Maintainer: David Ponce <david@dponce.com> 6 ;; Maintainer: David Ponce <david@dponce.com>
7 ;; Created: 24 Mar 2001 7 ;; Created: 24 Mar 2001
8 ;; Version: 1.4 8 ;; Version: 1.5
9 ;; Keywords: convenience 9 ;; Keywords: convenience
10 10
11 ;; This file is part of GNU Emacs. 11 ;; This file is part of GNU Emacs.
12 12
13 ;; This program is free software; you can redistribute it and/or 13 ;; This program is free software; you can redistribute it and/or
28 ;;; Commentary: 28 ;;; Commentary:
29 29
30 ;; This library provides a minor mode to display a ruler in the header 30 ;; This library provides a minor mode to display a ruler in the header
31 ;; line. It works only on Emacs 21. 31 ;; line. It works only on Emacs 21.
32 ;; 32 ;;
33 ;; You can use the mouse to change the `fill-column', `window-margins' 33 ;; You can use the mouse to change the `fill-column' `comment-column',
34 ;; and `tab-stop-list' settings: 34 ;; `goal-column', `window-margins' and `tab-stop-list' settings:
35 ;; 35 ;;
36 ;; [header-line (shift down-mouse-1)] set left margin to the ruler 36 ;; [header-line (shift down-mouse-1)] set left margin to the ruler
37 ;; graduation where the mouse pointer is on. 37 ;; graduation where the mouse pointer is on.
38 ;; 38 ;;
39 ;; [header-line (shift down-mouse-3)] set right margin to the ruler 39 ;; [header-line (shift down-mouse-3)] set right margin to the ruler
40 ;; graduation where the mouse pointer is on. 40 ;; graduation where the mouse pointer is on.
41 ;; 41 ;;
42 ;; [header-line down-mouse-2] set `fill-column' to the ruler 42 ;; [header-line down-mouse-2] set `fill-column', `comment-column' or
43 ;; graduation where the mouse pointer is on. 43 ;; `goal-column' to the ruler graduation with the mouse dragging.
44 ;; 44 ;;
45 ;; [header-line (control down-mouse-1)] add a tab stop to the ruler 45 ;; [header-line (control down-mouse-1)] add a tab stop to the ruler
46 ;; graduation where the mouse pointer is on. 46 ;; graduation where the mouse pointer is on.
47 ;; 47 ;;
48 ;; [header-line (control down-mouse-3)] remove the tab stop at the 48 ;; [header-line (control down-mouse-3)] remove the tab stop at the
53 ;; editing `tab-stop-list' setting. The `ruler-mode-show-tab-stops' 53 ;; editing `tab-stop-list' setting. The `ruler-mode-show-tab-stops'
54 ;; option controls if the ruler shows tab stops by default. 54 ;; option controls if the ruler shows tab stops by default.
55 ;; 55 ;;
56 ;; In the ruler the character `ruler-mode-current-column-char' shows 56 ;; In the ruler the character `ruler-mode-current-column-char' shows
57 ;; the `current-column' location, `ruler-mode-fill-column-char' shows 57 ;; the `current-column' location, `ruler-mode-fill-column-char' shows
58 ;; the `fill-column' location and `ruler-mode-tab-stop-char' shows tab 58 ;; the `fill-column' location, `ruler-mode-comment-column-char' shows
59 ;; the `comment-column' location, `ruler-mode-goal-column-char' shows
60 ;; the `goal-column' and `ruler-mode-tab-stop-char' shows tab
59 ;; stop locations. `window-margins' areas are shown with a different 61 ;; stop locations. `window-margins' areas are shown with a different
60 ;; background color. 62 ;; background color.
61 ;; 63 ;;
62 ;; It is also possible to customize the following characters: 64 ;; It is also possible to customize the following characters:
63 ;; 65 ;;
71 ;; The following faces are customizable: 73 ;; The following faces are customizable:
72 ;; 74 ;;
73 ;; - `ruler-mode-default-face' the ruler default face. 75 ;; - `ruler-mode-default-face' the ruler default face.
74 ;; - `ruler-mode-fill-column-face' the face used to highlight the 76 ;; - `ruler-mode-fill-column-face' the face used to highlight the
75 ;; `fill-column' character. 77 ;; `fill-column' character.
78 ;; - `ruler-mode-comment-column-face' the face used to highlight the
79 ;; `comment-column' character.
80 ;; - `ruler-mode-goal-column-face' the face used to highlight the
81 ;; `goal-column' character.
76 ;; - `ruler-mode-current-column-face' the face used to highlight the 82 ;; - `ruler-mode-current-column-face' the face used to highlight the
77 ;; `current-column' character. 83 ;; `current-column' character.
78 ;; - `ruler-mode-tab-stop-face' the face used to highlight tab stop 84 ;; - `ruler-mode-tab-stop-face' the face used to highlight tab stop
79 ;; characters. 85 ;; characters.
80 ;; - `ruler-mode-margins-face' the face used to highlight the 86 ;; - `ruler-mode-margins-face' the face used to highlight the
126 (if (char-valid-p value) 132 (if (char-valid-p value)
127 nil 133 nil
128 (widget-put widget :error 134 (widget-put widget :error
129 (format "Invalid character value: %S" value)) 135 (format "Invalid character value: %S" value))
130 widget)))) 136 widget))))
131 137
132 (defcustom ruler-mode-fill-column-char (if window-system 138 (defcustom ruler-mode-fill-column-char (if window-system
133 ?\¶ 139 ?\¶
134 ?\|) 140 ?\|)
135 "*Character used at the `fill-column' location." 141 "*Character used at the `fill-column' location."
136 :group 'ruler-mode 142 :group 'ruler-mode
137 :type '(choice 143 :type '(choice
138 (character :tag "Character") 144 (character :tag "Character")
139 (integer :tag "Integer char value" 145 (integer :tag "Integer char value"
140 :validate ruler-mode-character-validate))) 146 :validate ruler-mode-character-validate)))
141 147
148 (defcustom ruler-mode-comment-column-char ?\#
149 "*Character used at the `comment-column' location."
150 :group 'ruler-mode
151 :type '(choice
152 (character :tag "Character")
153 (integer :tag "Integer char value"
154 :validate ruler-mode-character-validate)))
155
156 (defcustom ruler-mode-goal-column-char ?G
157 "*Character used at the `goal-column' location."
158 :group 'ruler-mode
159 :type '(choice
160 (character :tag "Character")
161 (integer :tag "Integer char value"
162 :validate ruler-mode-character-validate)))
163
142 (defcustom ruler-mode-current-column-char (if window-system 164 (defcustom ruler-mode-current-column-char (if window-system
143 ?\¦ 165 ?\¦
144 ?\@) 166 ?\@)
145 "*Character used at the `current-column' location." 167 "*Character used at the `current-column' location."
146 :group 'ruler-mode 168 :group 'ruler-mode
178 :group 'ruler-mode 200 :group 'ruler-mode
179 :type '(choice 201 :type '(choice
180 (character :tag "Character") 202 (character :tag "Character")
181 (integer :tag "Integer char value" 203 (integer :tag "Integer char value"
182 :validate ruler-mode-character-validate))) 204 :validate ruler-mode-character-validate)))
205
206 (defcustom ruler-mode-set-goal-column-ding-flag t
207 "*Non-nil means do `ding' when `goal-column' is set."
208 :group 'ruler-mode
209 :type 'boolean)
183 210
184 (defface ruler-mode-default-face 211 (defface ruler-mode-default-face
185 '((((type tty)) 212 '((((type tty))
186 (:inherit default 213 (:inherit default
187 :background "grey64" 214 :background "grey64"
210 '((t 237 '((t
211 (:inherit ruler-mode-default-face 238 (:inherit ruler-mode-default-face
212 :foreground "red" 239 :foreground "red"
213 ))) 240 )))
214 "Face used to highlight the fill column character." 241 "Face used to highlight the fill column character."
242 :group 'ruler-mode)
243
244 (defface ruler-mode-comment-column-face
245 '((t
246 (:inherit ruler-mode-default-face
247 :foreground "red"
248 )))
249 "Face used to highlight the comment column character."
250 :group 'ruler-mode)
251
252 (defface ruler-mode-goal-column-face
253 '((t
254 (:inherit ruler-mode-default-face
255 :foreground "red"
256 )))
257 "Face used to highlight the goal column character."
215 :group 'ruler-mode) 258 :group 'ruler-mode)
216 259
217 (defface ruler-mode-tab-stop-face 260 (defface ruler-mode-tab-stop-face
218 '((t 261 '((t
219 (:inherit ruler-mode-default-face 262 (:inherit ruler-mode-default-face
279 w (window-width) 322 w (window-width)
280 rm (max 0 (- w col))) 323 rm (max 0 (- w col)))
281 (message "Right margin set to %d (was %d)" rm rm0) 324 (message "Right margin set to %d (was %d)" rm rm0)
282 (set-window-margins nil lm rm))))) 325 (set-window-margins nil lm rm)))))
283 326
284 (defun ruler-mode-mouse-set-fill-column (start-event) 327 (defvar ruler-mode-mouse-current-grab-object nil
285 "Set `fill-column' to the graduation where the mouse pointer is on. 328 "Column symbol dragged in the ruler.
286 START-EVENT is the mouse click event." 329 That is `fill-column', `comment-column', `goal-column', or nil when
330 nothing is dragged.")
331
332 (defun ruler-mode-mouse-grab-any-column (start-event)
333 "Set a column symbol to the graduation with mouse dragging.
334 See also variable `ruler-mode-mouse-current-grab-object'.
335 START-EVENT is the mouse down event."
287 (interactive "e") 336 (interactive "e")
337 (setq ruler-mode-mouse-current-grab-object nil)
338 (let* ((start (event-start start-event))
339 m col w lm rm hs newc oldc)
340 (save-selected-window
341 (select-window (posn-window start))
342 (setq m (window-margins)
343 lm (or (car m) 0)
344 rm (or (cdr m) 0)
345 col (- (car (posn-col-row start)) lm)
346 w (window-width)
347 hs (window-hscroll)
348 newc (+ col hs))
349 ;;
350 ;; About the ways to handle the goal column:
351 ;; A. update the value of the goal column if goal-column has
352 ;; non-nil value and if the mouse is dragged
353 ;; B. set value to the goal column if goal-column has nil and if
354 ;; the mouse is just clicked, not dragged.
355 ;; C. unset value to the goal column if goal-column has non-nil
356 ;; and mouse is just clicked on goal-column character on the
357 ;; ruler, not dragged.
358 ;;
359 (and (>= col 0) (< (+ col lm rm) w)
360 (cond
361 ((eq newc fill-column)
362 (setq oldc fill-column)
363 (setq ruler-mode-mouse-current-grab-object 'fill-column)
364 t)
365 ((eq newc comment-column)
366 (setq oldc comment-column)
367 (setq ruler-mode-mouse-current-grab-object 'comment-column)
368 t)
369 ((eq newc goal-column) ; A. update goal column
370 (setq oldc goal-column)
371 (setq ruler-mode-mouse-current-grab-object 'goal-column)
372 t)
373 ((null goal-column) ; B. set goal column
374 (setq oldc goal-column)
375 (setq goal-column newc)
376 ;; mouse-2 coming AFTER drag-mouse-2 invokes `ding'.
377 ;; This `ding' flushes the next messages about setting
378 ;; goal column. So here I force fetch the event(mouse-2)
379 ;; and throw away.
380 (read-event)
381 ;; Ding BEFORE `message' is OK.
382 (if ruler-mode-set-goal-column-ding-flag
383 (ding))
384 (message
385 "Goal column %d (click `%s' on the ruler again to unset it)"
386 newc
387 (propertize (char-to-string ruler-mode-goal-column-char)
388 'face 'ruler-mode-goal-column-face))
389 ;; don't enter drag iteration
390 nil))
391 (if (eq 'click (ruler-mode-mouse-drag-any-column-iteration
392 (posn-window start)))
393 (if (eq 'goal-column ruler-mode-mouse-current-grab-object)
394 ;; C. unset goal column
395 (set-goal-column t))
396 ;; *-column is updated; report it
397 (message "%s is set to %d (was %d)"
398 ruler-mode-mouse-current-grab-object
399 (eval ruler-mode-mouse-current-grab-object)
400 oldc))))))
401
402 (defun ruler-mode-mouse-drag-any-column-iteration (window)
403 "Update the ruler while dragging the mouse.
404 WINDOW is the window where the last down-mouse event is occurred.
405 Return a symbol `drag' if the mouse is actually dragged.
406 Return a symbol `click' if the mouse is just clicked."
407 (let (newevent
408 (drag-count 0))
409 (track-mouse
410 (while (progn
411 (setq newevent (read-event))
412 (mouse-movement-p newevent))
413 (setq drag-count (1+ drag-count))
414 (if (eq window (posn-window (event-end newevent)))
415 (progn
416 (ruler-mode-mouse-drag-any-column newevent)
417 (force-mode-line-update)))))
418 (if (and (eq drag-count 0)
419 (eq 'click (car (event-modifiers newevent))))
420 'click
421 'drag)))
422
423 (defun ruler-mode-mouse-drag-any-column (start-event)
424 "Update the ruler for START-EVENT, one mouse motion event."
288 (let* ((start (event-start start-event)) 425 (let* ((start (event-start start-event))
289 (end (event-end start-event)) 426 (end (event-end start-event))
290 m col w lm rm hs fc) 427 m col w lm rm hs newc)
291 (if (eq start end) ;; mouse click 428 (save-selected-window
292 (save-selected-window 429 (select-window (posn-window start))
293 (select-window (posn-window start)) 430 (setq m (window-margins)
294 (setq m (window-margins) 431 lm (or (car m) 0)
295 lm (or (car m) 0) 432 rm (or (cdr m) 0)
296 rm (or (cdr m) 0) 433 col (- (car (posn-col-row end)) lm)
297 col (- (car (posn-col-row start)) lm) 434 w (window-width)
298 w (window-width) 435 hs (window-hscroll)
299 hs (window-hscroll) 436 newc (+ col hs))
300 fc (+ col hs)) 437 (if (and (>= col 0) (< (+ col lm rm) w))
301 (and (>= col 0) (< (+ col lm rm) w) 438 (set ruler-mode-mouse-current-grab-object newc)))))
302 (progn
303 (message "Fill column set to %d (was %d)" fc fill-column)
304 (setq fill-column fc)))))))
305 439
306 (defun ruler-mode-mouse-add-tab-stop (start-event) 440 (defun ruler-mode-mouse-add-tab-stop (start-event)
307 "Add a tab stop to the graduation where the mouse pointer is on. 441 "Add a tab stop to the graduation where the mouse pointer is on.
308 START-EVENT is the mouse click event." 442 START-EVENT is the mouse click event."
309 (interactive "e") 443 (interactive "e")
344 lm (or (car m) 0) 478 lm (or (car m) 0)
345 rm (or (cdr m) 0) 479 rm (or (cdr m) 0)
346 col (- (car (posn-col-row start)) lm) 480 col (- (car (posn-col-row start)) lm)
347 w (window-width) 481 w (window-width)
348 hs (window-hscroll) 482 hs (window-hscroll)
349 ts (+ col hs)) 483 ts (+ col hs))
350 (and (>= col 0) (< (+ col lm rm) w) 484 (and (>= col 0) (< (+ col lm rm) w)
351 (member ts tab-stop-list) 485 (member ts tab-stop-list)
352 (progn 486 (progn
353 (message "Tab stop at %d deleted" ts) 487 (message "Tab stop at %d deleted" ts)
354 (setq tab-stop-list 488 (setq tab-stop-list
365 (define-key km [header-line down-mouse-1] 499 (define-key km [header-line down-mouse-1]
366 #'ignore) 500 #'ignore)
367 (define-key km [header-line down-mouse-3] 501 (define-key km [header-line down-mouse-3]
368 #'ignore) 502 #'ignore)
369 (define-key km [header-line down-mouse-2] 503 (define-key km [header-line down-mouse-2]
370 #'ruler-mode-mouse-set-fill-column) 504 #'ruler-mode-mouse-grab-any-column)
371 (define-key km [header-line (shift down-mouse-1)] 505 (define-key km [header-line (shift down-mouse-1)]
372 #'ruler-mode-mouse-set-left-margin) 506 #'ruler-mode-mouse-set-left-margin)
373 (define-key km [header-line (shift down-mouse-3)] 507 (define-key km [header-line (shift down-mouse-3)]
374 #'ruler-mode-mouse-set-right-margin) 508 #'ruler-mode-mouse-set-right-margin)
375 (define-key km [header-line (control down-mouse-1)] 509 (define-key km [header-line (control down-mouse-1)]
397 :group 'ruler-mode 531 :group 'ruler-mode
398 (if ruler-mode 532 (if ruler-mode
399 (progn 533 (progn
400 ;; When `ruler-mode' is on save previous header line format 534 ;; When `ruler-mode' is on save previous header line format
401 ;; and install the ruler header line format. 535 ;; and install the ruler header line format.
402 (setq ruler-mode-header-line-format-old header-line-format 536 (when (local-variable-p 'header-line-format)
403 header-line-format ruler-mode-header-line-format) 537 (setq ruler-mode-header-line-format-old header-line-format))
538 (setq header-line-format ruler-mode-header-line-format)
404 (add-hook 'post-command-hook ; add local hook 539 (add-hook 'post-command-hook ; add local hook
405 #'force-mode-line-update nil t)) 540 #'force-mode-line-update nil t))
406 ;; When `ruler-mode' is off restore previous header line format if 541 ;; When `ruler-mode' is off restore previous header line format if
407 ;; the current one is the ruler header line format. 542 ;; the current one is the ruler header line format.
408 (if (eq header-line-format ruler-mode-header-line-format) 543 (when (eq header-line-format ruler-mode-header-line-format)
409 (setq header-line-format ruler-mode-header-line-format-old)) 544 (kill-local-variable 'header-line-format)
545 (when ruler-mode-header-line-format-old
546 (setq header-line-format ruler-mode-header-line-format-old)))
410 (remove-hook 'post-command-hook ; remove local hook 547 (remove-hook 'post-command-hook ; remove local hook
411 #'force-mode-line-update t))) 548 #'force-mode-line-update t)))
412 549
413 ;; Add ruler-mode to the minor mode menu in the mode line 550 ;; Add ruler-mode to the minor mode menu in the mode line
414 (define-key mode-line-mode-menu [ruler-mode] 551 (define-key mode-line-mode-menu [ruler-mode]
415 `(menu-item "Ruler" ruler-mode 552 `(menu-item "Ruler" ruler-mode
416 :button (:toggle . ruler-mode))) 553 :button (:toggle . ruler-mode)))
417 554
418 (defconst ruler-mode-ruler-help-echo 555 (defconst ruler-mode-ruler-help-echo
419 "\ 556 "\
420 S-mouse-1/3: set L/R margin, \ 557 S-mouse-1/3: set L/R margin, \
421 mouse-2: set fill col, \ 558 mouse-2: set goal column, \
422 C-mouse-2: show tabs" 559 C-mouse-2: show tabs"
423 "Help string shown when mouse pointer is over the ruler. 560 "Help string shown when mouse is over the ruler.
424 `ruler-mode-show-tab-stops' is nil.") 561 `ruler-mode-show-tab-stops' is nil.")
425 562
426 (defconst ruler-mode-ruler-help-echo-tab 563 (defconst ruler-mode-ruler-help-echo-when-goal-column
564 "\
565 S-mouse-1/3: set L/R margin, \
566 C-mouse-2: show tabs"
567 "Help string shown when mouse is over the ruler.
568 `goal-column' is set and `ruler-mode-show-tab-stops' is nil.")
569
570 (defconst ruler-mode-ruler-help-echo-when-tab-stops
427 "\ 571 "\
428 C-mouse1/3: set/unset tab, \ 572 C-mouse1/3: set/unset tab, \
429 C-mouse-2: hide tabs" 573 C-mouse-2: hide tabs"
430 "Help string shown when mouse pointer is over the ruler. 574 "Help string shown when mouse is over the ruler.
431 `ruler-mode-show-tab-stops' is non-nil.") 575 `ruler-mode-show-tab-stops' is non-nil.")
576
577 (defconst ruler-mode-fill-column-help-echo
578 "drag-mouse-2: set fill column"
579 "Help string shown when mouse is on the fill column character.")
580
581 (defconst ruler-mode-comment-column-help-echo
582 "drag-mouse-2: set comment column"
583 "Help string shown when mouse is on the comment column character.")
584
585 (defconst ruler-mode-goal-column-help-echo
586 "\
587 drag-mouse-2: set goal column, \
588 mouse-2: unset goal column"
589 "Help string shown when mouse is on the goal column character.")
432 590
433 (defconst ruler-mode-left-margin-help-echo 591 (defconst ruler-mode-left-margin-help-echo
434 "Left margin %S" 592 "Left margin %S"
435 "Help string shown when mouse is over the left margin area.") 593 "Help string shown when mouse is over the left margin area.")
436 594
450 608
451 (defmacro ruler-mode-left-scroll-bar-cols () 609 (defmacro ruler-mode-left-scroll-bar-cols ()
452 "Return the width, measured in columns, of the left vertical scrollbar." 610 "Return the width, measured in columns, of the left vertical scrollbar."
453 '(if (eq (frame-parameter nil 'vertical-scroll-bars) 'left) 611 '(if (eq (frame-parameter nil 'vertical-scroll-bars) 'left)
454 (let ((sbw (frame-parameter nil 'scroll-bar-width))) 612 (let ((sbw (frame-parameter nil 'scroll-bar-width)))
455 ;; nil means it's a non-toolkit scroll bar, 613 ;; nil means it's a non-toolkit scroll bar,
456 ;; and its width in columns is 14 pixels rounded up. 614 ;; and its width in columns is 14 pixels rounded up.
457 (unless sbw (setq sbw 14)) 615 (unless sbw (setq sbw 14))
458 ;; Always round up to multiple of columns. 616 ;; Always round up to multiple of columns.
459 (ceiling sbw (frame-char-width))) 617 (ceiling sbw (frame-char-width)))
460 0)) 618 0))
461 619
462 (defmacro ruler-mode-right-scroll-bar-cols () 620 (defmacro ruler-mode-right-scroll-bar-cols ()
463 "Return the width, measured in columns, of the right vertical scrollbar." 621 "Return the width, measured in columns, of the right vertical scrollbar."
464 '(if (eq (frame-parameter nil 'vertical-scroll-bars) 'right) 622 '(if (eq (frame-parameter nil 'vertical-scroll-bars) 'right)
489 ;; Setup default face and help echo. 647 ;; Setup default face and help echo.
490 (put-text-property 0 (length ruler) 648 (put-text-property 0 (length ruler)
491 'face 'ruler-mode-default-face 649 'face 'ruler-mode-default-face
492 ruler) 650 ruler)
493 (put-text-property 0 (length ruler) 651 (put-text-property 0 (length ruler)
494 'help-echo 652 'help-echo
495 (if ruler-mode-show-tab-stops 653 (if ruler-mode-show-tab-stops
496 ruler-mode-ruler-help-echo-tab 654 ruler-mode-ruler-help-echo-when-tab-stops
497 ruler-mode-ruler-help-echo) 655 (if goal-column
656 ruler-mode-ruler-help-echo-when-goal-column
657 ruler-mode-ruler-help-echo))
498 ruler) 658 ruler)
499 ;; Setup the local map. 659 ;; Setup the local map.
500 (put-text-property 0 (length ruler) 660 (put-text-property 0 (length ruler)
501 'local-map ruler-mode-map 661 'local-map ruler-mode-map
502 ruler) 662 ruler)
544 (format ruler-mode-right-margin-help-echo (- w r)) 704 (format ruler-mode-right-margin-help-echo (- w r))
545 ruler) 705 ruler)
546 (while (< i (length ruler)) 706 (while (< i (length ruler))
547 (aset ruler i ruler-mode-margins-char) 707 (aset ruler i ruler-mode-margins-char)
548 (setq i (1+ i))) 708 (setq i (1+ i)))
549 709
710 ;; Show the `goal-column' marker.
711 (if goal-column
712 (progn
713 (setq i (- goal-column o))
714 (and (>= i 0) (< i r)
715 (aset ruler i ruler-mode-goal-column-char)
716 (progn
717 (put-text-property
718 i (1+ i) 'face 'ruler-mode-goal-column-face
719 ruler)
720 (put-text-property
721 i (1+ i) 'help-echo ruler-mode-goal-column-help-echo
722 ruler))
723 )))
724
725 ;; Show the `comment-column' marker.
726 (setq i (- comment-column o))
727 (and (>= i 0) (< i r)
728 (aset ruler i ruler-mode-comment-column-char)
729 (progn
730 (put-text-property
731 i (1+ i) 'face 'ruler-mode-comment-column-face
732 ruler)
733 (put-text-property
734 i (1+ i) 'help-echo ruler-mode-comment-column-help-echo
735 ruler)))
736
550 ;; Show the `fill-column' marker. 737 ;; Show the `fill-column' marker.
551 (setq i (- fill-column o)) 738 (setq i (- fill-column o))
552 (and (>= i 0) (< i r) 739 (and (>= i 0) (< i r)
553 (aset ruler i ruler-mode-fill-column-char) 740 (aset ruler i ruler-mode-fill-column-char)
554 (put-text-property 741 (progn (put-text-property
555 i (1+ i) 'face 'ruler-mode-fill-column-face 742 i (1+ i) 'face 'ruler-mode-fill-column-face
556 ruler)) 743 ruler)
744 (put-text-property
745 i (1+ i) 'help-echo ruler-mode-fill-column-help-echo
746 ruler)))
557 747
558 ;; Show the `tab-stop-list' markers. 748 ;; Show the `tab-stop-list' markers.
559 (if ruler-mode-show-tab-stops 749 (if ruler-mode-show-tab-stops
560 (let ((tsl tab-stop-list) ts) 750 (let ((tsl tab-stop-list) ts)
561 (while tsl 751 (while tsl
565 (and (>= i 0) (< i r) 755 (and (>= i 0) (< i r)
566 (aset ruler i ruler-mode-tab-stop-char) 756 (aset ruler i ruler-mode-tab-stop-char)
567 (put-text-property 757 (put-text-property
568 i (1+ i) 758 i (1+ i)
569 'face (cond 759 'face (cond
570 ;; Don't override the fill-column face 760 ;; Don't override the *-column face
571 ((eq ts fill-column) 761 ((eq ts fill-column)
572 'ruler-mode-fill-column-face) 762 'ruler-mode-fill-column-face)
763 ((eq ts comment-column)
764 'ruler-mode-comment-column-face)
765 ((eq ts goal-column)
766 'ruler-mode-goal-column-face)
573 (t 767 (t
574 'ruler-mode-tab-stop-face)) 768 'ruler-mode-tab-stop-face))
575 ruler))))) 769 ruler)))))
576 770
577 ;; Show the `current-column' marker. 771 ;; Show the `current-column' marker.
579 (and (>= i 0) (< i r) 773 (and (>= i 0) (< i r)
580 (aset ruler i ruler-mode-current-column-char) 774 (aset ruler i ruler-mode-current-column-char)
581 (put-text-property 775 (put-text-property
582 i (1+ i) 'face 'ruler-mode-current-column-face 776 i (1+ i) 'face 'ruler-mode-current-column-face
583 ruler)) 777 ruler))
584 778
585 ruler))) 779 ruler)))
586 780
587 (provide 'ruler-mode) 781 (provide 'ruler-mode)
588 782
589 ;; Local Variables: 783 ;; Local Variables: