Mercurial > emacs
annotate lisp/textmodes/paragraphs.el @ 1717:aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
`has_vertical_scrollbars'.
(FRAME_CAN_HAVE_SCROLLBARS, FRAME_HAS_VERTICAL_SCROLLBARS): New
accessors, for both the MULTI_FRAME and non-MULTI_FRAME.
(VERTICAL_SCROLLBAR_WIDTH, WINDOW_VERTICAL_SCROLLBAR,
WINDOW_VERTICAL_SCROLLBAR_COLUMN,
WINDOW_VERTICAL_SCROLLBAR_HEIGHT): New macros.
* window.h (struct window): New field `vertical_scrollbar'.
* xterm.h (struct x_display): vertical_scrollbars,
judge_timestamp, vertical_scrollbar_extra: New fields.
(struct scrollbar): New struct.
(VERTICAL_SCROLLBAR_PIXEL_WIDTH, VERTICAL_SCROLLBAR_PIXEL_HEIGHT,
VERTICAL_SCROLLBAR_LEFT_BORDER, VERTICAL_SCROLLBAR_RIGHT_BORDER,
VERTICAL_SCROLLBAR_TOP_BORDER, VERTICAL_SCROLLBAR_BOTTOM_BORDER,
CHAR_TO_PIXEL_WIDTH, CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_WIDTH,
PIXEL_TO_CHAR_HEIGHT): New accessors and macros.
* frame.c (make_frame): Initialize the `can_have_scrollbars' and
`has_vertical_scrollbars' fields of the frame.
* term.c (term_init): Note that TERMCAP terminals don't support
scrollbars.
(mouse_position_hook): Document new args.
(set_vertical_scrollbar_hook, condemn_scrollbars_hook,
redeem_scrollbar_hook, judge_scrollbars_hook): New hooks.
* termhooks.h: Declare and document them.
(enum scrollbar_part): New type.
(struct input_event): Describe the new form of the scrollbar_click
event type. Change `part' from a Lisp_Object to an enum
scrollbar_part. Add a new field `scrollbar'.
* keyboard.c (kbd_buffer_get_event): Pass appropriate new
parameters to *mouse_position_hook, and make_lispy_movement.
* xfns.c (x_set_vertical_scrollbar): New function.
(x_figure_window_size): Use new macros to calculate frame size.
(Fx_create_frame): Note that X Windows frames do support scroll
bars. Default to "yes".
* xterm.c: #include <X11/cursorfont.h> and "window.h".
(x_vertical_scrollbar_cursor): New variable.
(x_term_init): Initialize it.
(last_mouse_bar, last_mouse_bar_frame, last_mouse_part,
last_mouse_scroll_range_start, last_mouse_scroll_range_end): New
variables.
(XTmouse_position): Use them to return scrollbar movement events.
Take new arguments, for that purpose.
(x_window_to_scrollbar, x_scrollbar_create,
x_scrollbar_set_handle, x_scrollbar_remove, x_scrollbar_move,
XTset_scrollbar, XTcondemn_scrollbars, XTredeem_scrollbar,
XTjudge_scrollbars, x_scrollbar_expose,
x_scrollbar_background_expose, x_scrollbar_handle_click,
x_scrollbar_handle_motion): New functions to implement scrollbars.
(x_term_init): Set the termhooks.h hooks to point to them.
(x_set_window_size): Use new macros to calculate frame size. Set
vertical_scrollbar_extra field.
(x_make_frame_visible): Use the frame accessor
FRAME_HAS_VERTICAL_SCROLLBARS to decide if we need to map the
frame's subwindows as well.
(XTread_socket): Use new size-calculation macros from xterm.h when
processing ConfigureNotify events.
(x_wm_set_size_hint): Use PIXEL_TO_CHAR_WIDTH and
PIXEL_TO_CHAR_HEIGHT macros.
* ymakefile (xdisp.o): This now depends on termhooks.h.
(xterm.o): This now depends on window.h.
| author | Jim Blandy <jimb@redhat.com> |
|---|---|
| date | Thu, 24 Dec 1992 06:17:18 +0000 |
| parents | 876e54ad6936 |
| children | f287613dfc28 |
| rev | line source |
|---|---|
|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
1 ;;; paragraphs.el --- paragraph and sentence parsing. |
|
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
2 |
| 845 | 3 ;; Copyright (C) 1985, 86, 87, 1991 Free Software Foundation, Inc. |
| 4 | |
|
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
5 ;; Maintainer: FSF |
|
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
804
diff
changeset
|
6 ;; Keywords: wp |
|
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
7 |
| 36 | 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 | |
| 804 | 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 | |
| 21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
| 22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 23 | |
|
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
24 ;;; Code: |
| 36 | 25 |
| 269 | 26 (defconst paragraph-start "^[ \t\n\f]" "\ |
| 27 *Regexp for beginning of a line that starts OR separates paragraphs.") | |
| 264 | 28 |
| 269 | 29 (defconst paragraph-separate "^[ \t\f]*$" "\ |
| 30 *Regexp for beginning of a line that separates paragraphs. | |
| 31 If you change this, you may have to change paragraph-start also.") | |
| 264 | 32 |
| 269 | 33 (defconst sentence-end (purecopy "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*") "\ |
| 34 *Regexp describing the end of a sentence. | |
| 35 All paragraph boundaries also end sentences, regardless.") | |
| 264 | 36 |
| 269 | 37 (defconst page-delimiter "^\014" "\ |
| 38 *Regexp describing line-beginnings that separate pages.") | |
| 264 | 39 |
| 269 | 40 (defvar paragraph-ignore-fill-prefix nil "\ |
| 41 Non-nil means the paragraph commands are not affected by `fill-prefix'. | |
| 42 This is desirable in modes where blank lines are the paragraph delimiters.") | |
| 264 | 43 |
| 36 | 44 |
| 45 (defun forward-paragraph (&optional arg) | |
| 46 "Move forward to end of paragraph. | |
| 47 With arg N, do it N times; negative arg -N means move forward N paragraphs. | |
| 48 | |
| 49 A line which `paragraph-start' matches either separates paragraphs | |
| 50 \(if `paragraph-separate' matches it also) or is the first line of a paragraph. | |
| 51 A paragraph end is the beginning of a line which is not part of the paragraph | |
| 52 to which the end of the previous line belongs, or the end of the buffer." | |
| 53 (interactive "p") | |
| 54 (or arg (setq arg 1)) | |
| 55 (let* ((fill-prefix-regexp | |
| 56 (and fill-prefix (not (equal fill-prefix "")) | |
| 57 (not paragraph-ignore-fill-prefix) | |
| 58 (regexp-quote fill-prefix))) | |
| 59 (paragraph-separate | |
| 60 (if fill-prefix-regexp | |
| 61 (concat paragraph-separate "\\|^" | |
| 62 fill-prefix-regexp "[ \t]*$") | |
| 63 paragraph-separate))) | |
| 64 (while (< arg 0) | |
| 65 (if (and (not (looking-at paragraph-separate)) | |
| 66 (re-search-backward "^\n" (max (1- (point)) (point-min)) t)) | |
| 67 nil | |
| 68 (forward-char -1) (beginning-of-line) | |
| 69 (while (and (not (bobp)) (looking-at paragraph-separate)) | |
| 70 (forward-line -1)) | |
| 71 (end-of-line) | |
| 72 ;; Search back for line that starts or separates paragraphs. | |
| 73 (if (if fill-prefix-regexp | |
| 74 ;; There is a fill prefix; it overrides paragraph-start. | |
| 75 (progn | |
| 76 (while (progn (beginning-of-line) | |
| 77 (and (not (bobp)) | |
| 78 (not (looking-at paragraph-separate)) | |
| 79 (looking-at fill-prefix-regexp))) | |
| 80 (forward-line -1)) | |
| 81 (not (bobp))) | |
| 82 (re-search-backward paragraph-start nil t)) | |
| 83 ;; Found one. | |
| 84 (progn | |
| 85 (while (and (not (eobp)) (looking-at paragraph-separate)) | |
| 86 (forward-line 1)) | |
| 87 (if (eq (char-after (- (point) 2)) ?\n) | |
| 88 (forward-line -1))) | |
| 89 ;; No starter or separator line => use buffer beg. | |
| 90 (goto-char (point-min)))) | |
| 91 (setq arg (1+ arg))) | |
| 92 (while (> arg 0) | |
| 93 (beginning-of-line) | |
| 94 (while (prog1 (and (not (eobp)) | |
| 95 (looking-at paragraph-separate)) | |
| 96 (forward-line 1))) | |
| 97 (if fill-prefix-regexp | |
| 98 ;; There is a fill prefix; it overrides paragraph-start. | |
| 99 (while (and (not (eobp)) | |
| 100 (not (looking-at paragraph-separate)) | |
| 101 (looking-at fill-prefix-regexp)) | |
| 102 (forward-line 1)) | |
| 103 (if (re-search-forward paragraph-start nil t) | |
| 104 (goto-char (match-beginning 0)) | |
| 105 (goto-char (point-max)))) | |
| 106 (setq arg (1- arg))))) | |
| 107 | |
| 108 (defun backward-paragraph (&optional arg) | |
| 109 "Move backward to start of paragraph. | |
| 110 With arg N, do it N times; negative arg -N means move forward N paragraphs. | |
| 111 | |
| 237 | 112 A paragraph start is the beginning of a line which is a |
| 113 `first-line-of-paragraph' or which is ordinary text and follows a | |
| 114 paragraph-separating line; except: if the first real line of a | |
| 115 paragraph is preceded by a blank line, the paragraph starts at that | |
| 116 blank line. | |
| 117 | |
| 118 See `forward-paragraph' for more information." | |
| 36 | 119 (interactive "p") |
| 120 (or arg (setq arg 1)) | |
| 121 (forward-paragraph (- arg))) | |
| 122 | |
| 123 (defun mark-paragraph () | |
| 124 "Put point at beginning of this paragraph, mark at end. | |
| 125 The paragraph marked is the one that contains point or follows point." | |
| 126 (interactive) | |
| 127 (forward-paragraph 1) | |
| 128 (push-mark nil t) | |
| 129 (backward-paragraph 1)) | |
| 130 | |
| 131 (defun kill-paragraph (arg) | |
| 132 "Kill forward to end of paragraph. | |
| 133 With arg N, kill forward to Nth end of paragraph; | |
| 134 negative arg -N means kill backward to Nth start of paragraph." | |
| 237 | 135 (interactive "p") |
|
1435
4fef92b213f6
(kill-sentence, backward-kill-sentence):
Richard M. Stallman <rms@gnu.org>
parents:
845
diff
changeset
|
136 (kill-region (point) (save-excursion (forward-paragraph arg) (point)))) |
| 36 | 137 |
| 138 (defun backward-kill-paragraph (arg) | |
| 139 "Kill back to start of paragraph. | |
| 140 With arg N, kill back to Nth start of paragraph; | |
| 141 negative arg -N means kill forward to Nth end of paragraph." | |
| 237 | 142 (interactive "p") |
|
1435
4fef92b213f6
(kill-sentence, backward-kill-sentence):
Richard M. Stallman <rms@gnu.org>
parents:
845
diff
changeset
|
143 (kill-region (point) (save-excursion (backward-paragraph arg) (point)))) |
| 36 | 144 |
| 145 (defun transpose-paragraphs (arg) | |
| 146 "Interchange this (or next) paragraph with previous one." | |
| 147 (interactive "*p") | |
| 148 (transpose-subr 'forward-paragraph arg)) | |
| 149 | |
| 150 (defun start-of-paragraph-text () | |
| 151 (let ((opoint (point)) npoint) | |
| 152 (forward-paragraph -1) | |
| 153 (setq npoint (point)) | |
| 154 (skip-chars-forward " \t\n") | |
| 68 | 155 ;; If the range of blank lines found spans the original start point, |
| 156 ;; try again from the beginning of it. | |
| 157 ;; Must be careful to avoid infinite loop | |
| 158 ;; when following a single return at start of buffer. | |
| 159 (if (and (>= (point) opoint) (< npoint opoint)) | |
| 36 | 160 (progn |
| 161 (goto-char npoint) | |
| 162 (if (> npoint (point-min)) | |
| 163 (start-of-paragraph-text)))))) | |
| 164 | |
| 165 (defun end-of-paragraph-text () | |
| 166 (let ((opoint (point))) | |
| 167 (forward-paragraph 1) | |
| 168 (if (eq (preceding-char) ?\n) (forward-char -1)) | |
| 169 (if (<= (point) opoint) | |
| 170 (progn | |
| 171 (forward-char 1) | |
| 172 (if (< (point) (point-max)) | |
| 173 (end-of-paragraph-text)))))) | |
| 174 | |
| 175 (defun forward-sentence (&optional arg) | |
| 237 | 176 "Move forward to next`sentence-end'. With argument, repeat. |
| 177 With negative argument, move backward repeatedly to `sentence-beginning'. | |
| 36 | 178 |
| 237 | 179 The variable `sentence-end' is a regular expression that matches ends of |
| 180 sentences. Also, every paragraph boundary terminates sentences as well." | |
| 36 | 181 (interactive "p") |
| 182 (or arg (setq arg 1)) | |
| 183 (while (< arg 0) | |
| 184 (let ((par-beg (save-excursion (start-of-paragraph-text) (point)))) | |
| 185 (if (re-search-backward (concat sentence-end "[^ \t\n]") par-beg t) | |
| 186 (goto-char (1- (match-end 0))) | |
| 187 (goto-char par-beg))) | |
| 188 (setq arg (1+ arg))) | |
| 189 (while (> arg 0) | |
| 190 (let ((par-end (save-excursion (end-of-paragraph-text) (point)))) | |
| 191 (if (re-search-forward sentence-end par-end t) | |
| 192 (skip-chars-backward " \t\n") | |
| 193 (goto-char par-end))) | |
| 194 (setq arg (1- arg)))) | |
| 195 | |
| 196 (defun backward-sentence (&optional arg) | |
| 197 "Move backward to start of sentence. With arg, do it arg times. | |
| 237 | 198 See `forward-sentence' for more information." |
| 36 | 199 (interactive "p") |
| 200 (or arg (setq arg 1)) | |
| 201 (forward-sentence (- arg))) | |
| 202 | |
| 203 (defun kill-sentence (&optional arg) | |
| 204 "Kill from point to end of sentence. | |
| 205 With arg, repeat; negative arg -N means kill back to Nth start of sentence." | |
| 206 (interactive "*p") | |
|
1435
4fef92b213f6
(kill-sentence, backward-kill-sentence):
Richard M. Stallman <rms@gnu.org>
parents:
845
diff
changeset
|
207 (kill-region (point) (save-excursion (forward-sentence arg) (point)))) |
| 36 | 208 |
| 209 (defun backward-kill-sentence (&optional arg) | |
| 210 "Kill back from point to start of sentence. | |
| 211 With arg, repeat, or kill forward to Nth end of sentence if negative arg -N." | |
| 212 (interactive "*p") | |
|
1462
876e54ad6936
(backward-kill-sentence): Fix typo in last change.
Richard M. Stallman <rms@gnu.org>
parents:
1435
diff
changeset
|
213 (kill-region (point) (save-excursion (backward-sentence arg) (point)))) |
| 36 | 214 |
| 215 (defun mark-end-of-sentence (arg) | |
| 237 | 216 "Put mark at end of sentence. Arg works as in `forward-sentence'." |
| 36 | 217 (interactive "p") |
| 218 (push-mark | |
| 219 (save-excursion | |
| 220 (forward-sentence arg) | |
| 221 (point)))) | |
| 222 | |
| 223 (defun transpose-sentences (arg) | |
| 224 "Interchange this (next) and previous sentence." | |
| 225 (interactive "*p") | |
| 226 (transpose-subr 'forward-sentence arg)) | |
|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
227 |
|
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
269
diff
changeset
|
228 ;;; paragraphs.el ends here |
