annotate lisp/ruler-mode.el @ 52590:ae8115a00e62

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