Mercurial > emacs
comparison lisp/progmodes/hideshow.el @ 103737:f016828ad15e
* progmodes/hideshow.el (hs-hide-block-at-point): Don't move point
to the end of the line when locating the block (Bug#700).
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Mon, 06 Jul 2009 14:16:52 +0000 |
parents | a9dc0e7c3f2b |
children | 0cec7dac5f50 |
comparison
equal
deleted
inserted
replaced
103736:50bef8e85f9d | 103737:f016828ad15e |
---|---|
563 and then further adjusted to be at the end of the line." | 563 and then further adjusted to be at the end of the line." |
564 (if comment-reg | 564 (if comment-reg |
565 (hs-hide-comment-region (car comment-reg) (cadr comment-reg) end) | 565 (hs-hide-comment-region (car comment-reg) (cadr comment-reg) end) |
566 (when (looking-at hs-block-start-regexp) | 566 (when (looking-at hs-block-start-regexp) |
567 (let* ((mdata (match-data t)) | 567 (let* ((mdata (match-data t)) |
568 (pure-p (match-end 0)) | 568 (header-beg (match-beginning 0)) |
569 (header-end (match-end 0)) | |
569 (p | 570 (p |
570 ;; `p' is the point at the end of the block beginning, | 571 ;; `p' is the point at the end of the block beginning, |
571 ;; which may need to be adjusted | 572 ;; which may need to be adjusted |
572 (save-excursion | 573 (save-excursion |
573 (goto-char (funcall (or hs-adjust-block-beginning | 574 (if hs-adjust-block-beginning |
574 'identity) | 575 (goto-char (funcall hs-adjust-block-beginning |
575 pure-p)) | 576 header-end)) |
576 ;; whatever the adjustment, we move to eol | 577 (goto-char header-beg)))) |
577 (line-end-position))) | |
578 (q | 578 (q |
579 ;; `q' is the point at the end of the block | 579 ;; `q' is the point at the end of the block |
580 (progn (hs-forward-sexp mdata 1) | 580 (progn (hs-forward-sexp mdata 1) |
581 (end-of-line) | 581 (point))) |
582 (point))) | 582 ov) |
583 ov) | |
584 (when (and (< p (point)) (> (count-lines p q) 1)) | 583 (when (and (< p (point)) (> (count-lines p q) 1)) |
585 (cond ((and hs-allow-nesting (setq ov (hs-overlay-at p))) | 584 (cond ((and hs-allow-nesting (setq ov (hs-overlay-at p))) |
586 (delete-overlay ov)) | 585 (delete-overlay ov)) |
587 ((not hs-allow-nesting) | 586 ((not hs-allow-nesting) |
588 (hs-discard-overlays p q))) | 587 (hs-discard-overlays p q))) |
589 (hs-make-overlay p q 'code (- pure-p p))) | 588 (hs-make-overlay p q 'code (- header-end p))) |
590 (goto-char (if end q (min p pure-p))))))) | 589 (goto-char (if end q (min p header-end))))))) |
591 | 590 |
592 (defun hs-inside-comment-p () | 591 (defun hs-inside-comment-p () |
593 "Return non-nil if point is inside a comment, otherwise nil. | 592 "Return non-nil if point is inside a comment, otherwise nil. |
594 Actually, return a list containing the buffer position of the start | 593 Actually, return a list containing the buffer position of the start |
595 and the end of the comment. A comment block can be hidden only if on | 594 and the end of the comment. A comment block can be hidden only if on |