/[emacs]/emacs/lisp/textmodes/paragraphs.el
ViewVC logotype

Diff of /emacs/lisp/textmodes/paragraphs.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.60 by kai, Sun Feb 17 15:07:35 2002 UTC revision 1.60.4.1 by miles, Fri Apr 4 06:20:37 2003 UTC
# Line 43  only considered as a candidate to match Line 43  only considered as a candidate to match
43    
44  Prefix argument says to turn mode on if positive, off if negative.  Prefix argument says to turn mode on if positive, off if negative.
45  When the mode is turned on, if there are newlines in the buffer but no hard  When the mode is turned on, if there are newlines in the buffer but no hard
46  newlines, ask the user whether to mark as hard any newlines preceeding a  newlines, ask the user whether to mark as hard any newlines preceeding a
47  `paragraph-start' line.  From a program, second arg INSERT specifies whether  `paragraph-start' line.  From a program, second arg INSERT specifies whether
48  to do this; it can be `never' to change nothing, t or `always' to force  to do this; it can be `never' to change nothing, t or `always' to force
49  marking, `guess' to try to do the right thing with no questions, nil  marking, `guess' to try to do the right thing with no questions, nil
50  or anything else to ask the user.  or anything else to ask the user.
51    
52  Newlines not marked hard are called \"soft\", and are always internal  Newlines not marked hard are called \"soft\", and are always internal
53  to paragraphs.  The fill functions insert and delete only soft newlines."  to paragraphs.  The fill functions insert and delete only soft newlines."
54      :group 'paragraphs
55    :extra-args (insert)    :extra-args (insert)
56    (when use-hard-newlines    (when use-hard-newlines
57      ;; Turn mode on      ;; Turn mode on
# Line 136  without a period." Line 137  without a period."
137     ;; This is a bit stupid since it's not auto-updated when the     ;; This is a bit stupid since it's not auto-updated when the
138     ;; other variables are changes, but it's still useful info.     ;; other variables are changes, but it's still useful info.
139     (concat (if sentence-end-without-period "\\w  \\|")     (concat (if sentence-end-without-period "\\w  \\|")
140             "[.?!][]\"')}]*"             "[.?!$B!#!%!)!*$A!##.#?#!$(0!$!%!)!*$(G!$!%!)!*(B][]\"')}]*"
141             (if sentence-end-double-space             (if sentence-end-double-space
142                 "\\($\\| $\\|\t\\|  \\)" "\\($\\|[\t ]\\)")                 "\\($\\| $\\|\t\\|  \\)" "\\($\\|[\t ]\\)")
143             "[ \t\n]*"))             "[ \t\n]*"))
# Line 173  a negative argument ARG = -N means move Line 174  a negative argument ARG = -N means move
174  A line which `paragraph-start' matches either separates paragraphs  A line which `paragraph-start' matches either separates paragraphs
175  \(if `paragraph-separate' matches it also) or is the first line of a paragraph.  \(if `paragraph-separate' matches it also) or is the first line of a paragraph.
176  A paragraph end is the beginning of a line which is not part of the paragraph  A paragraph end is the beginning of a line which is not part of the paragraph
177  to which the end of the previous line belongs, or the end of the buffer."  to which the end of the previous line belongs, or the end of the buffer.
178    Returns the count of paragraphs left to move."
179    (interactive "p")    (interactive "p")
180    (or arg (setq arg 1))    (or arg (setq arg 1))
181    (let* ((opoint (point))    (let* ((opoint (point))
# Line 206  to which the end of the previous line be Line 208  to which the end of the previous line be
208        (if (and (not (looking-at parsep))        (if (and (not (looking-at parsep))
209                 (re-search-backward "^\n" (max (1- (point)) (point-min)) t)                 (re-search-backward "^\n" (max (1- (point)) (point-min)) t)
210                 (looking-at parsep))                 (looking-at parsep))
211            nil            (setq arg (1+ arg))
212          (setq start (point))          (setq start (point))
213          ;; Move back over paragraph-separating lines.          ;; Move back over paragraph-separating lines.
214          (forward-char -1) (beginning-of-line)          (forward-char -1) (beginning-of-line)
# Line 216  to which the end of the previous line be Line 218  to which the end of the previous line be
218            (forward-line -1))            (forward-line -1))
219          (if (bobp)          (if (bobp)
220              nil              nil
221              (setq arg (1+ arg))
222            ;; Go to end of the previous (non-separating) line.            ;; Go to end of the previous (non-separating) line.
223            (end-of-line)            (end-of-line)
224            ;; Search back for line that starts or separates paragraphs.            ;; Search back for line that starts or separates paragraphs.
# Line 253  to which the end of the previous line be Line 256  to which the end of the previous line be
256                    (setq found-start nil)                    (setq found-start nil)
257                    (goto-char start))                    (goto-char start))
258                  found-start)                  found-start)
259              ;; Found one.                ;; Found one.
260              (progn                (progn
261                  ;; Move forward over paragraph separators.                  ;; Move forward over paragraph separators.
262                  ;; We know this cannot reach the place we started                  ;; We know this cannot reach the place we started
263                  ;; because we know we moved back over a non-separator.                  ;; because we know we moved back over a non-separator.
# Line 270  to which the end of the previous line be Line 273  to which the end of the previous line be
273                    (if (not (bolp))                    (if (not (bolp))
274                        (forward-line 1))))                        (forward-line 1))))
275              ;; No starter or separator line => use buffer beg.              ;; No starter or separator line => use buffer beg.
276              (goto-char (point-min)))))              (goto-char (point-min))))))
       (setq arg (1+ arg)))  
277    
278      (while (and (> arg 0) (not (eobp)))      (while (and (> arg 0) (not (eobp)))
279        ;; Move forward over separator lines, and one more line.        ;; Move forward over separator lines...
280        (while (prog1 (and (not (eobp))        (while (and (not (eobp))
281                           (progn (move-to-left-margin) (not (eobp)))                    (progn (move-to-left-margin) (not (eobp)))
282                           (looking-at parsep))                    (looking-at parsep))
283                 (forward-line 1)))          (forward-line 1))
284          (unless (eobp) (setq arg (1- arg)))
285          ;; ... and one more line.
286          (forward-line 1)
287        (if fill-prefix-regexp        (if fill-prefix-regexp
288            ;; There is a fill prefix; it overrides parstart.            ;; There is a fill prefix; it overrides parstart.
289            (while (and (not (eobp))            (while (and (not (eobp))
# Line 297  to which the end of the previous line be Line 302  to which the end of the previous line be
302                               (not (get-text-property (1- start) 'hard)))))                               (not (get-text-property (1- start) 'hard)))))
303            (forward-char 1))            (forward-char 1))
304          (if (< (point) (point-max))          (if (< (point) (point-max))
305              (goto-char start)))              (goto-char start))))
306        (setq arg (1- arg)))      (constrain-to-field nil opoint t)
307      (constrain-to-field nil opoint t)))      ;; Return the number of steps that could not be done.
308        arg))
309    
310  (defun backward-paragraph (&optional arg)  (defun backward-paragraph (&optional arg)
311    "Move backward to start of paragraph.    "Move backward to start of paragraph.
# Line 451  ones already marked." Line 457  ones already marked."
457    (interactive "*p")    (interactive "*p")
458    (transpose-subr 'forward-sentence arg))    (transpose-subr 'forward-sentence arg))
459    
460    ;;; Local Variables:
461    ;;; coding: iso-2022-7bit
462    ;;; End:
463    
464  ;;; paragraphs.el ends here  ;;; paragraphs.el ends here

Legend:
Removed from v.1.60  
changed lines
  Added in v.1.60.4.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26