comparison lisp/progmodes/hideshow.el @ 104214:0cec7dac5f50

* progmodes/hideshow.el (hs-special-modes-alist): Don't use hs-c-like-adjust-block-beginning. (hs-hide-block-at-point): Stop hiding at the beginning of hs-block-end-regexp (Bug#700).
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 09 Aug 2009 02:43:50 +0000
parents f016828ad15e
children ea67ac46d172
comparison
equal deleted inserted replaced
104213:8642d488076f 104214:0cec7dac5f50
265 (const :tag "don't open any of them" nil)) 265 (const :tag "don't open any of them" nil))
266 :group 'hideshow) 266 :group 'hideshow)
267 267
268 ;;;###autoload 268 ;;;###autoload
269 (defvar hs-special-modes-alist 269 (defvar hs-special-modes-alist
270 '((c-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning) 270 '((c-mode "{" "}" "/[*/]" nil nil)
271 (c++-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning) 271 (c++-mode "{" "}" "/[*/]" nil nil)
272 (bibtex-mode ("@\\S(*\\(\\s(\\)" 1)) 272 (bibtex-mode ("@\\S(*\\(\\s(\\)" 1))
273 (java-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning)) 273 (java-mode "{" "}" "/[*/]" nil nil))
274 "*Alist for initializing the hideshow variables for different modes. 274 "*Alist for initializing the hideshow variables for different modes.
275 Each element has the form 275 Each element has the form
276 (MODE START END COMMENT-START FORWARD-SEXP-FUNC ADJUST-BEG-FUNC). 276 (MODE START END COMMENT-START FORWARD-SEXP-FUNC ADJUST-BEG-FUNC).
277 277
278 If non-nil, hideshow will use these values as regexps to define blocks 278 If non-nil, hideshow will use these values as regexps to define blocks
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 (header-beg (match-beginning 0)) 568 (header-beg (match-beginning 0))
569 (header-end (match-end 0)) 569 (header-end (match-end 0))
570 (p 570 p q ov)
571 ;; `p' is the point at the end of the block beginning, 571 ;; `p' is the point at the end of the block beginning, which
572 ;; which may need to be adjusted 572 ;; may need to be adjusted
573 (save-excursion 573 (save-excursion
574 (if hs-adjust-block-beginning 574 (if hs-adjust-block-beginning
575 (goto-char (funcall hs-adjust-block-beginning 575 (goto-char (funcall hs-adjust-block-beginning
576 header-end)) 576 header-end))
577 (goto-char header-beg)))) 577 (goto-char header-end))
578 (q 578 (setq p (line-end-position)))
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 (hs-forward-sexp mdata 1)
581 (point))) 581 (setq q (if (looking-back hs-block-end-regexp)
582 ov) 582 (match-beginning 0)
583 (when (and (< p (point)) (> (count-lines p q) 1)) 583 (point)))
584 (when (and (< p q) (> (count-lines p q) 1))
584 (cond ((and hs-allow-nesting (setq ov (hs-overlay-at p))) 585 (cond ((and hs-allow-nesting (setq ov (hs-overlay-at p)))
585 (delete-overlay ov)) 586 (delete-overlay ov))
586 ((not hs-allow-nesting) 587 ((not hs-allow-nesting)
587 (hs-discard-overlays p q))) 588 (hs-discard-overlays p q)))
588 (hs-make-overlay p q 'code (- header-end p))) 589 (hs-make-overlay p q 'code (- header-end p)))
749 ;; point is inside a block 750 ;; point is inside a block
750 (goto-char (match-end 0))))) 751 (goto-char (match-end 0)))))
751 (end-of-line) 752 (end-of-line)
752 (hs-overlay-at (point)))) 753 (hs-overlay-at (point))))
753 754
755 ;; This function is not used anymore (Bug#700).
754 (defun hs-c-like-adjust-block-beginning (initial) 756 (defun hs-c-like-adjust-block-beginning (initial)
755 "Adjust INITIAL, the buffer position after `hs-block-start-regexp'. 757 "Adjust INITIAL, the buffer position after `hs-block-start-regexp'.
756 Actually, point is never moved; a new position is returned that is 758 Actually, point is never moved; a new position is returned that is
757 the end of the C-function header. This adjustment function is meant 759 the end of the C-function header. This adjustment function is meant
758 to be assigned to `hs-adjust-block-beginning' for C-like modes." 760 to be assigned to `hs-adjust-block-beginning' for C-like modes."