diff options
| author | Richard M. Stallman | 2005-08-26 11:52:08 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-08-26 11:52:08 +0000 |
| commit | 20e3210fb7584494c83dda26d79b3ad54d525d2e (patch) | |
| tree | 87c650f614fdc4f85448a81904b5fb3fd6a1fc01 /lisp | |
| parent | 04ec34141ff9216131130a83777a2a42fde3255d (diff) | |
| download | emacs-20e3210fb7584494c83dda26d79b3ad54d525d2e.tar.gz emacs-20e3210fb7584494c83dda26d79b3ad54d525d2e.zip | |
(outline-promote): Try shortening the heading.
As last resort, read the heading to use.
(outline-demote): As last resort, read the heading to use.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/outline.el | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/lisp/outline.el b/lisp/outline.el index 213bc34aba7..61968da99d7 100644 --- a/lisp/outline.el +++ b/lisp/outline.el | |||
| @@ -471,13 +471,28 @@ in the region." | |||
| 471 | (save-excursion (outline-get-next-sibling) (point)))) | 471 | (save-excursion (outline-get-next-sibling) (point)))) |
| 472 | (t | 472 | (t |
| 473 | (outline-back-to-heading t) | 473 | (outline-back-to-heading t) |
| 474 | (let* ((head (match-string 0)) | 474 | (let* ((head (match-string-no-properties 0)) |
| 475 | (level (save-match-data (funcall outline-level))) | 475 | (level (save-match-data (funcall outline-level))) |
| 476 | (up-head (or (outline-head-from-level (1- level) head) | 476 | (up-head (or (outline-head-from-level (1- level) head) |
| 477 | ;; Use the parent heading, if it is really | ||
| 478 | ;; one level less. | ||
| 477 | (save-excursion | 479 | (save-excursion |
| 478 | (save-match-data | 480 | (save-match-data |
| 479 | (outline-up-heading 1 t) | 481 | (outline-up-heading 1 t) |
| 480 | (match-string 0)))))) | 482 | (and (= (1- level) (funcall outline-level)) |
| 483 | (match-string-no-properties 0)))) | ||
| 484 | ;; Bummer!! There is no lower level heading. | ||
| 485 | ;; Let's try to invent one by deleting the last char. | ||
| 486 | (save-match-data | ||
| 487 | (let ((new-head (substring head 0 -1))) | ||
| 488 | (if (string-match (concat "\\`\\(?:" outline-regexp "\\)") | ||
| 489 | new-head) | ||
| 490 | ;; Why bother checking that it is indeed lower level ? | ||
| 491 | new-head | ||
| 492 | ;; Didn't work, so ask what to do. | ||
| 493 | (read-string (format "Parent heading for `%s': " | ||
| 494 | head) | ||
| 495 | head nil nil t))))))) | ||
| 481 | 496 | ||
| 482 | (unless (rassoc level outline-heading-alist) | 497 | (unless (rassoc level outline-heading-alist) |
| 483 | (push (cons head level) outline-heading-alist)) | 498 | (push (cons head level) outline-heading-alist)) |
| @@ -501,7 +516,7 @@ in the region." | |||
| 501 | (point) | 516 | (point) |
| 502 | (save-excursion (outline-get-next-sibling) (point)))) | 517 | (save-excursion (outline-get-next-sibling) (point)))) |
| 503 | (t | 518 | (t |
| 504 | (let* ((head (match-string 0)) | 519 | (let* ((head (match-string-no-properties 0)) |
| 505 | (level (save-match-data (funcall outline-level))) | 520 | (level (save-match-data (funcall outline-level))) |
| 506 | (down-head | 521 | (down-head |
| 507 | (or (outline-head-from-level (1+ level) head) | 522 | (or (outline-head-from-level (1+ level) head) |
| @@ -516,21 +531,23 @@ in the region." | |||
| 516 | (<= (funcall outline-level) level)))) | 531 | (<= (funcall outline-level) level)))) |
| 517 | (unless (eobp) | 532 | (unless (eobp) |
| 518 | (looking-at outline-regexp) | 533 | (looking-at outline-regexp) |
| 519 | (match-string 0)))) | 534 | (match-string-no-properties 0)))) |
| 520 | (save-match-data | 535 | (save-match-data |
| 521 | ;; Bummer!! There is no lower heading in the buffer. | 536 | ;; Bummer!! There is no higher-level heading in the buffer. |
| 522 | ;; Let's try to invent one by repeating the first char. | 537 | ;; Let's try to invent one by repeating the last char. |
| 523 | (let ((new-head (concat (substring head 0 1) head))) | 538 | (let ((new-head (concat head (substring head -1)))) |
| 524 | (if (string-match (concat "\\`\\(?:" outline-regexp "\\)") | 539 | (if (string-match (concat "\\`\\(?:" outline-regexp "\\)") |
| 525 | new-head) | 540 | new-head) |
| 526 | ;; Why bother checking that it is indeed lower level ? | 541 | ;; Why bother checking that it is indeed higher level ? |
| 527 | new-head | 542 | new-head |
| 528 | ;; Didn't work: keep it as is so it's still a heading. | 543 | ;; Didn't work, so ask what to do. |
| 529 | head)))))) | 544 | (read-string (format "Demoted heading for `%s': " |
| 545 | head) | ||
| 546 | head nil nil t))))))) | ||
| 530 | 547 | ||
| 531 | (unless (rassoc level outline-heading-alist) | 548 | (unless (rassoc level outline-heading-alist) |
| 532 | (push (cons head level) outline-heading-alist)) | 549 | (push (cons head level) outline-heading-alist)) |
| 533 | (replace-match down-head nil t))))) | 550 | (replace-match down-head nil t))))) |
| 534 | 551 | ||
| 535 | (defun outline-head-from-level (level head &optional alist) | 552 | (defun outline-head-from-level (level head &optional alist) |
| 536 | "Get new heading with level LEVEL from ALIST. | 553 | "Get new heading with level LEVEL from ALIST. |