Mercurial > emacs
annotate lisp/textmodes/text-mode.el @ 39925:8944218cbc96
*** empty log message ***
author | Pavel Janík <Pavel@Janik.cz> |
---|---|
date | Sun, 14 Oct 2001 16:14:53 +0000 |
parents | a19197c6442f |
children | 04be247dd745 |
rev | line source |
---|---|
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
28108
diff
changeset
|
1 ;;; text-mode.el --- text mode, and its idiosyncratic commands |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
283
diff
changeset
|
2 |
7300 | 3 ;; Copyright (C) 1985, 1992, 1994 Free Software Foundation, Inc. |
841 | 4 |
775
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
727
diff
changeset
|
5 ;; Maintainer: FSF |
38697
a19197c6442f
Keyword added and FSF specified as Maintainer.
Pavel Janík <Pavel@Janik.cz>
parents:
38412
diff
changeset
|
6 ;; Keywords: wp |
36 | 7 |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
727 | 12 ;; the Free Software Foundation; either version 2, or (at your option) |
36 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
2315
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1576
diff
changeset
|
24 |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1576
diff
changeset
|
25 ;;; Commentary: |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1576
diff
changeset
|
26 |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1576
diff
changeset
|
27 ;; This package provides the fundamental text mode documented in the |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1576
diff
changeset
|
28 ;; Emacs user's manual. |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1576
diff
changeset
|
29 |
775
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
727
diff
changeset
|
30 ;;; Code: |
36 | 31 |
26598 | 32 (defcustom text-mode-hook nil |
33 "Normal hook run when entering Text mode and many related modes." | |
34 :type 'hook | |
28108
0d9cac36402a
(text-mode-hook): Add flyspell-mode to
Dave Love <fx@gnu.org>
parents:
27202
diff
changeset
|
35 :options '(turn-on-auto-fill flyspell-mode) |
26598 | 36 :group 'data) |
19589
8c19d570a391
(text-mode-hook): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
18256
diff
changeset
|
37 |
19590
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
38 (defvar text-mode-variant nil |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
39 "Non-nil if this buffer's major mode is a variant of Text mode.") |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
40 |
36 | 41 (defvar text-mode-syntax-table nil |
42 "Syntax table used while in text mode.") | |
43 | |
44 (defvar text-mode-abbrev-table nil | |
45 "Abbrev table used while in text mode.") | |
46 (define-abbrev-table 'text-mode-abbrev-table ()) | |
47 | |
48 (if text-mode-syntax-table | |
49 () | |
50 (setq text-mode-syntax-table (make-syntax-table)) | |
51 (modify-syntax-entry ?\" ". " text-mode-syntax-table) | |
52 (modify-syntax-entry ?\\ ". " text-mode-syntax-table) | |
53 (modify-syntax-entry ?' "w " text-mode-syntax-table)) | |
54 | |
55 (defvar text-mode-map nil | |
56 "Keymap for Text mode. | |
57 Many other modes, such as Mail mode, Outline mode and Indented Text mode, | |
58 inherit all the commands defined in this map.") | |
59 | |
60 (if text-mode-map | |
61 () | |
62 (setq text-mode-map (make-sparse-keymap)) | |
4896
bc777b8e4b45
(text-mode-map): Bind ispell-complete-word to M-TAB.
Richard M. Stallman <rms@gnu.org>
parents:
4744
diff
changeset
|
63 (define-key text-mode-map "\e\t" 'ispell-complete-word) |
18222
b7ad635feeb8
(paragraph-indent-text-mode): Renamed from spaced-text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
18132
diff
changeset
|
64 (define-key text-mode-map "\t" 'indent-relative) |
36 | 65 (define-key text-mode-map "\es" 'center-line) |
66 (define-key text-mode-map "\eS" 'center-paragraph)) | |
67 | |
68 | |
69 (defun text-mode () | |
18132
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
70 "Major mode for editing text written for humans to read. |
18256
27f2dfb2c1de
(text-mode): Let all-white lines separate paragraphs.
Richard M. Stallman <rms@gnu.org>
parents:
18222
diff
changeset
|
71 In this mode, paragraphs are delimited only by blank or white lines. |
18132
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
72 You can thus get the full benefit of adaptive filling |
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
73 (see the variable `adaptive-fill-mode'). |
6323 | 74 \\{text-mode-map} |
18132
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
75 Turning on Text mode runs the normal hook `text-mode-hook'." |
36 | 76 (interactive) |
77 (kill-all-local-variables) | |
78 (use-local-map text-mode-map) | |
18132
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
79 (setq local-abbrev-table text-mode-abbrev-table) |
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
80 (set-syntax-table text-mode-syntax-table) |
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
81 (make-local-variable 'paragraph-start) |
26544
1551195f02c3
(text-mode): Contruct paragraph-start so
Gerd Moellmann <gerd@gnu.org>
parents:
22631
diff
changeset
|
82 (setq paragraph-start (concat page-delimiter "\\|[ \t]*$")) |
27202
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
83 (if (eq ?^ (aref paragraph-start 0)) |
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
84 (setq paragraph-start (substring paragraph-start 1))) |
18132
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
85 (make-local-variable 'paragraph-separate) |
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
86 (setq paragraph-separate paragraph-start) |
22631
3f3121176533
(text-mode): Locally set indent-line-function.
Richard M. Stallman <rms@gnu.org>
parents:
19620
diff
changeset
|
87 (make-local-variable 'indent-line-function) |
3f3121176533
(text-mode): Locally set indent-line-function.
Richard M. Stallman <rms@gnu.org>
parents:
19620
diff
changeset
|
88 (setq indent-line-function 'indent-relative-maybe) |
36 | 89 (setq mode-name "Text") |
90 (setq major-mode 'text-mode) | |
18132
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
91 (run-hooks 'text-mode-hook)) |
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
92 |
18222
b7ad635feeb8
(paragraph-indent-text-mode): Renamed from spaced-text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
18132
diff
changeset
|
93 (defun paragraph-indent-text-mode () |
18132
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
94 "Major mode for editing text, with leading spaces starting a paragraph. |
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
95 In this mode, you do not need blank lines between paragraphs |
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
96 when the first line of the following paragraph starts with whitespace. |
27202
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
97 `paragraph-indent-minor-mode' provides a similar facility as a minor mode. |
18132
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
98 Special commands: |
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
99 \\{text-mode-map} |
18222
b7ad635feeb8
(paragraph-indent-text-mode): Renamed from spaced-text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
18132
diff
changeset
|
100 Turning on Paragraph-Indent Text mode runs the normal hooks |
b7ad635feeb8
(paragraph-indent-text-mode): Renamed from spaced-text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
18132
diff
changeset
|
101 `text-mode-hook' and `paragraph-indent-text-mode-hook'." |
18132
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
102 (interactive) |
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
103 (kill-all-local-variables) |
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
104 (use-local-map text-mode-map) |
18222
b7ad635feeb8
(paragraph-indent-text-mode): Renamed from spaced-text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
18132
diff
changeset
|
105 (setq mode-name "Parindent") |
b7ad635feeb8
(paragraph-indent-text-mode): Renamed from spaced-text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
18132
diff
changeset
|
106 (setq major-mode 'paragraph-indent-text-mode) |
36 | 107 (setq local-abbrev-table text-mode-abbrev-table) |
108 (set-syntax-table text-mode-syntax-table) | |
18222
b7ad635feeb8
(paragraph-indent-text-mode): Renamed from spaced-text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
18132
diff
changeset
|
109 (run-hooks 'text-mode-hook 'paragraph-indent-text-mode-hook)) |
27202
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
110 |
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
111 (defun paragraph-indent-minor-mode () |
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
112 "Minor mode for editing text, with leading spaces starting a paragraph. |
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
113 In this mode, you do not need blank lines between paragraphs when the |
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
114 first line of the following paragraph starts with whitespace, as with |
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
115 `paragraph-indent-mode'. |
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
116 Turning on Paragraph-Indent minor mode runs the normal hook |
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
117 `paragraph-indent-text-mode-hook'." |
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
118 (interactive) |
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
119 (set (make-local-variable 'paragraph-start) |
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
120 (default-value 'paragraph-start)) |
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
121 (set (make-local-variable 'paragraph-separate) paragraph-start) |
6047ac0aaa7c
(text-mode): Remove page-delimiter's `^' from paragraph-start.
Dave Love <fx@gnu.org>
parents:
26598
diff
changeset
|
122 (run-hooks 'paragraph-indent-text-mode-hook)) |
18132
95f6ac42b352
(spaced-text-mode): Renamed from text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
123 |
18222
b7ad635feeb8
(paragraph-indent-text-mode): Renamed from spaced-text-mode.
Richard M. Stallman <rms@gnu.org>
parents:
18132
diff
changeset
|
124 (defalias 'indented-text-mode 'text-mode) |
36 | 125 |
19620
7fccc0f34e57
(text-mode-hook-identify): New function,
Richard M. Stallman <rms@gnu.org>
parents:
19590
diff
changeset
|
126 (defun text-mode-hook-identify () |
7fccc0f34e57
(text-mode-hook-identify): New function,
Richard M. Stallman <rms@gnu.org>
parents:
19590
diff
changeset
|
127 "Mark that this mode has run `text-mode-hook'. |
7fccc0f34e57
(text-mode-hook-identify): New function,
Richard M. Stallman <rms@gnu.org>
parents:
19590
diff
changeset
|
128 This is how `toggle-text-mode-auto-fill' knows which buffers to operate on." |
7fccc0f34e57
(text-mode-hook-identify): New function,
Richard M. Stallman <rms@gnu.org>
parents:
19590
diff
changeset
|
129 (make-local-variable 'text-mode-variant) |
7fccc0f34e57
(text-mode-hook-identify): New function,
Richard M. Stallman <rms@gnu.org>
parents:
19590
diff
changeset
|
130 (setq text-mode-variant t)) |
7fccc0f34e57
(text-mode-hook-identify): New function,
Richard M. Stallman <rms@gnu.org>
parents:
19590
diff
changeset
|
131 |
7fccc0f34e57
(text-mode-hook-identify): New function,
Richard M. Stallman <rms@gnu.org>
parents:
19590
diff
changeset
|
132 (add-hook 'text-mode-hook 'text-mode-hook-identify) |
7fccc0f34e57
(text-mode-hook-identify): New function,
Richard M. Stallman <rms@gnu.org>
parents:
19590
diff
changeset
|
133 |
19590
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
134 (defun toggle-text-mode-auto-fill () |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
135 "Toggle whether to use Auto Fill in Text mode and related modes. |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
136 This command affects all buffers that use modes related to Text mode, |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
137 both existing buffers and buffers that you subsequently create." |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
138 (interactive) |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
139 (let ((enable-mode (not (memq 'turn-on-auto-fill text-mode-hook))) |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
140 (buffers (buffer-list))) |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
141 (if enable-mode |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
142 (add-hook 'text-mode-hook 'turn-on-auto-fill) |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
143 (remove-hook 'text-mode-hook 'turn-on-auto-fill)) |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
144 (while buffers |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
145 (with-current-buffer (car buffers) |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
146 (if text-mode-variant |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
147 (auto-fill-mode (if enable-mode 1 0)))) |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
148 (setq buffers (cdr buffers))) |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
149 (message "Auto Fill %s in Text modes" |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
150 (if enable-mode "enabled" "disabled")))) |
167f4700890a
(text-mode-variant): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19589
diff
changeset
|
151 |
36 | 152 (defun center-paragraph () |
153 "Center each nonblank line in the paragraph at or after point. | |
1576 | 154 See `center-line' for more info." |
36 | 155 (interactive) |
156 (save-excursion | |
157 (forward-paragraph) | |
158 (or (bolp) (newline 1)) | |
159 (let ((end (point))) | |
160 (backward-paragraph) | |
161 (center-region (point) end)))) | |
162 | |
163 (defun center-region (from to) | |
164 "Center each nonblank line starting in the region. | |
1576 | 165 See `center-line' for more info." |
36 | 166 (interactive "r") |
167 (if (> from to) | |
168 (let ((tem to)) | |
169 (setq to from from tem))) | |
170 (save-excursion | |
171 (save-restriction | |
172 (narrow-to-region from to) | |
173 (goto-char from) | |
174 (while (not (eobp)) | |
175 (or (save-excursion (skip-chars-forward " \t") (eolp)) | |
176 (center-line)) | |
177 (forward-line 1))))) | |
178 | |
13023
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
179 (defun center-line (&optional nlines) |
36 | 180 "Center the line point is on, within the width specified by `fill-column'. |
181 This means adjusting the indentation so that it equals | |
13023
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
182 the distance between the end of the text and `fill-column'. |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
183 The argument NLINES says how many lines to center." |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
184 (interactive "P") |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
185 (if nlines (setq nlines (prefix-numeric-value nlines))) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
186 (while (not (eq nlines 0)) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
187 (save-excursion |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
188 (let ((lm (current-left-margin)) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
189 line-length) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
190 (beginning-of-line) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
191 (delete-horizontal-space) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
192 (end-of-line) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
193 (delete-horizontal-space) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
194 (setq line-length (current-column)) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
195 (if (> (- fill-column lm line-length) 0) |
28108
0d9cac36402a
(text-mode-hook): Add flyspell-mode to
Dave Love <fx@gnu.org>
parents:
27202
diff
changeset
|
196 (indent-line-to |
13023
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
197 (+ lm (/ (- fill-column lm line-length) 2)))))) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
198 (cond ((null nlines) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
199 (setq nlines 0)) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
200 ((> nlines 0) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
201 (setq nlines (1- nlines)) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
202 (forward-line 1)) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
203 ((< nlines 0) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
204 (setq nlines (1+ nlines)) |
78f30dd2c8fd
(center-line): New arg NLINES.
Richard M. Stallman <rms@gnu.org>
parents:
10899
diff
changeset
|
205 (forward-line -1))))) |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
283
diff
changeset
|
206 |
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
283
diff
changeset
|
207 ;;; text-mode.el ends here |