annotate lisp/ruler-mode.el @ 51186:e610d367508d

(find_safe_codings): Fix last change.
author Andreas Schwab <schwab@suse.de>
date Sat, 24 May 2003 20:11:55 +0000
parents 5ed59fd23bc4
children a8b686f386db d7ddb3e565de
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
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
8 ;; Version: 1.5
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 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;; [header-line (shift down-mouse-1)] set left margin to the ruler
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;; graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;; [header-line (shift down-mouse-3)] set right margin to the ruler
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;; graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;;
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
42 ;; [header-line down-mouse-2] set `fill-column', `comment-column' or
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
43 ;; `goal-column' to the ruler graduation with the mouse dragging.
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
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
60 ;; the `goal-column' and `ruler-mode-tab-stop-char' shows tab
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 ;; stop locations. `window-margins' areas are shown with a different
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 ;; background color.
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-margins-char' character used to pad margin areas
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 ;; (space by default).
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 ;; - `ruler-mode-basic-graduation-char' character used for basic
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 ;; graduations ('.' by default).
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 ;; - `ruler-mode-inter-graduation-char' character used for
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 ;; intermediate graduations ('!' by default).
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 ;; The following faces are customizable:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 ;;
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 ;; - `ruler-mode-default-face' the ruler default face.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 ;; - `ruler-mode-fill-column-face' the face used to highlight the
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 ;; `fill-column' character.
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
78 ;; - `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
79 ;; `comment-column' character.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
80 ;; - `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
81 ;; `goal-column' character.
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 ;; - `ruler-mode-current-column-face' the face used to highlight the
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 ;; `current-column' character.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 ;; - `ruler-mode-tab-stop-face' the face used to highlight tab stop
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 ;; characters.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 ;; - `ruler-mode-margins-face' the face used to highlight the
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 ;; `window-margins' areas.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 ;; - `ruler-mode-column-number-face' the face used to highlight the
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 ;; number graduations.
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.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 ;; All `ruler-mode' faces inerit from `ruler-mode-default-face'.
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
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 (defcustom ruler-mode-fill-column-char (if window-system
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
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 (defcustom ruler-mode-current-column-char (if window-system
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
49769
5ed59fd23bc4 Use new ?\s syntax instead of "? " followed by a comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 49603
diff changeset
182 (defcustom ruler-mode-margins-char ?\s
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 "*Character used in margin areas."
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-basic-graduation-char ?\.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 "*Character used for basic 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)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 (defcustom ruler-mode-inter-graduation-char ?\!
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 "*Character used for intermediate graduations."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 :type '(choice
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 (character :tag "Character")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 (integer :tag "Integer char value"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 :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
205
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
206 (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
207 "*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
208 :group 'ruler-mode
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
209 :type 'boolean)
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
210
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 (defface ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 '((((type tty))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 (:inherit default
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 :background "grey64"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 :foreground "grey50"
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 (t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 (:inherit default
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 :background "grey76"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 :foreground "grey64"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 :box (:color "grey76"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 :line-width 1
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 :style released-button)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 "Default face used by the ruler."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 (defface ruler-mode-column-number-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 '((t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 :foreground "black"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 "Face used to highlight number graduations."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 (defface ruler-mode-fill-column-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 '((t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 :foreground "red"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 "Face used to highlight the fill column character."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
244 (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
245 '((t
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
246 (: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
247 :foreground "red"
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
248 )))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
249 "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
250 :group 'ruler-mode)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
251
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
252 (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
253 '((t
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
254 (: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
255 :foreground "red"
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
256 )))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
257 "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
258 :group 'ruler-mode)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
259
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 (defface ruler-mode-tab-stop-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 '((t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 :foreground "steelblue"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 "Face used to highlight tab stop characters."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 (defface ruler-mode-margins-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 '((((type tty))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 :background "grey50"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 ))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 (t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (:inherit ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 :background "grey64"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 "Face used to highlight the `window-margins' areas."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 :group 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 (defface ruler-mode-current-column-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 :weight bold
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 :foreground "yellow"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 )))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 "Face used to highlight the `current-column' character."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 :group 'ruler-mode)
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
288
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (defun ruler-mode-mouse-set-left-margin (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 "Set left margin to the graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 w col m lm0 lm rm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 lm0 (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 rm (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 col (car (posn-col-row start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 lm (min (- w rm) col))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (message "Left margin set to %d (was %d)" lm lm0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 (set-window-margins nil lm rm)))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 (defun ruler-mode-mouse-set-right-margin (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 "Set right margin to the graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 m col w lm rm0 rm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 rm0 (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 lm (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 col (car (posn-col-row start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 rm (max 0 (- w col)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (message "Right margin set to %d (was %d)" rm rm0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 (set-window-margins nil lm rm)))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
327 (defvar ruler-mode-mouse-current-grab-object nil
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
328 "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
329 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
330 nothing is dragged.")
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
331
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
332 (defun ruler-mode-mouse-grab-any-column (start-event)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
333 "Set a column symbol to the graduation with mouse dragging.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
334 See also variable `ruler-mode-mouse-current-grab-object'.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
335 START-EVENT is the mouse down event."
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 (interactive "e")
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
337 (setq ruler-mode-mouse-current-grab-object nil)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
338 (let* ((start (event-start start-event))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
339 m col w lm rm hs newc oldc)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
340 (save-selected-window
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
341 (select-window (posn-window start))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
342 (setq m (window-margins)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
343 lm (or (car m) 0)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
344 rm (or (cdr m) 0)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
345 col (- (car (posn-col-row start)) lm)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
346 w (window-width)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
347 hs (window-hscroll)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
348 newc (+ col hs))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
349 ;;
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
350 ;; About the ways to handle the goal column:
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
351 ;; A. update the value of the goal column if goal-column has
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
352 ;; non-nil value and if the mouse is dragged
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
353 ;; B. set value to the goal column if goal-column has nil and if
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
354 ;; the mouse is just clicked, not dragged.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
355 ;; C. unset value to the goal column if goal-column has non-nil
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
356 ;; and mouse is just clicked on goal-column character on the
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
357 ;; ruler, not dragged.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
358 ;;
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
359 (and (>= col 0) (< (+ col lm rm) w)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
360 (cond
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
361 ((eq newc fill-column)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
362 (setq oldc fill-column)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
363 (setq ruler-mode-mouse-current-grab-object 'fill-column)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
364 t)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
365 ((eq newc comment-column)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
366 (setq oldc comment-column)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
367 (setq ruler-mode-mouse-current-grab-object 'comment-column)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
368 t)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
369 ((eq newc goal-column) ; A. update goal column
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
370 (setq oldc goal-column)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
371 (setq ruler-mode-mouse-current-grab-object 'goal-column)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
372 t)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
373 ((null goal-column) ; B. set goal column
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
374 (setq oldc goal-column)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
375 (setq goal-column newc)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
376 ;; mouse-2 coming AFTER drag-mouse-2 invokes `ding'.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
377 ;; This `ding' flushes the next messages about setting
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
378 ;; goal column. So here I force fetch the event(mouse-2)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
379 ;; and throw away.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
380 (read-event)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
381 ;; Ding BEFORE `message' is OK.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
382 (if ruler-mode-set-goal-column-ding-flag
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
383 (ding))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
384 (message
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
385 "Goal column %d (click `%s' on the ruler again to unset it)"
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
386 newc
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
387 (propertize (char-to-string ruler-mode-goal-column-char)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
388 'face '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
389 ;; don't enter drag iteration
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
390 nil))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
391 (if (eq 'click (ruler-mode-mouse-drag-any-column-iteration
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
392 (posn-window start)))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
393 (if (eq 'goal-column ruler-mode-mouse-current-grab-object)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
394 ;; C. unset goal column
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
395 (set-goal-column t))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
396 ;; *-column is updated; report it
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
397 (message "%s is set to %d (was %d)"
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
398 ruler-mode-mouse-current-grab-object
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
399 (eval ruler-mode-mouse-current-grab-object)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
400 oldc))))))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
401
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
402 (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
403 "Update the ruler while dragging the mouse.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
404 WINDOW is the window where the last down-mouse event is occurred.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
405 Return a symbol `drag' if the mouse is actually dragged.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
406 Return a symbol `click' if the mouse is just clicked."
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
407 (let (newevent
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
408 (drag-count 0))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
409 (track-mouse
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
410 (while (progn
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
411 (setq newevent (read-event))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
412 (mouse-movement-p newevent))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
413 (setq drag-count (1+ drag-count))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
414 (if (eq window (posn-window (event-end newevent)))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
415 (progn
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
416 (ruler-mode-mouse-drag-any-column newevent)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
417 (force-mode-line-update)))))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
418 (if (and (eq drag-count 0)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
419 (eq 'click (car (event-modifiers newevent))))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
420 'click
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
421 'drag)))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
422
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
423 (defun ruler-mode-mouse-drag-any-column (start-event)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
424 "Update the ruler for START-EVENT, one mouse motion event."
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (end (event-end start-event))
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
427 m col w lm rm hs newc)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
428 (save-selected-window
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
429 (select-window (posn-window start))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
430 (setq m (window-margins)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
431 lm (or (car m) 0)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
432 rm (or (cdr m) 0)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
433 col (- (car (posn-col-row end)) lm)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
434 w (window-width)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
435 hs (window-hscroll)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
436 newc (+ col hs))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
437 (if (and (>= col 0) (< (+ col lm rm) w))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
438 (set ruler-mode-mouse-current-grab-object newc)))))
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
439
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 (defun ruler-mode-mouse-add-tab-stop (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 "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
442 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (if ruler-mode-show-tab-stops
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 m col w lm rm hs ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 lm (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 rm (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 col (- (car (posn-col-row start)) lm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 hs (window-hscroll)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 ts (+ col hs))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 (and (>= col 0) (< (+ col lm rm) w)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 (not (member ts tab-stop-list))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 (progn
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 (message "Tab stop set to %d" ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (setq tab-stop-list
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 (sort (cons ts tab-stop-list)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 #'<)))))))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 (defun ruler-mode-mouse-del-tab-stop (start-event)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 "Delete tab stop at the graduation where the mouse pointer is on.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 START-EVENT is the mouse click event."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 (interactive "e")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (if ruler-mode-show-tab-stops
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 (let* ((start (event-start start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (end (event-end start-event))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 m col w lm rm hs ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (if (eq start end) ;; mouse click
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 (save-selected-window
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 (select-window (posn-window start))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 (setq m (window-margins)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 lm (or (car m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 rm (or (cdr m) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 col (- (car (posn-col-row start)) lm)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 w (window-width)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 hs (window-hscroll)
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
483 ts (+ col hs))
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (and (>= col 0) (< (+ col lm rm) w)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (member ts tab-stop-list)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 (progn
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 (message "Tab stop at %d deleted" ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 (setq tab-stop-list
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 (delete ts tab-stop-list)))))))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 (defun ruler-mode-toggle-show-tab-stops ()
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 "Toggle showing of tab stops on the ruler."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 (interactive)
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
494 (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
495 (force-mode-line-update))
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
496
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 (defvar ruler-mode-map
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 (let ((km (make-sparse-keymap)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 (define-key km [header-line down-mouse-1]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 #'ignore)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 (define-key km [header-line down-mouse-3]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 #'ignore)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 (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
504 #'ruler-mode-mouse-grab-any-column)
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 (define-key km [header-line (shift down-mouse-1)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 #'ruler-mode-mouse-set-left-margin)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 (define-key km [header-line (shift down-mouse-3)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 #'ruler-mode-mouse-set-right-margin)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 (define-key km [header-line (control down-mouse-1)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 #'ruler-mode-mouse-add-tab-stop)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 (define-key km [header-line (control down-mouse-3)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 #'ruler-mode-mouse-del-tab-stop)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513 (define-key km [header-line (control down-mouse-2)]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
514 #'ruler-mode-toggle-show-tab-stops)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 km)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 "Keymap for ruler minor mode.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 (defvar ruler-mode-header-line-format-old nil
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 "Hold previous value of `header-line-format'.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 (make-variable-buffer-local 'ruler-mode-header-line-format-old)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 (defconst ruler-mode-header-line-format
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523 '(:eval (ruler-mode-ruler))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 "`header-line-format' used in ruler mode.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 ;;;###autoload
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 (define-minor-mode ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 "Display a ruler in the header line if ARG > 0."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 nil nil
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 ruler-mode-map
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 :group 'ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 (if ruler-mode
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 (progn
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 ;; When `ruler-mode' is on save previous header line format
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 ;; 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
536 (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
537 (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
538 (setq header-line-format ruler-mode-header-line-format)
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 (add-hook 'post-command-hook ; add local hook
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 #'force-mode-line-update nil t))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 ;; When `ruler-mode' is off restore previous header line format if
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 ;; 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
543 (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
544 (kill-local-variable 'header-line-format)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
545 (when ruler-mode-header-line-format-old
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
546 (setq header-line-format ruler-mode-header-line-format-old)))
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 (remove-hook 'post-command-hook ; remove local hook
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 #'force-mode-line-update t)))
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
549
42706
be541feb06cc Fix typo.
Pavel Janík <Pavel@Janik.cz>
parents: 42020
diff changeset
550 ;; 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
551 (define-key mode-line-mode-menu [ruler-mode]
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 `(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
553 :button (:toggle . ruler-mode)))
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 (defconst ruler-mode-ruler-help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 "\
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 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
558 mouse-2: set goal column, \
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 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
560 "Help string shown when mouse is over the ruler.
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 `ruler-mode-show-tab-stops' is nil.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
563 (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
564 "\
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
565 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
566 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
567 "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
568 `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
569
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
570 (defconst ruler-mode-ruler-help-echo-when-tab-stops
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571 "\
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572 C-mouse1/3: set/unset tab, \
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 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
574 "Help string shown when mouse is over the ruler.
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 `ruler-mode-show-tab-stops' is non-nil.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
577 (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
578 "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
579 "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
580
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
581 (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
582 "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
583 "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
584
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
585 (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
586 "\
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
587 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
588 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
589 "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
590
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
591 (defconst ruler-mode-left-margin-help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592 "Left margin %S"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593 "Help string shown when mouse is over the left margin area.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 (defconst ruler-mode-right-margin-help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596 "Right margin %S"
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 "Help string shown when mouse is over the right margin area.")
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598
42020
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
599 (defmacro ruler-mode-left-fringe-cols ()
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
600 "Return the width, measured in columns, of the left fringe area."
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
601 '(round (or (frame-parameter nil 'left-fringe) 0)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
602 (frame-char-width)))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
603
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
604 (defmacro ruler-mode-right-fringe-cols ()
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
605 "Return the width, measured in columns, of the right fringe area."
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
606 '(round (or (frame-parameter nil 'right-fringe) 0)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
607 (frame-char-width)))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
608
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
609 (defmacro ruler-mode-left-scroll-bar-cols ()
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
610 "Return the width, measured in columns, of the left vertical scrollbar."
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
611 '(if (eq (frame-parameter nil 'vertical-scroll-bars) 'left)
47425
525668986222 (ruler-mode-left-scroll-bar-cols):
Richard M. Stallman <rms@gnu.org>
parents: 47183
diff changeset
612 (let ((sbw (frame-parameter nil 'scroll-bar-width)))
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
613 ;; nil means it's a non-toolkit scroll bar,
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
614 ;; and its width in columns is 14 pixels rounded up.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
615 (unless sbw (setq sbw 14))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
616 ;; Always round up to multiple of columns.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
617 (ceiling sbw (frame-char-width)))
42020
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
618 0))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
619
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
620 (defmacro ruler-mode-right-scroll-bar-cols ()
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
621 "Return the width, measured in columns, of the right vertical scrollbar."
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
622 '(if (eq (frame-parameter nil 'vertical-scroll-bars) 'right)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
623 (round (or (frame-parameter nil 'scroll-bar-width) 0)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
624 (frame-char-width))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
625 0))
41461
5507024cc13c Add pagination.
Richard M. Stallman <rms@gnu.org>
parents: 39731
diff changeset
626
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
627 (defun ruler-mode-ruler ()
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628 "Return a string ruler."
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629 (if ruler-mode
42020
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
630 (let* ((j (+ (ruler-mode-left-fringe-cols)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
631 (ruler-mode-left-scroll-bar-cols)))
42003
a22f2256bce0 (ruler-mode-left-fringe-cols): Variable removed.
Richard M. Stallman <rms@gnu.org>
parents: 41461
diff changeset
632 (w (+ (window-width) j))
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633 (m (window-margins))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 (l (or (car m) 0))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635 (r (or (cdr m) 0))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
636 (o (- (window-hscroll) l j))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637 (i 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
638 (ruler (concat
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
639 ;; unit graduations
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
640 (make-string w ruler-mode-basic-graduation-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
641 ;; extra space to fill the header line
42020
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
642 (make-string (+ (ruler-mode-right-fringe-cols)
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
643 (ruler-mode-right-scroll-bar-cols))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
644 ?\ )))
6e891121e1cc (ruler-mode-extra-left-cols): Removed.
Richard M. Stallman <rms@gnu.org>
parents: 42003
diff changeset
645 c k)
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
646
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
647 ;; Setup default face and help echo.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
648 (put-text-property 0 (length ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
649 'face 'ruler-mode-default-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
650 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
651 (put-text-property 0 (length ruler)
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
652 'help-echo
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
653 (if ruler-mode-show-tab-stops
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
654 ruler-mode-ruler-help-echo-when-tab-stops
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
655 (if goal-column
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
656 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
657 ruler-mode-ruler-help-echo))
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
658 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
659 ;; Setup the local map.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
660 (put-text-property 0 (length ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
661 'local-map ruler-mode-map
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
662 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
663
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
664 (setq j (+ l j))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
665 ;; Setup the left margin area.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
666 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
667 i j 'face 'ruler-mode-margins-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
668 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
669 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
670 i j 'help-echo (format ruler-mode-left-margin-help-echo l)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
671 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
672 (while (< i j)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
673 (aset ruler i ruler-mode-margins-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
674 (setq i (1+ i)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
675
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
676 ;; Setup the ruler area.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
677 (setq r (- w r))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
678 (while (< i r)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
679 (setq j (+ i o))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
680 (cond
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
681 ((= (mod j 10) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
682 (setq c (number-to-string (/ j 10))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
683 m (length c)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
684 k i)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
685 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
686 i (1+ i) 'face 'ruler-mode-column-number-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
687 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
688 (while (and (> m 0) (>= k 0))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
689 (aset ruler k (aref c (setq m (1- m))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
690 (setq k (1- k)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
691 )
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
692 ((= (mod j 5) 0)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
693 (aset ruler i ruler-mode-inter-graduation-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
694 )
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
695 )
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
696 (setq i (1+ i)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
697
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
698 ;; Setup the right margin area.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
699 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
700 i (length ruler) 'face 'ruler-mode-margins-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
701 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
702 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
703 i (length ruler) 'help-echo
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
704 (format ruler-mode-right-margin-help-echo (- w r))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
705 ruler)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
706 (while (< i (length ruler))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
707 (aset ruler i ruler-mode-margins-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
708 (setq i (1+ i)))
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
709
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
710 ;; Show the `goal-column' marker.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
711 (if goal-column
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
712 (progn
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
713 (setq i (- goal-column o))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
714 (and (>= i 0) (< i r)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
715 (aset ruler i ruler-mode-goal-column-char)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
716 (progn
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
717 (put-text-property
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
718 i (1+ i) 'face '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
719 ruler)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
720 (put-text-property
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
721 i (1+ i) 'help-echo 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
722 ruler))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
723 )))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
724
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
725 ;; Show the `comment-column' marker.
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
726 (setq i (- comment-column o))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
727 (and (>= i 0) (< i r)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
728 (aset ruler i 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
729 (progn
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
730 (put-text-property
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
731 i (1+ i) 'face '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
732 ruler)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
733 (put-text-property
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
734 i (1+ i) 'help-echo 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
735 ruler)))
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
736
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
737 ;; Show the `fill-column' marker.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
738 (setq i (- fill-column o))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
739 (and (>= i 0) (< i r)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
740 (aset ruler i ruler-mode-fill-column-char)
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
741 (progn (put-text-property
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
742 i (1+ i) 'face 'ruler-mode-fill-column-face
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
743 ruler)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
744 (put-text-property
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
745 i (1+ i) 'help-echo 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
746 ruler)))
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
747
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
748 ;; Show the `tab-stop-list' markers.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
749 (if ruler-mode-show-tab-stops
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
750 (let ((tsl tab-stop-list) ts)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
751 (while tsl
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
752 (setq ts (car tsl)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
753 tsl (cdr tsl)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
754 i (- ts o))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
755 (and (>= i 0) (< i r)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
756 (aset ruler i ruler-mode-tab-stop-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
757 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
758 i (1+ i)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
759 'face (cond
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
760 ;; Don't override the *-column face
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
761 ((eq ts fill-column)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
762 'ruler-mode-fill-column-face)
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
763 ((eq ts comment-column)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
764 '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
765 ((eq ts goal-column)
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
766 'ruler-mode-goal-column-face)
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
767 (t
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
768 'ruler-mode-tab-stop-face))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
769 ruler)))))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
770
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
771 ;; Show the `current-column' marker.
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
772 (setq i (- (current-column) o))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
773 (and (>= i 0) (< i r)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
774 (aset ruler i ruler-mode-current-column-char)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
775 (put-text-property
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
776 i (1+ i) 'face 'ruler-mode-current-column-face
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
777 ruler))
49195
c297d31ef382 (ruler-mode-comment-column-char, ruler-mode-goal-column-char)
Juanma Barranquero <lekktu@gmail.com>
parents: 47425
diff changeset
778
39731
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
779 ruler)))
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
780
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
781 (provide 'ruler-mode)
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
782
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
783 ;; Local Variables:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
784 ;; coding: iso-latin-1
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
785 ;; End:
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
786
0fbd04880396 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
787 ;;; ruler-mode.el ends here