Mercurial > emacs
comparison lisp/textmodes/outline.el @ 33797:b5df14d31790
(outline-flag-region):
Don't bind inhibit-read-only since we don't modify the buffer.
(outline-isearch-open-invisible): Don't jump to overlay-start
since we're trying to unhide text around point.
(outline-discard-overlays): Use dolist.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 23 Nov 2000 00:04:36 +0000 |
parents | 350d5ee0e430 |
children | 77de13a8a918 |
comparison
equal
deleted
inserted
replaced
33796:10ffa5b56f53 | 33797:b5df14d31790 |
---|---|
381 (goto-char beg))) | 381 (goto-char beg))) |
382 | 382 |
383 (defun outline-flag-region (from to flag) | 383 (defun outline-flag-region (from to flag) |
384 "Hides or shows lines from FROM to TO, according to FLAG. | 384 "Hides or shows lines from FROM to TO, according to FLAG. |
385 If FLAG is nil then text is shown, while if FLAG is t the text is hidden." | 385 If FLAG is nil then text is shown, while if FLAG is t the text is hidden." |
386 (let ((inhibit-read-only t)) | 386 (save-excursion |
387 (save-excursion | 387 (goto-char from) |
388 (goto-char from) | 388 (end-of-line) |
389 (end-of-line) | 389 (outline-discard-overlays (point) to 'outline) |
390 (outline-discard-overlays (point) to 'outline) | 390 (if flag |
391 (if flag | 391 (let ((o (make-overlay (point) to))) |
392 (let ((o (make-overlay (point) to))) | 392 (overlay-put o 'invisible 'outline) |
393 (overlay-put o 'invisible 'outline) | 393 (overlay-put o 'isearch-open-invisible |
394 (overlay-put o 'isearch-open-invisible | 394 'outline-isearch-open-invisible)))) |
395 'outline-isearch-open-invisible))))) | |
396 (run-hooks 'outline-view-change-hook)) | 395 (run-hooks 'outline-view-change-hook)) |
397 | 396 |
398 | 397 |
399 ;; Function to be set as an outline-isearch-open-invisible' property | 398 ;; Function to be set as an outline-isearch-open-invisible' property |
400 ;; to the overlay that makes the outline invisible (see | 399 ;; to the overlay that makes the outline invisible (see |
401 ;; `outline-flag-region'). | 400 ;; `outline-flag-region'). |
402 (defun outline-isearch-open-invisible (overlay) | 401 (defun outline-isearch-open-invisible (overlay) |
403 (save-excursion | 402 ;; We rely on the fact that isearch places point one the matched text. |
404 (goto-char (overlay-start overlay)) | 403 (show-entry)) |
405 (show-entry))) | |
406 | 404 |
407 | 405 |
408 ;; Exclude from the region BEG ... END all overlays | 406 ;; Exclude from the region BEG ... END all overlays |
409 ;; which have PROP as the value of the `invisible' property. | 407 ;; which have PROP as the value of the `invisible' property. |
410 ;; Exclude them by shrinking them to exclude BEG ... END, | 408 ;; Exclude them by shrinking them to exclude BEG ... END, |
412 ;; Overlays without such an `invisible' property are not touched. | 410 ;; Overlays without such an `invisible' property are not touched. |
413 (defun outline-discard-overlays (beg end prop) | 411 (defun outline-discard-overlays (beg end prop) |
414 (if (< end beg) | 412 (if (< end beg) |
415 (setq beg (prog1 end (setq end beg)))) | 413 (setq beg (prog1 end (setq end beg)))) |
416 (save-excursion | 414 (save-excursion |
417 (let ((overlays (overlays-in beg end)) | 415 (dolist (o (overlays-in beg end)) |
418 o | 416 (if (eq (overlay-get o 'invisible) prop) |
419 o1) | 417 ;; Either push this overlay outside beg...end |
420 (while overlays | 418 ;; or split it to exclude beg...end |
421 (setq o (car overlays)) | 419 ;; or delete it entirely (if it is contained in beg...end). |
422 (if (eq (overlay-get o 'invisible) prop) | 420 (if (< (overlay-start o) beg) |
423 ;; Either push this overlay outside beg...end | |
424 ;; or split it to exclude beg...end | |
425 ;; or delete it entirely (if it is contained in beg...end). | |
426 (if (< (overlay-start o) beg) | |
427 (if (> (overlay-end o) end) | |
428 (progn | |
429 (setq o1 (outline-copy-overlay o)) | |
430 (move-overlay o1 (overlay-start o1) beg) | |
431 (move-overlay o end (overlay-end o))) | |
432 (move-overlay o (overlay-start o) beg)) | |
433 (if (> (overlay-end o) end) | 421 (if (> (overlay-end o) end) |
434 (move-overlay o end (overlay-end o)) | 422 (progn |
435 (delete-overlay o)))) | 423 (move-overlay (outline-copy-overlay o) |
436 (setq overlays (cdr overlays)))))) | 424 (overlay-start o) beg) |
425 (move-overlay o end (overlay-end o))) | |
426 (move-overlay o (overlay-start o) beg)) | |
427 (if (> (overlay-end o) end) | |
428 (move-overlay o end (overlay-end o)) | |
429 (delete-overlay o)))))))) | |
437 | 430 |
438 ;; Make a copy of overlay O, with the same beginning, end and properties. | 431 ;; Make a copy of overlay O, with the same beginning, end and properties. |
439 (defun outline-copy-overlay (o) | 432 (defun outline-copy-overlay (o) |
440 (let ((o1 (make-overlay (overlay-start o) (overlay-end o) | 433 (let ((o1 (make-overlay (overlay-start o) (overlay-end o) |
441 (overlay-buffer o))) | 434 (overlay-buffer o))) |