Mercurial > emacs
annotate lisp/textmodes/text-mode.el @ 5020:94de08fd8a7c
(Fnext_single_property_change): Fix missing \n\.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Mon, 15 Nov 1993 06:41:45 +0000 |
| parents | bc777b8e4b45 |
| children | 5360e784af1d |
| 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)) | |
|
4896
bc777b8e4b45
(text-mode-map): Bind ispell-complete-word to M-TAB.
Richard M. Stallman <rms@gnu.org>
parents:
4744
diff
changeset
|
53 (define-key text-mode-map "\e\t" 'ispell-complete-word) |
| 36 | 54 (define-key text-mode-map "\t" 'tab-to-tab-stop) |
| 55 (define-key text-mode-map "\es" 'center-line) | |
| 56 (define-key text-mode-map "\eS" 'center-paragraph)) | |
| 57 | |
| 58 | |
| 59 ;(defun non-saved-text-mode () | |
| 60 ; "Like text-mode, but delete auto save file when file is saved for real." | |
| 61 ; (text-mode) | |
| 62 ; (make-local-variable 'delete-auto-save-files) | |
| 63 ; (setq delete-auto-save-files t)) | |
| 64 | |
| 65 (defun text-mode () | |
| 66 "Major mode for editing text intended for humans to read. Special commands:\\{text-mode-map} | |
| 1576 | 67 Turning on Text mode calls the value of the variable `text-mode-hook', |
| 36 | 68 if that value is non-nil." |
| 69 (interactive) | |
| 70 (kill-all-local-variables) | |
| 71 (use-local-map text-mode-map) | |
| 72 (setq mode-name "Text") | |
| 73 (setq major-mode 'text-mode) | |
| 74 (setq local-abbrev-table text-mode-abbrev-table) | |
| 75 (set-syntax-table text-mode-syntax-table) | |
| 76 (run-hooks 'text-mode-hook)) | |
| 77 | |
| 78 (defvar indented-text-mode-map () | |
| 79 "Keymap for Indented Text mode. | |
| 80 All the commands defined in Text mode are inherited unless overridden.") | |
| 81 | |
| 82 (if indented-text-mode-map | |
| 83 () | |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2315
diff
changeset
|
84 ;; Make different definition for TAB before the one in text-mode-map, but |
| 283 | 85 ;; share the rest. |
| 86 (let ((newmap (make-sparse-keymap))) | |
| 87 (define-key newmap "\t" 'indent-relative) | |
| 88 (setq indented-text-mode-map (nconc newmap text-mode-map)))) | |
| 36 | 89 |
| 90 (defun indented-text-mode () | |
|
4744
ea4df8504763
(indented-text-mode): Make only blank lines
Richard M. Stallman <rms@gnu.org>
parents:
4573
diff
changeset
|
91 "Major mode for editing text with indented paragraphs. |
|
ea4df8504763
(indented-text-mode): Make only blank lines
Richard M. Stallman <rms@gnu.org>
parents:
4573
diff
changeset
|
92 In this mode, paragraphs are delimited only by blank lines. |
|
ea4df8504763
(indented-text-mode): Make only blank lines
Richard M. Stallman <rms@gnu.org>
parents:
4573
diff
changeset
|
93 You can thus get the benefit of adaptive filling |
|
ea4df8504763
(indented-text-mode): Make only blank lines
Richard M. Stallman <rms@gnu.org>
parents:
4573
diff
changeset
|
94 (see the variable `adaptive-fill-mode'). |
|
4573
5a2c0c38a0a1
(indented-text-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
95 \\{indented-text-mode-map} |
| 1576 | 96 Turning on `indented-text-mode' calls the value of the variable |
| 97 `text-mode-hook', if that value is non-nil." | |
| 36 | 98 (interactive) |
| 99 (kill-all-local-variables) | |
| 100 (use-local-map text-mode-map) | |
| 101 (define-abbrev-table 'text-mode-abbrev-table ()) | |
| 102 (setq local-abbrev-table text-mode-abbrev-table) | |
| 103 (set-syntax-table text-mode-syntax-table) | |
| 104 (make-local-variable 'indent-line-function) | |
| 105 (setq indent-line-function 'indent-relative-maybe) | |
|
4744
ea4df8504763
(indented-text-mode): Make only blank lines
Richard M. Stallman <rms@gnu.org>
parents:
4573
diff
changeset
|
106 (make-local-variable 'paragraph-start) |
|
ea4df8504763
(indented-text-mode): Make only blank lines
Richard M. Stallman <rms@gnu.org>
parents:
4573
diff
changeset
|
107 (setq paragraph-start (concat "^$\\|" page-delimiter)) |
|
ea4df8504763
(indented-text-mode): Make only blank lines
Richard M. Stallman <rms@gnu.org>
parents:
4573
diff
changeset
|
108 (make-local-variable 'paragraph-separate) |
|
ea4df8504763
(indented-text-mode): Make only blank lines
Richard M. Stallman <rms@gnu.org>
parents:
4573
diff
changeset
|
109 (setq paragraph-separate paragraph-start) |
| 36 | 110 (use-local-map indented-text-mode-map) |
| 111 (setq mode-name "Indented Text") | |
| 112 (setq major-mode 'indented-text-mode) | |
| 113 (run-hooks 'text-mode-hook)) | |
| 114 | |
| 115 (defun center-paragraph () | |
| 116 "Center each nonblank line in the paragraph at or after point. | |
| 1576 | 117 See `center-line' for more info." |
| 36 | 118 (interactive) |
| 119 (save-excursion | |
| 120 (forward-paragraph) | |
| 121 (or (bolp) (newline 1)) | |
| 122 (let ((end (point))) | |
| 123 (backward-paragraph) | |
| 124 (center-region (point) end)))) | |
| 125 | |
| 126 (defun center-region (from to) | |
| 127 "Center each nonblank line starting in the region. | |
| 1576 | 128 See `center-line' for more info." |
| 36 | 129 (interactive "r") |
| 130 (if (> from to) | |
| 131 (let ((tem to)) | |
| 132 (setq to from from tem))) | |
| 133 (save-excursion | |
| 134 (save-restriction | |
| 135 (narrow-to-region from to) | |
| 136 (goto-char from) | |
| 137 (while (not (eobp)) | |
| 138 (or (save-excursion (skip-chars-forward " \t") (eolp)) | |
| 139 (center-line)) | |
| 140 (forward-line 1))))) | |
| 141 | |
| 142 (defun center-line () | |
| 143 "Center the line point is on, within the width specified by `fill-column'. | |
| 144 This means adjusting the indentation so that it equals | |
| 145 the distance between the end of the text and `fill-column'." | |
| 146 (interactive) | |
| 147 (save-excursion | |
| 148 (let (line-length) | |
| 149 (beginning-of-line) | |
| 150 (delete-horizontal-space) | |
| 151 (end-of-line) | |
| 152 (delete-horizontal-space) | |
| 153 (setq line-length (current-column)) | |
| 154 (beginning-of-line) | |
| 155 (indent-to | |
| 156 (+ left-margin | |
| 157 (/ (- fill-column left-margin line-length) 2)))))) | |
|
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
283
diff
changeset
|
158 |
|
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
283
diff
changeset
|
159 ;;; text-mode.el ends here |
