Mercurial > hg > xemacs-beta
annotate lisp/text-mode.el @ 5820:b3824b7f5627
Some changes to eliminate warnings with Apple clang version 1.7.
src/ChangeLog addition:
2014-10-18 Aidan Kehoe <kehoea@parhasard.net>
Some changes to eliminate warnings with Apple clang version 1.7.
* cm.c (send_string_to_tty_console):
* doprnt.c (doprnt_2):
* doprnt.c (parse_off_posnum):
* event-stream.c (dribble_out_event):
Cast various calls to Lstream_putc() to void when the result isn't
being used, for the sake of clang.
* lisp.h:
Declare #'replace here too, it's used in event-stream.c.
* lisp.h (ALLOCA):
* lisp.h (MALLOC_OR_ALLOCA):
Cast a couple of zeros in the context of the ternary operator to
void to prevent unused value warnings with clang.
* sysdep.c (child_setup_tty):
* text.h (ASSERT_ASCTEXT_ASCII_LEN):
Use DO_NOTHING in these files to quieten the compiler.
lib-src/ChangeLog addition:
2014-10-18 Aidan Kehoe <kehoea@parhasard.net>
* ootags.c (substitute):
Cast the result of strlen to int before comparing it with a signed
value, for the sake of compiler warnings.
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Sat, 18 Oct 2014 21:48:10 +0100 |
| parents | 182d01410b8d |
| children |
| rev | line source |
|---|---|
| 428 | 1 ;;; text-mode.el --- text mode, and its idiosyncratic commands. |
| 2 | |
|
5766
182d01410b8d
Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents:
5402
diff
changeset
|
3 ;; Copyright (C) 1985, 1992, 1994, 1997, 2013 Free Software Foundation, Inc. |
| 428 | 4 |
| 5 ;; Maintainer: FSF | |
| 6 ;; Keywords: wp, dumped | |
| 7 | |
| 8 ;; This file is part of XEmacs. | |
| 9 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
10 ;; XEmacs is free software: you can redistribute it and/or modify it |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
11 ;; under the terms of the GNU General Public License as published by the |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
12 ;; Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
13 ;; option) any later version. |
| 428 | 14 |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
15 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
16 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
17 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
18 ;; for more details. |
| 428 | 19 |
| 20 ;; You should have received a copy of the GNU General Public License | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
428
diff
changeset
|
21 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
| 428 | 22 |
| 23 ;;; Synched up with: FSF 20.2. | |
| 24 | |
| 25 ;;; Commentary: | |
| 26 | |
| 27 ;; This file is dumped with XEmacs. | |
| 28 | |
| 29 ;; This package provides the fundamental text mode documented in the | |
| 30 ;; Emacs user's manual. | |
| 31 | |
| 32 ;;; Code: | |
| 33 | |
| 34 (defvar text-mode-hook nil | |
| 35 "Normal hook run when entering Text mode and many related modes.") | |
| 36 | |
| 37 (defvar text-mode-variant nil | |
| 38 "Non-nil if this buffer's major mode is a variant of Text mode.") | |
| 39 | |
| 40 (defvar text-mode-syntax-table nil | |
| 41 "Syntax table used while in text mode.") | |
| 42 | |
| 43 (defvar text-mode-abbrev-table nil | |
| 44 "Abbrev table used while in text mode.") | |
| 45 (define-abbrev-table 'text-mode-abbrev-table ()) | |
| 46 | |
| 47 (if text-mode-syntax-table | |
| 48 () | |
| 49 (setq text-mode-syntax-table (make-syntax-table)) | |
| 50 (modify-syntax-entry ?\" ". " text-mode-syntax-table) | |
| 51 (modify-syntax-entry ?\\ ". " text-mode-syntax-table) | |
| 52 (modify-syntax-entry ?' "w " text-mode-syntax-table)) | |
| 53 | |
| 54 (defvar text-mode-map nil | |
| 55 "Keymap for Text mode. | |
| 56 Many other modes, such as Mail mode, Outline mode and Indented Text mode, | |
| 57 inherit all the commands defined in this map.") | |
| 58 | |
| 59 (if text-mode-map | |
| 60 () | |
| 61 (setq text-mode-map (make-sparse-keymap)) | |
| 62 ;; XEmacs change | |
| 63 (set-keymap-name text-mode-map 'text-mode-map) | |
| 64 (define-key text-mode-map "\e\t" 'ispell-complete-word) | |
| 65 (define-key text-mode-map "\t" 'indent-relative) | |
| 66 (define-key text-mode-map "\es" 'center-line) | |
| 67 (define-key text-mode-map "\eS" 'center-paragraph)) | |
| 68 | |
| 69 | |
| 70 (defun text-mode () | |
| 71 "Major mode for editing text written for humans to read. | |
| 72 In this mode, paragraphs are delimited only by blank or white lines. | |
| 73 You can thus get the full benefit of adaptive filling | |
| 74 (see the variable `adaptive-fill-mode'). | |
| 75 \\{text-mode-map} | |
| 76 Turning on Text mode runs the normal hook `text-mode-hook'." | |
| 77 (interactive) | |
| 78 (kill-all-local-variables) | |
| 79 (use-local-map text-mode-map) | |
| 80 (setq local-abbrev-table text-mode-abbrev-table) | |
| 81 (set-syntax-table text-mode-syntax-table) | |
| 82 (make-local-variable 'paragraph-start) | |
| 83 (setq paragraph-start (concat page-delimiter "\\|[ \t]*$")) | |
| 84 (make-local-variable 'paragraph-separate) | |
| 85 (setq paragraph-separate paragraph-start) | |
|
5766
182d01410b8d
Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents:
5402
diff
changeset
|
86 (set (make-local-variable 'require-final-newline) |
|
182d01410b8d
Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents:
5402
diff
changeset
|
87 mode-require-final-newline) |
| 428 | 88 (setq mode-name "Text") |
| 89 (setq major-mode 'text-mode) | |
| 90 (run-hooks 'text-mode-hook)) | |
| 91 | |
| 92 (defun paragraph-indent-text-mode () | |
| 93 "Major mode for editing text, with leading spaces starting a paragraph. | |
| 94 In this mode, you do not need blank lines between paragraphs | |
| 95 when the first line of the following paragraph starts with whitespace. | |
| 96 Special commands: | |
| 97 \\{text-mode-map} | |
| 98 Turning on Paragraph-Indent Text mode runs the normal hooks | |
| 99 `text-mode-hook' and `paragraph-indent-text-mode-hook'." | |
| 100 (interactive) | |
| 101 (kill-all-local-variables) | |
| 102 (use-local-map text-mode-map) | |
| 103 (setq mode-name "Parindent") | |
| 104 (setq major-mode 'paragraph-indent-text-mode) | |
| 105 (setq local-abbrev-table text-mode-abbrev-table) | |
| 106 (set-syntax-table text-mode-syntax-table) | |
| 107 (run-hooks 'text-mode-hook 'paragraph-indent-text-mode-hook)) | |
| 108 | |
| 109 (defalias 'indented-text-mode 'text-mode) | |
| 110 | |
| 111 (defun text-mode-hook-identify () | |
| 112 "Mark that this mode has run `text-mode-hook'. | |
| 113 This is how `toggle-text-mode-auto-fill' knows which buffers to operate on." | |
| 114 (make-local-variable 'text-mode-variant) | |
| 115 (setq text-mode-variant t)) | |
| 116 | |
| 117 (add-hook 'text-mode-hook 'text-mode-hook-identify) | |
| 118 | |
| 119 (defun toggle-text-mode-auto-fill () | |
| 120 "Toggle whether to use Auto Fill in Text mode and related modes. | |
| 121 This command affects all buffers that use modes related to Text mode, | |
| 122 both existing buffers and buffers that you subsequently create." | |
| 123 (interactive) | |
| 124 (let ((enable-mode (not (memq 'turn-on-auto-fill text-mode-hook))) | |
| 125 (buffers (buffer-list))) | |
| 126 (if enable-mode | |
| 127 (add-hook 'text-mode-hook 'turn-on-auto-fill) | |
| 128 (remove-hook 'text-mode-hook 'turn-on-auto-fill)) | |
| 129 (while buffers | |
| 130 (with-current-buffer (car buffers) | |
| 131 (if text-mode-variant | |
| 132 (auto-fill-mode (if enable-mode 1 0)))) | |
| 133 (setq buffers (cdr buffers))) | |
| 134 (message "Auto Fill %s in Text modes" | |
| 135 (if enable-mode "enabled" "disabled")))) | |
| 136 | |
| 137 (defun center-paragraph () | |
| 138 "Center each nonblank line in the paragraph at or after point. | |
| 139 See `center-line' for more info." | |
| 140 (interactive) | |
| 141 (save-excursion | |
| 142 (forward-paragraph) | |
| 143 (or (bolp) (newline 1)) | |
| 144 (let ((end (point))) | |
| 145 (backward-paragraph) | |
| 146 (center-region (point) end)))) | |
| 147 | |
| 148 (defun center-region (from to) | |
| 149 "Center each nonblank line starting in the region. | |
| 150 See `center-line' for more info." | |
| 151 (interactive "r") | |
| 152 (if (> from to) | |
| 153 (let ((tem to)) | |
| 154 (setq to from from tem))) | |
| 155 (save-excursion | |
| 156 (save-restriction | |
| 157 (narrow-to-region from to) | |
| 158 (goto-char from) | |
| 159 (while (not (eobp)) | |
| 160 (or (save-excursion (skip-chars-forward " \t") (eolp)) | |
| 161 (center-line)) | |
| 162 (forward-line 1))))) | |
| 163 | |
| 164 (defun center-line (&optional nlines) | |
| 165 "Center the line point is on, within the width specified by `fill-column'. | |
| 166 This means adjusting the indentation so that it equals | |
| 167 the distance between the end of the text and `fill-column'. | |
| 168 The argument NLINES says how many lines to center." | |
| 169 (interactive "P") | |
| 170 (if nlines (setq nlines (prefix-numeric-value nlines))) | |
| 171 (while (not (eq nlines 0)) | |
| 172 (save-excursion | |
| 173 (let ((lm (current-left-margin)) | |
| 174 line-length) | |
| 175 (beginning-of-line) | |
| 176 (delete-horizontal-space) | |
| 177 (end-of-line) | |
| 178 (delete-horizontal-space) | |
| 179 (setq line-length (current-column)) | |
| 180 (if (> (- fill-column lm line-length) 0) | |
| 181 (indent-line-to | |
| 182 (+ lm (/ (- fill-column lm line-length) 2)))))) | |
| 183 (cond ((null nlines) | |
| 184 (setq nlines 0)) | |
| 185 ((> nlines 0) | |
| 186 (setq nlines (1- nlines)) | |
| 187 (forward-line 1)) | |
| 188 ((< nlines 0) | |
| 189 (setq nlines (1+ nlines)) | |
| 190 (forward-line -1))))) | |
| 191 | |
| 192 ;;; text-mode.el ends here |
