Do others see this:
Evaluate the following two functions and then `M-x mmc-test
RET'. You should be in buffer "mmc-test-buffer". Move the cursor up
one line repeatedly until you reach the beginning of the buffer (up
arrow, or `C-p').
Why does the cursor disappear on lines 4 and 2? The cursor
remains visible on the way down the buffer?
I've tried this with 21.2.b18 also, with the same results. I don't
know about the 21.1 series, but the cursor remains visible at all
times under FSF Emacs.
`redisplay' ? Perhaps minor aesthetics, but you know what it's like
when you've started with something :-).
(defun mmc-hide-lines ()
"*Hide all but `Line: nn' lines in the current buffer."
(interactive)
(make-local-variable 'line-move-ignore-invisible)
(setq line-move-ignore-invisible 't) ;ignore invisible lines
(make-local-variable 'hide-extents)
(setq hide-extents nil)
(save-excursion
(goto-char (point-min))
(let (beg end)
(re-search-forward "^Line: [0-9]?[0-9]\n" nil t)
(setq beg (match-end 0))
(while (re-search-forward "^Line: [0-9]?[0-9]\n" nil t)
(setq end (match-beginning 0))
(push (cons beg end) hide-extents)
(setq beg (match-end 0)))
(setq end (point-max))
(push (cons beg end) hide-extents)
(setq hide-extents (nreverse hide-extents))
(mapcar '(lambda (extent)
(put-text-property (car extent) (cdr extent) 'invisible 't))
hide-extents))))
(defun mmc-test ()
(interactive)
(require 'cl)
(let ((test-data
(concat
"Line: 1\n"
"Some intervening text.\n"
"Line: 2\n"
"Some intervening text.\n"
"Line: 3\n"
"Some intervening text.\n"
"Line: 4\n"
"Some intervening text.\n"
"Line: 5\n"
"Some intervening text.\n"
)))
(switch-to-buffer "mmc-test-buffer")
(insert test-data)
(mmc-hide-lines)))
--
Mike <mike(a)lotusland.demon.co.uk>