diff options
| author | Richard M. Stallman | 1995-07-30 00:46:23 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-07-30 00:46:23 +0000 |
| commit | e47d38f615079949f284a3e75a42fb7837772ec3 (patch) | |
| tree | eb176d73f03d9487cd20c193bb5beba0c2c7d856 | |
| parent | 2be0173802b140b1a79320b63f7fb7b2db1f6f3f (diff) | |
| download | emacs-e47d38f615079949f284a3e75a42fb7837772ec3.tar.gz emacs-e47d38f615079949f284a3e75a42fb7837772ec3.zip | |
(do-auto-fill): Handle adaptive-fill-function and adaptive-fill-regexp.
(scroll-other-window-down): Bind to S-C-M-v. Enhance documentation.
(next-line): Doc fix.
| -rw-r--r-- | lisp/simple.el | 137 |
1 files changed, 70 insertions, 67 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 031aefd4349..ec133c9b3e1 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -1604,8 +1604,7 @@ column, or at the end of the line if it is not long enough. | |||
| 1604 | If there is no line in the buffer after this one, behavior depends on the | 1604 | If there is no line in the buffer after this one, behavior depends on the |
| 1605 | value of `next-line-add-newlines'. If non-nil, it inserts a newline character | 1605 | value of `next-line-add-newlines'. If non-nil, it inserts a newline character |
| 1606 | to create a line, and moves the cursor to that line. Otherwise it moves the | 1606 | to create a line, and moves the cursor to that line. Otherwise it moves the |
| 1607 | cursor to the end of the buffer (if already at the end of the buffer, an error | 1607 | cursor to the end of the buffer. |
| 1608 | is signaled). | ||
| 1609 | 1608 | ||
| 1610 | The command \\[set-goal-column] can be used to create | 1609 | The command \\[set-goal-column] can be used to create |
| 1611 | a semipermanent goal column to which this command always moves. | 1610 | a semipermanent goal column to which this command always moves. |
| @@ -1876,7 +1875,8 @@ If this is zero, point is always centered after it moves off frame.") | |||
| 1876 | ;; (hscroll-point-visible)) | 1875 | ;; (hscroll-point-visible)) |
| 1877 | 1876 | ||
| 1878 | (defun scroll-other-window-down (lines) | 1877 | (defun scroll-other-window-down (lines) |
| 1879 | "Scroll the \"other window\" down." | 1878 | "Scroll the \"other window\" down. |
| 1879 | For more details, see the documentation for `scroll-other-window'." | ||
| 1880 | (interactive "P") | 1880 | (interactive "P") |
| 1881 | (scroll-other-window | 1881 | (scroll-other-window |
| 1882 | ;; Just invert the argument's meaning. | 1882 | ;; Just invert the argument's meaning. |
| @@ -1884,6 +1884,7 @@ If this is zero, point is always centered after it moves off frame.") | |||
| 1884 | (if (eq lines '-) nil | 1884 | (if (eq lines '-) nil |
| 1885 | (if (null lines) '- | 1885 | (if (null lines) '- |
| 1886 | (- (prefix-numeric-value lines)))))) | 1886 | (- (prefix-numeric-value lines)))))) |
| 1887 | (define-key esc-map [?\C-\S-v] 'scroll-other-window-down) | ||
| 1887 | 1888 | ||
| 1888 | (defun beginning-of-buffer-other-window (arg) | 1889 | (defun beginning-of-buffer-other-window (arg) |
| 1889 | "Move point to the beginning of the buffer in the other window. | 1890 | "Move point to the beginning of the buffer in the other window. |
| @@ -2317,7 +2318,7 @@ Setting this variable automatically makes it local to the current buffer.") | |||
| 2317 | ;; Choose a fill-prefix automatically. | 2318 | ;; Choose a fill-prefix automatically. |
| 2318 | (if (and adaptive-fill-mode | 2319 | (if (and adaptive-fill-mode |
| 2319 | (or (null fill-prefix) (string= fill-prefix ""))) | 2320 | (or (null fill-prefix) (string= fill-prefix ""))) |
| 2320 | (let (start end) | 2321 | (let (start end temp) |
| 2321 | (save-excursion | 2322 | (save-excursion |
| 2322 | (end-of-line) | 2323 | (end-of-line) |
| 2323 | (setq end (point)) | 2324 | (setq end (point)) |
| @@ -2328,71 +2329,73 @@ Setting this variable automatically makes it local to the current buffer.") | |||
| 2328 | ;; because then the next line will probably also become one. | 2329 | ;; because then the next line will probably also become one. |
| 2329 | ;; In text mode, when the user indents the first line of a | 2330 | ;; In text mode, when the user indents the first line of a |
| 2330 | ;; paragraph, we don't want all the lines to be indented. | 2331 | ;; paragraph, we don't want all the lines to be indented. |
| 2331 | (and (not (looking-at paragraph-start)) | 2332 | (if (not (looking-at paragraph-start)) |
| 2332 | (re-search-forward adaptive-fill-regexp end t) | 2333 | (cond ((re-search-forward adaptive-fill-regexp end t) |
| 2333 | (setq fill-prefix | 2334 | (setq fill-prefix |
| 2334 | (buffer-substring-no-properties start (point))))))) | 2335 | (buffer-substring-no-properties start (point)))) |
| 2336 | ((setq temp (funcall adaptive-fill-function)) | ||
| 2337 | (setq fill-prefix temp))))))) | ||
| 2335 | 2338 | ||
| 2336 | (while (and (not give-up) (> (current-column) fc)) | 2339 | (while (and (not give-up) (> (current-column) fc)) |
| 2337 | ;; Determine where to split the line. | 2340 | ;; Determine where to split the line. |
| 2338 | (let ((fill-point | 2341 | (let ((fill-point |
| 2339 | (let ((opoint (point)) | 2342 | (let ((opoint (point)) |
| 2340 | bounce | 2343 | bounce |
| 2341 | (first t)) | 2344 | (first t)) |
| 2342 | (save-excursion | 2345 | (save-excursion |
| 2343 | (move-to-column (1+ fc)) | 2346 | (move-to-column (1+ fc)) |
| 2344 | ;; Move back to a word boundary. | 2347 | ;; Move back to a word boundary. |
| 2345 | (while (or first | 2348 | (while (or first |
| 2346 | ;; If this is after period and a single space, | 2349 | ;; If this is after period and a single space, |
| 2347 | ;; move back once more--we don't want to break | 2350 | ;; move back once more--we don't want to break |
| 2348 | ;; the line there and make it look like a | 2351 | ;; the line there and make it look like a |
| 2349 | ;; sentence end. | 2352 | ;; sentence end. |
| 2350 | (and (not (bobp)) | 2353 | (and (not (bobp)) |
| 2351 | (not bounce) | 2354 | (not bounce) |
| 2352 | sentence-end-double-space | 2355 | sentence-end-double-space |
| 2353 | (save-excursion (forward-char -1) | 2356 | (save-excursion (forward-char -1) |
| 2354 | (and (looking-at "\\. ") | 2357 | (and (looking-at "\\. ") |
| 2355 | (not (looking-at "\\. ")))))) | 2358 | (not (looking-at "\\. ")))))) |
| 2356 | (setq first nil) | 2359 | (setq first nil) |
| 2357 | (skip-chars-backward "^ \t\n") | 2360 | (skip-chars-backward "^ \t\n") |
| 2358 | ;; If we find nowhere on the line to break it, | 2361 | ;; If we find nowhere on the line to break it, |
| 2359 | ;; break after one word. Set bounce to t | 2362 | ;; break after one word. Set bounce to t |
| 2360 | ;; so we will not keep going in this while loop. | 2363 | ;; so we will not keep going in this while loop. |
| 2361 | (if (bolp) | 2364 | (if (bolp) |
| 2362 | (progn | 2365 | (progn |
| 2363 | (re-search-forward "[ \t]" opoint t) | 2366 | (re-search-forward "[ \t]" opoint t) |
| 2364 | (setq bounce t))) | 2367 | (setq bounce t))) |
| 2365 | (skip-chars-backward " \t")) | 2368 | (skip-chars-backward " \t")) |
| 2366 | ;; Let fill-point be set to the place where we end up. | 2369 | ;; Let fill-point be set to the place where we end up. |
| 2367 | (point))))) | 2370 | (point))))) |
| 2368 | ;; If that place is not the beginning of the line, | 2371 | ;; If that place is not the beginning of the line, |
| 2369 | ;; break the line there. | 2372 | ;; break the line there. |
| 2370 | (if (save-excursion | 2373 | (if (save-excursion |
| 2371 | (goto-char fill-point) | 2374 | (goto-char fill-point) |
| 2372 | (not (bolp))) | 2375 | (not (bolp))) |
| 2373 | (let ((prev-column (current-column))) | 2376 | (let ((prev-column (current-column))) |
| 2374 | ;; If point is at the fill-point, do not `save-excursion'. | 2377 | ;; If point is at the fill-point, do not `save-excursion'. |
| 2375 | ;; Otherwise, if a comment prefix or fill-prefix is inserted, | 2378 | ;; Otherwise, if a comment prefix or fill-prefix is inserted, |
| 2376 | ;; point will end up before it rather than after it. | 2379 | ;; point will end up before it rather than after it. |
| 2377 | (if (save-excursion | 2380 | (if (save-excursion |
| 2378 | (skip-chars-backward " \t") | 2381 | (skip-chars-backward " \t") |
| 2379 | (= (point) fill-point)) | 2382 | (= (point) fill-point)) |
| 2380 | (indent-new-comment-line t) | 2383 | (indent-new-comment-line t) |
| 2381 | (save-excursion | 2384 | (save-excursion |
| 2382 | (goto-char fill-point) | 2385 | (goto-char fill-point) |
| 2383 | (indent-new-comment-line t))) | 2386 | (indent-new-comment-line t))) |
| 2384 | ;; Now do justification, if required | 2387 | ;; Now do justification, if required |
| 2385 | (if (not (eq justify 'left)) | 2388 | (if (not (eq justify 'left)) |
| 2386 | (save-excursion | 2389 | (save-excursion |
| 2387 | (end-of-line 0) | 2390 | (end-of-line 0) |
| 2388 | (justify-current-line justify nil t))) | 2391 | (justify-current-line justify nil t))) |
| 2389 | ;; If making the new line didn't reduce the hpos of | 2392 | ;; If making the new line didn't reduce the hpos of |
| 2390 | ;; the end of the line, then give up now; | 2393 | ;; the end of the line, then give up now; |
| 2391 | ;; trying again will not help. | 2394 | ;; trying again will not help. |
| 2392 | (if (>= (current-column) prev-column) | 2395 | (if (>= (current-column) prev-column) |
| 2393 | (setq give-up t))) | 2396 | (setq give-up t))) |
| 2394 | ;; No place to break => stop trying. | 2397 | ;; No place to break => stop trying. |
| 2395 | (setq give-up t)))) | 2398 | (setq give-up t)))) |
| 2396 | ;; justify last line | 2399 | ;; justify last line |
| 2397 | (justify-current-line justify t t)))) | 2400 | (justify-current-line justify t t)))) |
| 2398 | 2401 | ||