Mercurial > emacs
comparison lisp/progmodes/sh-script.el @ 90614:8dd8c8286063
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 460-475)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 145-152)
- Merge from emacs--devo--0
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-118
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 15 Oct 2006 02:54:13 +0000 |
parents | bb0e318b7c53 5e9926b80061 |
children | 6588c6259dfb |
comparison
equal
deleted
inserted
replaced
90613:7a2fdfcc7f71 | 90614:8dd8c8286063 |
---|---|
2458 ;; nil - nothing | 2458 ;; nil - nothing |
2459 ;; a string - possibly a keyword | 2459 ;; a string - possibly a keyword |
2460 ;; | 2460 ;; |
2461 (if (bolp) | 2461 (if (bolp) |
2462 nil | 2462 nil |
2463 (let (c min-point | 2463 (let ((start (point)) |
2464 (start (point))) | 2464 (min-point (if (sh-this-is-a-continuation) |
2465 (save-restriction | 2465 (sh-prev-line nil) |
2466 (narrow-to-region | 2466 (line-beginning-position)))) |
2467 (if (sh-this-is-a-continuation) | 2467 (skip-chars-backward " \t;" min-point) |
2468 (setq min-point (sh-prev-line nil)) | 2468 (if (looking-at "\\s-*;;") |
2469 (save-excursion | 2469 ;; (message "Found ;; !") |
2470 (beginning-of-line) | 2470 ";;" |
2471 (setq min-point (point)))) | 2471 (skip-chars-backward "^)}];\"'`({[" min-point) |
2472 (point)) | 2472 (let ((c (if (> (point) min-point) (char-before)))) |
2473 (skip-chars-backward " \t;") | 2473 (sh-debug "stopping at %d c is %s start=%d min-point=%d" |
2474 (unless (looking-at "\\s-*;;") | 2474 (point) c start min-point) |
2475 (skip-chars-backward "^)}];\"'`({[") | 2475 (if (not (memq c '(?\n nil ?\;))) |
2476 (setq c (char-before))) | 2476 ;; c -- return a string |
2477 (sh-debug "stopping at %d c is %s start=%d min-point=%d" | 2477 (char-to-string c) |
2478 (point) c start min-point) | 2478 ;; Return the leading keyword of the "command" we supposedly |
2479 (if (< (point) min-point) | 2479 ;; skipped over. Maybe we skipped too far (e.g. past a `do' or |
2480 (error "point %d < min-point %d" (point) min-point)) | 2480 ;; `then' that precedes the actual command), so check whether |
2481 (cond | 2481 ;; we're looking at such a keyword and if so, move back forward. |
2482 ((looking-at "\\s-*;;") | 2482 (let ((boundary (point)) |
2483 ;; (message "Found ;; !") | 2483 kwd next) |
2484 ";;") | 2484 (while |
2485 ((or (eq c ?\n) | 2485 (progn |
2486 (eq c nil) | 2486 ;; Skip forward over white space newline and \ at eol. |
2487 (eq c ?\;)) | 2487 (skip-chars-forward " \t\n\\\\" start) |
2488 (let (done kwd next | 2488 (if (>= (point) start) |
2489 (boundary (point))) | 2489 (progn |
2490 (skip-chars-forward " \t\n\\\\") | 2490 (sh-debug "point: %d >= start: %d" (point) start) |
2491 (while (and (not done) (not (eobp))) | 2491 nil) |
2492 (if next (setq boundary next)) | 2492 (if next (setq boundary next)) |
2493 ;; skip forward over white space newline and \ at eol | 2493 (sh-debug "Now at %d start=%d" (point) start) |
2494 (sh-debug "Now at %d start=%d" (point) start) | 2494 (setq kwd (sh-get-word)) |
2495 (if (>= (point) start) | 2495 (if (member kwd (sh-feature sh-leading-keywords)) |
2496 (progn | 2496 (progn |
2497 (sh-debug "point: %d >= start: %d" (point) start) | 2497 (setq next (point)) |
2498 nil) | 2498 t) |
2499 (setq kwd (sh-get-word)) | 2499 nil)))) |
2500 (unless (eobp) (forward-char 1)) | 2500 (goto-char boundary) |
2501 (if (member kwd (sh-feature sh-leading-keywords)) | 2501 kwd))))))) |
2502 (setq next (point)) | |
2503 (setq done t))) | |
2504 (skip-chars-forward " \t\n\\\\")) | |
2505 (goto-char boundary) | |
2506 kwd)) | |
2507 (t | |
2508 ;; c -- return a string | |
2509 (char-to-string c) | |
2510 )) | |
2511 )))) | |
2512 | 2502 |
2513 | 2503 |
2514 (defun sh-this-is-a-continuation () | 2504 (defun sh-this-is-a-continuation () |
2515 "Return non-nil if current line is a continuation of previous line." | 2505 "Return non-nil if current line is a continuation of previous line." |
2516 (save-excursion | 2506 (save-excursion |
2525 (let ((start (point))) | 2515 (let ((start (point))) |
2526 (if where | 2516 (if where |
2527 (goto-char where)) | 2517 (goto-char where)) |
2528 (prog1 | 2518 (prog1 |
2529 (buffer-substring (point) | 2519 (buffer-substring (point) |
2530 (progn (skip-chars-forward "^ \t\n;&")(point))) | 2520 (progn (skip-chars-forward "^ \t\n;&|()")(point))) |
2531 (unless and-move | 2521 (unless and-move |
2532 (goto-char start))))) | 2522 (goto-char start))))) |
2533 | 2523 |
2534 (defun sh-find-prev-matching (open close &optional depth) | 2524 (defun sh-find-prev-matching (open close &optional depth) |
2535 "Find a matching token for a set of opening and closing keywords. | 2525 "Find a matching token for a set of opening and closing keywords. |