comparison lisp/prim/simple.el @ 110:fe104dbd9147 r20-1b7

Import from CVS: tag r20-1b7
author cvs
date Mon, 13 Aug 2007 09:19:45 +0200
parents 360340f9fd5f
children cca96a509cfe
comparison
equal deleted inserted replaced
109:e183fc049578 110:fe104dbd9147
49 ;; push a mark) have been altered to call exchange-point-and-mark with an 49 ;; push a mark) have been altered to call exchange-point-and-mark with an
50 ;; argument, meaning "don't activate the region". These commands only use 50 ;; argument, meaning "don't activate the region". These commands only use
51 ;; exchange-point-and-mark to position the newly-pushed mark correctly, so 51 ;; exchange-point-and-mark to position the newly-pushed mark correctly, so
52 ;; this isn't a user-visible change. These functions have also been altered 52 ;; this isn't a user-visible change. These functions have also been altered
53 ;; to use (mark t) for the same reason. 53 ;; to use (mark t) for the same reason.
54
55 ;; 97/3/14 Jareth Hein (jhod@po.iijnet.or.jp) added kinsoku processing (support
56 ;; for filling of Asian text) into the fill code. This was ripped bleeding from
57 ;; Mule-2.3, and could probably use some feature additions (like additional wrap
58 ;; styles, etc)
54 59
55 ;;; Code: 60 ;;; Code:
56 61
57 (defun newline (&optional arg) 62 (defun newline (&optional arg)
58 "Insert a newline, and move to left margin of the new line if it's blank. 63 "Insert a newline, and move to left margin of the new line if it's blank.
2211 ;; Determine where to split the line. 2216 ;; Determine where to split the line.
2212 (let ((fill-prefix fill-prefix) 2217 (let ((fill-prefix fill-prefix)
2213 (fill-point 2218 (fill-point
2214 (let ((opoint (point)) 2219 (let ((opoint (point))
2215 bounce 2220 bounce
2221 ;; 97/3/14 jhod: Kinsoku
2222 (re-break-point (if (featurep 'mule)
2223 (concat "[ \t\n]\\|" word-across-newline)
2224 "[ \t\n]"))
2225 ;; end patch
2216 (first t)) 2226 (first t))
2217 (save-excursion 2227 (save-excursion
2218 (move-to-column (1+ fill-column)) 2228 (move-to-column (1+ fill-column))
2219 ;; Move back to a word boundary. 2229 ;; Move back to a word boundary.
2220 (while (or first 2230 (while (or first
2227 sentence-end-double-space 2237 sentence-end-double-space
2228 (save-excursion (forward-char -1) 2238 (save-excursion (forward-char -1)
2229 (and (looking-at "\\. ") 2239 (and (looking-at "\\. ")
2230 (not (looking-at "\\. ")))))) 2240 (not (looking-at "\\. "))))))
2231 (setq first nil) 2241 (setq first nil)
2232 (skip-chars-backward "^ \t\n") 2242 ;; 97/3/14 jhod: Kinsoku
2243 ; (skip-chars-backward "^ \t\n"))
2244 (fill-move-backward-to-break-point re-break-point)
2245 ;; end patch
2233 ;; If we find nowhere on the line to break it, 2246 ;; If we find nowhere on the line to break it,
2234 ;; break after one word. Set bounce to t 2247 ;; break after one word. Set bounce to t
2235 ;; so we will not keep going in this while loop. 2248 ;; so we will not keep going in this while loop.
2236 (if (bolp) 2249 (if (bolp)
2237 (progn 2250 (progn
2238 (re-search-forward "[ \t]" opoint t) 2251 ;; 97/3/14 jhod: Kinsoku
2252 ; (re-search-forward "[ \t]" opoint t)
2253 (fill-move-forward-to-break-point re-break-point
2254 opoint)
2255 ;; end patch
2239 (setq bounce t))) 2256 (setq bounce t)))
2240 (skip-chars-backward " \t")) 2257 (skip-chars-backward " \t"))
2258 (if (and (featurep 'mule)
2259 (or bounce (bolp))) (kinsoku-process)) ;; 97/3/14 jhod: Kinsoku
2241 ;; Let fill-point be set to the place where we end up. 2260 ;; Let fill-point be set to the place where we end up.
2242 (point))))) 2261 (point)))))
2243 2262
2244 ;; I'm not sure why Stig made this change but it breaks 2263 ;; I'm not sure why Stig made this change but it breaks
2245 ;; auto filling in at least C mode so I'm taking it back 2264 ;; auto filling in at least C mode so I'm taking it back
2254 2273
2255 ;; If that place is not the beginning of the line, 2274 ;; If that place is not the beginning of the line,
2256 ;; break the line there. 2275 ;; break the line there.
2257 (if (save-excursion 2276 (if (save-excursion
2258 (goto-char fill-point) 2277 (goto-char fill-point)
2259 (not (bolp))) 2278 (not (or (bolp) (eolp)))) ; 97/3/14 jhod: during kinsoku processing it is possible to move beyond
2260 (let ((prev-column (current-column))) 2279 (let ((prev-column (current-column)))
2261 ;; If point is at the fill-point, do not `save-excursion'. 2280 ;; If point is at the fill-point, do not `save-excursion'.
2262 ;; Otherwise, if a comment prefix or fill-prefix is inserted, 2281 ;; Otherwise, if a comment prefix or fill-prefix is inserted,
2263 ;; point will end up before it rather than after it. 2282 ;; point will end up before it rather than after it.
2264 (if (save-excursion 2283 (if (save-excursion
2265 (skip-chars-backward " \t") 2284 (skip-chars-backward " \t")
2266 (= (point) fill-point)) 2285 (= (point) fill-point))
2267 (indent-new-comment-line) 2286 ;; 97/3/14 jhod: Kinsoku processing
2287 ;(indent-new-comment-line)
2288 (let ((spacep (memq (preceding-char) '(?\ ?\t))))
2289 (indent-new-comment-line)
2290 ;; if user type space explicitly, leave SPC
2291 ;; even if there is no WAN.
2292 (if spacep
2293 (save-excursion
2294 (goto-char fill-point)
2295 ;; put SPC except that there is SPC
2296 ;; already or there is sentence end.
2297 (or (memq (following-char) '(?\ ?\t))
2298 (fill-end-of-sentence-p)
2299 (insert ?\ )))))
2268 (save-excursion 2300 (save-excursion
2269 (goto-char fill-point) 2301 (goto-char fill-point)
2270 (indent-new-comment-line))) 2302 (indent-new-comment-line)))
2271 ;; If making the new line didn't reduce the hpos of 2303 ;; If making the new line didn't reduce the hpos of
2272 ;; the end of the line, then give up now; 2304 ;; the end of the line, then give up now;
2399 (defun turn-on-auto-fill () 2431 (defun turn-on-auto-fill ()
2400 "Unconditionally turn on Auto Fill mode." 2432 "Unconditionally turn on Auto Fill mode."
2401 (auto-fill-mode 1)) 2433 (auto-fill-mode 1))
2402 2434
2403 (defun set-fill-column (arg) 2435 (defun set-fill-column (arg)
2404 "Set `fill-column' to current column, or to argument if given. 2436 "Set `fill-column' to specified argument.
2437 Just \\[universal-argument] as argument means to use the current column
2405 The variable `fill-column' has a separate value for each buffer." 2438 The variable `fill-column' has a separate value for each buffer."
2406 (interactive "_P") ; XEmacs 2439 (interactive "_P") ; XEmacs
2407 (cond ((integerp arg) 2440 (cond ((integerp arg)
2408 (setq fill-column arg)) 2441 (setq fill-column arg))
2409 ((consp arg) 2442 ((consp arg)
2433 The inserted newline is marked hard if `use-hard-newlines' is true, 2466 The inserted newline is marked hard if `use-hard-newlines' is true,
2434 unless optional argument SOFT is non-nil." 2467 unless optional argument SOFT is non-nil."
2435 (interactive) 2468 (interactive)
2436 (let (comcol comstart) 2469 (let (comcol comstart)
2437 (skip-chars-backward " \t") 2470 (skip-chars-backward " \t")
2471 ;; 97/3/14 jhod: Kinsoku processing
2472 (if (featurep 'mule)
2473 (kinsoku-process))
2438 (delete-region (point) 2474 (delete-region (point)
2439 (progn (skip-chars-forward " \t") 2475 (progn (skip-chars-forward " \t")
2440 (point))) 2476 (point)))
2441 (if soft (insert ?\n) (newline 1)) 2477 (if soft (insert ?\n) (newline 1))
2442 (if fill-prefix 2478 (if fill-prefix
2445 (insert fill-prefix)) 2481 (insert fill-prefix))
2446 ;; #### - Eric Eide reverts to v18 semantics for this function in 2482 ;; #### - Eric Eide reverts to v18 semantics for this function in
2447 ;; fa-extras, which I'm not gonna do. His changes are to (1) execute 2483 ;; fa-extras, which I'm not gonna do. His changes are to (1) execute
2448 ;; the save-excursion below unconditionally, and (2) uncomment the check 2484 ;; the save-excursion below unconditionally, and (2) uncomment the check
2449 ;; for (not comment-multi-line) further below. --Stig 2485 ;; for (not comment-multi-line) further below. --Stig
2486 ;;### jhod: probably need to fix this for kinsoku processing
2450 (if (not comment-multi-line) 2487 (if (not comment-multi-line)
2451 (save-excursion 2488 (save-excursion
2452 (if (and comment-start-skip 2489 (if (and comment-start-skip
2453 (let ((opoint (point))) 2490 (let ((opoint (point)))
2454 (forward-line -1) 2491 (forward-line -1)