comparison lisp/textmodes/paragraphs.el @ 25551:5cd9adabaee5

(backward-kill-sentence): Don't test minibuffer-prompt-end here. (forward-sentence): Do handle it here. (backward-kill-paragraph): Don't test it here. (forward-paragraph): Handle it here.
author Richard M. Stallman <rms@gnu.org>
date Sun, 05 Sep 1999 23:44:56 +0000
parents bf9932dab556
children cf5dd9e8bf79
comparison
equal deleted inserted replaced
25550:05f27fc24f81 25551:5cd9adabaee5
183 (paragraph-separate 183 (paragraph-separate
184 (if fill-prefix-regexp 184 (if fill-prefix-regexp
185 (concat paragraph-separate "\\|" 185 (concat paragraph-separate "\\|"
186 fill-prefix-regexp "[ \t]*$") 186 fill-prefix-regexp "[ \t]*$")
187 paragraph-separate)) 187 paragraph-separate))
188 ;; The end of the prompt is treated as a paragraph boundary.
189 (prompt-end (if (window-minibuffer-p)
190 (minibuffer-prompt-end)
191 1))
192 (orig-point (point))
188 ;; This is used for searching. 193 ;; This is used for searching.
189 (sp-paragraph-start (concat "^[ \t]*\\(" paragraph-start "\\)")) 194 (sp-paragraph-start (concat "^[ \t]*\\(" paragraph-start "\\)"))
190 start found-start) 195 start found-start)
191 (while (and (< arg 0) (not (bobp))) 196 (while (and (< arg 0) (not (bobp)))
192 (if (and (not (looking-at paragraph-separate)) 197 (if (and (not (looking-at paragraph-separate))
283 (and use-hard-newlines 288 (and use-hard-newlines
284 (not (get-text-property (1- start) 'hard))))) 289 (not (get-text-property (1- start) 'hard)))))
285 (forward-char 1)) 290 (forward-char 1))
286 (if (< (point) (point-max)) 291 (if (< (point) (point-max))
287 (goto-char start))) 292 (goto-char start)))
288 (setq arg (1- arg))))) 293 (setq arg (1- arg)))
294 (when (and (< orig-point prompt-end)
295 (< prompt-end (point)))
296 (goto-char prompt-end))
297 (when (and (> orig-point prompt-end)
298 (> prompt-end (point)))
299 (goto-char prompt-end))))
289 300
290 (defun backward-paragraph (&optional arg) 301 (defun backward-paragraph (&optional arg)
291 "Move backward to start of paragraph. 302 "Move backward to start of paragraph.
292 With argument ARG, do it ARG times; 303 With argument ARG, do it ARG times;
293 a negative argument ARG = -N means move forward N paragraphs. 304 a negative argument ARG = -N means move forward N paragraphs.
322 "Kill back to start of paragraph. 333 "Kill back to start of paragraph.
323 With arg N, kill back to Nth start of paragraph; 334 With arg N, kill back to Nth start of paragraph;
324 negative arg -N means kill forward to Nth end of paragraph." 335 negative arg -N means kill forward to Nth end of paragraph."
325 (interactive "*p") 336 (interactive "*p")
326 (let ((start (point)) 337 (let ((start (point))
327 (end (progn (backward-paragraph arg) (point))) 338 (end (progn (backward-paragraph arg) (point))))
328 (prompt-end (minibuffer-prompt-end)))
329 (when (> end prompt-end)
330 (goto-char (setq end prompt-end)))
331 (kill-region start end))) 339 (kill-region start end)))
332 340
333 (defun transpose-paragraphs (arg) 341 (defun transpose-paragraphs (arg)
334 "Interchange this (or next) paragraph with previous one." 342 "Interchange this (or next) paragraph with previous one."
335 (interactive "*p") 343 (interactive "*p")
367 The variable `sentence-end' is a regular expression that matches ends of 375 The variable `sentence-end' is a regular expression that matches ends of
368 sentences. Also, every paragraph boundary terminates sentences as well." 376 sentences. Also, every paragraph boundary terminates sentences as well."
369 (interactive "p") 377 (interactive "p")
370 (or arg (setq arg 1)) 378 (or arg (setq arg 1))
371 (while (< arg 0) 379 (while (< arg 0)
372 (let ((par-beg (save-excursion (start-of-paragraph-text) (point)))) 380 (let ((par-beg (save-excursion (start-of-paragraph-text) (point)))
381 (prompt-end (if (window-minibuffer-p)
382 (minibuffer-prompt-end)
383 1)))
384 (if (and (< prompt-end (point))
385 (> prompt-end par-beg))
386 (setq par-beg prompt-end))
373 (if (re-search-backward (concat sentence-end "[^ \t\n]") par-beg t) 387 (if (re-search-backward (concat sentence-end "[^ \t\n]") par-beg t)
374 (goto-char (1- (match-end 0))) 388 (goto-char (1- (match-end 0)))
375 (goto-char par-beg))) 389 (goto-char par-beg)))
376 (setq arg (1+ arg))) 390 (setq arg (1+ arg)))
377 (while (> arg 0) 391 (while (> arg 0)
378 (let ((par-end (save-excursion (end-of-paragraph-text) (point)))) 392 (let ((par-end (save-excursion (end-of-paragraph-text) (point)))
393 (prompt-end (if (window-minibuffer-p)
394 (minibuffer-prompt-end)
395 1)))
396 (if (and (> prompt-end (point))
397 (< prompt-end par-end))
398 (setq par-end prompt-end))
379 (if (re-search-forward sentence-end par-end t) 399 (if (re-search-forward sentence-end par-end t)
380 (skip-chars-backward " \t\n") 400 (skip-chars-backward " \t\n")
381 (goto-char par-end))) 401 (goto-char par-end)))
382 (setq arg (1- arg)))) 402 (setq arg (1- arg))))
383 403
397 (defun backward-kill-sentence (&optional arg) 417 (defun backward-kill-sentence (&optional arg)
398 "Kill back from point to start of sentence. 418 "Kill back from point to start of sentence.
399 With arg, repeat, or kill forward to Nth end of sentence if negative arg -N." 419 With arg, repeat, or kill forward to Nth end of sentence if negative arg -N."
400 (interactive "*p") 420 (interactive "*p")
401 (let ((start (point)) 421 (let ((start (point))
402 (end (progn (backward-sentence arg) (point))) 422 (end (progn (backward-sentence arg) (point))))
403 (prompt-end (minibuffer-prompt-end)))
404 (when (> end prompt-end)
405 (goto-char (setq end prompt-end)))
406 (kill-region start end))) 423 (kill-region start end)))
407 424
408 (defun mark-end-of-sentence (arg) 425 (defun mark-end-of-sentence (arg)
409 "Put mark at end of sentence. Arg works as in `forward-sentence'." 426 "Put mark at end of sentence. Arg works as in `forward-sentence'."
410 (interactive "p") 427 (interactive "p")