Mercurial > emacs
annotate lisp/textmodes/text-mode.el @ 2837:00f822101e49
(ispell): Deactivate mark before the Ispell run.
(ispell-point): Delete the sit-for; it was confusing.
(ispell): Don't use save-excursion; just restore current buffer.
(ispell-next): Don't save-excursion or save-window-excursion.
(ispell-point): Don't save-excursion.
(ispell-window-configuration): New variable.
(ispell-show-choices): Set it if not nil.
(ispell-next): Initialize to nil. Restore at end.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 16 May 1993 21:31:39 +0000 |
parents | 9e7ec92a4fdf |
children | 507f64624555 |
rev | line source |
---|---|
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
283
diff
changeset
|
1 ;;; text-mode.el --- text mode, and its idiosyncratic commands. |
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
283
diff
changeset
|
2 |
841 | 3 ;; Copyright (C) 1985, 1992 Free Software Foundation, Inc. |
4 | |
775
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
727
diff
changeset
|
5 ;; Maintainer: FSF |
36 | 6 |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
727 | 11 ;; the Free Software Foundation; either version 2, or (at your option) |
36 | 12 ;; any later version. |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
22 | |
2315
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1576
diff
changeset
|
23 |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1576
diff
changeset
|
24 ;;; Commentary: |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1576
diff
changeset
|
25 |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1576
diff
changeset
|
26 ;; 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
|
27 ;; Emacs user's manual. |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1576
diff
changeset
|
28 |
775
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
727
diff
changeset
|
29 ;;; Code: |
36 | 30 |
31 (defvar text-mode-syntax-table nil | |
32 "Syntax table used while in text mode.") | |
33 | |
34 (defvar text-mode-abbrev-table nil | |
35 "Abbrev table used while in text mode.") | |
36 (define-abbrev-table 'text-mode-abbrev-table ()) | |
37 | |
38 (if text-mode-syntax-table | |
39 () | |
40 (setq text-mode-syntax-table (make-syntax-table)) | |
41 (modify-syntax-entry ?\" ". " text-mode-syntax-table) | |
42 (modify-syntax-entry ?\\ ". " text-mode-syntax-table) | |
43 (modify-syntax-entry ?' "w " text-mode-syntax-table)) | |
44 | |
45 (defvar text-mode-map nil | |
46 "Keymap for Text mode. | |
47 Many other modes, such as Mail mode, Outline mode and Indented Text mode, | |
48 inherit all the commands defined in this map.") | |
49 | |
50 (if text-mode-map | |
51 () | |
52 (setq text-mode-map (make-sparse-keymap)) | |
53 (define-key text-mode-map "\t" 'tab-to-tab-stop) | |
54 (define-key text-mode-map "\es" 'center-line) | |
55 (define-key text-mode-map "\eS" 'center-paragraph)) | |
56 | |
57 | |
58 ;(defun non-saved-text-mode () | |
59 ; "Like text-mode, but delete auto save file when file is saved for real." | |
60 ; (text-mode) | |
61 ; (make-local-variable 'delete-auto-save-files) | |
62 ; (setq delete-auto-save-files t)) | |
63 | |
64 (defun text-mode () | |
65 "Major mode for editing text intended for humans to read. Special commands:\\{text-mode-map} | |
1576 | 66 Turning on Text mode calls the value of the variable `text-mode-hook', |
36 | 67 if that value is non-nil." |
68 (interactive) | |
69 (kill-all-local-variables) | |
70 (use-local-map text-mode-map) | |
71 (setq mode-name "Text") | |
72 (setq major-mode 'text-mode) | |
73 (setq local-abbrev-table text-mode-abbrev-table) | |
74 (set-syntax-table text-mode-syntax-table) | |
75 (run-hooks 'text-mode-hook)) | |
76 | |
77 (defvar indented-text-mode-map () | |
78 "Keymap for Indented Text mode. | |
79 All the commands defined in Text mode are inherited unless overridden.") | |
80 | |
81 (if indented-text-mode-map | |
82 () | |
283 | 83 ;; Make different definintion for TAB before the one in text-mode-map, but |
84 ;; share the rest. | |
85 (let ((newmap (make-sparse-keymap))) | |
86 (define-key newmap "\t" 'indent-relative) | |
87 (setq indented-text-mode-map (nconc newmap text-mode-map)))) | |
36 | 88 |
89 (defun indented-text-mode () | |
90 "Major mode for editing indented text intended for humans to read.\\{indented-text-mode-map} | |
1576 | 91 Turning on `indented-text-mode' calls the value of the variable |
92 `text-mode-hook', if that value is non-nil." | |
36 | 93 (interactive) |
94 (kill-all-local-variables) | |
95 (use-local-map text-mode-map) | |
96 (define-abbrev-table 'text-mode-abbrev-table ()) | |
97 (setq local-abbrev-table text-mode-abbrev-table) | |
98 (set-syntax-table text-mode-syntax-table) | |
99 (make-local-variable 'indent-line-function) | |
100 (setq indent-line-function 'indent-relative-maybe) | |
101 (use-local-map indented-text-mode-map) | |
102 (setq mode-name "Indented Text") | |
103 (setq major-mode 'indented-text-mode) | |
104 (run-hooks 'text-mode-hook)) | |
105 | |
106 (defun center-paragraph () | |
107 "Center each nonblank line in the paragraph at or after point. | |
1576 | 108 See `center-line' for more info." |
36 | 109 (interactive) |
110 (save-excursion | |
111 (forward-paragraph) | |
112 (or (bolp) (newline 1)) | |
113 (let ((end (point))) | |
114 (backward-paragraph) | |
115 (center-region (point) end)))) | |
116 | |
117 (defun center-region (from to) | |
118 "Center each nonblank line starting in the region. | |
1576 | 119 See `center-line' for more info." |
36 | 120 (interactive "r") |
121 (if (> from to) | |
122 (let ((tem to)) | |
123 (setq to from from tem))) | |
124 (save-excursion | |
125 (save-restriction | |
126 (narrow-to-region from to) | |
127 (goto-char from) | |
128 (while (not (eobp)) | |
129 (or (save-excursion (skip-chars-forward " \t") (eolp)) | |
130 (center-line)) | |
131 (forward-line 1))))) | |
132 | |
133 (defun center-line () | |
134 "Center the line point is on, within the width specified by `fill-column'. | |
135 This means adjusting the indentation so that it equals | |
136 the distance between the end of the text and `fill-column'." | |
137 (interactive) | |
138 (save-excursion | |
139 (let (line-length) | |
140 (beginning-of-line) | |
141 (delete-horizontal-space) | |
142 (end-of-line) | |
143 (delete-horizontal-space) | |
144 (setq line-length (current-column)) | |
145 (beginning-of-line) | |
146 (indent-to | |
147 (+ left-margin | |
148 (/ (- fill-column left-margin line-length) 2)))))) | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
283
diff
changeset
|
149 |
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
283
diff
changeset
|
150 ;;; text-mode.el ends here |