395 |
; (setq buffer-invisibility-spec |
; (setq buffer-invisibility-spec |
396 |
; (cons arg buffer-invisibility-spec))))) |
; (cons arg buffer-invisibility-spec))))) |
397 |
; (defun remove-from-invisibility-spec (arg) |
; (defun remove-from-invisibility-spec (arg) |
398 |
; (if buffer-invisibility-spec |
; (when buffer-invisibility-spec |
399 |
; (setq buffer-invisibility-spec |
; (setq buffer-invisibility-spec |
400 |
; (delete arg buffer-invisibility-spec))))) |
; (delete arg buffer-invisibility-spec))))) |
401 |
|
|
402 |
;; hs-match-data |
;; hs-match-data |
403 |
(defalias 'hs-match-data 'match-data) |
(defalias 'hs-match-data 'match-data) |
497 |
and then further adjusted to be at the end of the line." |
and then further adjusted to be at the end of the line." |
498 |
(if comment-reg |
(if comment-reg |
499 |
(hs-hide-comment-region (car comment-reg) (cadr comment-reg) end) |
(hs-hide-comment-region (car comment-reg) (cadr comment-reg) end) |
500 |
(if (looking-at hs-block-start-regexp) |
(when (looking-at hs-block-start-regexp) |
501 |
(let* ((mdata (hs-match-data t)) |
(let* ((mdata (hs-match-data t)) |
502 |
(pure-p (match-end 0)) |
(pure-p (match-end 0)) |
503 |
(p |
(p |
504 |
;; `p' is the point at the end of the block beginning, |
;; `p' is the point at the end of the block beginning, |
505 |
;; which may need to be adjusted |
;; which may need to be adjusted |
506 |
(save-excursion |
(save-excursion |
507 |
(goto-char (funcall (or hs-adjust-block-beginning |
(goto-char (funcall (or hs-adjust-block-beginning |
508 |
'identity) |
'identity) |
509 |
pure-p)) |
pure-p)) |
510 |
;; whatever the adjustment, we move to eol |
;; whatever the adjustment, we move to eol |
511 |
(end-of-line) |
(end-of-line) |
512 |
(point))) |
(point))) |
513 |
(q |
(q |
514 |
;; `q' is the point at the end of the block |
;; `q' is the point at the end of the block |
515 |
(progn (hs-forward-sexp mdata 1) |
(progn (hs-forward-sexp mdata 1) |
516 |
(end-of-line) |
(end-of-line) |
517 |
(point)))) |
(point)))) |
518 |
(if (and (< p (point)) (> (count-lines p q) 1)) |
(when (and (< p (point)) (> (count-lines p q) 1)) |
519 |
(overlay-put (hs-flag-region p q 'code) |
(overlay-put (hs-flag-region p q 'code) |
520 |
'hs-ofs |
'hs-ofs |
521 |
(- pure-p p))) |
(- pure-p p))) |
522 |
(goto-char (if end q (min p pure-p))))))) |
(goto-char (if end q (min p pure-p))))))) |
523 |
|
|
524 |
(defun hs-safety-is-job-n () |
(defun hs-safety-is-job-n () |
525 |
"Warn if `buffer-invisibility-spec' does not contain symbol `hs'." |
"Warn if `buffer-invisibility-spec' does not contain symbol `hs'." |
568 |
(setq p (point));; use this to avoid an infinite cycle |
(setq p (point));; use this to avoid an infinite cycle |
569 |
(forward-comment 1) |
(forward-comment 1) |
570 |
(skip-chars-forward " \t\n\f")) |
(skip-chars-forward " \t\n\f")) |
571 |
(if (or (not (looking-at hs-c-start-regexp)) |
(when (or (not (looking-at hs-c-start-regexp)) |
572 |
(> (point) q)) |
(> (point) q)) |
573 |
;; we cannot hide this comment block |
;; we cannot hide this comment block |
574 |
(setq not-hidable t))) |
(setq not-hidable t))) |
575 |
;; goto the end of the comment |
;; goto the end of the comment |
576 |
(forward-comment (buffer-size)) |
(forward-comment (buffer-size)) |
577 |
(skip-chars-backward " \t\n\f") |
(skip-chars-backward " \t\n\f") |
578 |
(end-of-line) |
(end-of-line) |
579 |
(if (>= (point) q) |
(when (>= (point) q) |
580 |
(list (if not-hidable nil p) (point)))))))) |
(list (if not-hidable nil p) (point)))))))) |
581 |
|
|
582 |
(defun hs-grok-mode-type () |
(defun hs-grok-mode-type () |
583 |
"Set up hideshow variables for new buffers. |
"Set up hideshow variables for new buffers. |
607 |
c-start-regexp))) |
c-start-regexp))) |
608 |
hs-forward-sexp-func (or (nth 4 lookup) 'forward-sexp) |
hs-forward-sexp-func (or (nth 4 lookup) 'forward-sexp) |
609 |
hs-adjust-block-beginning (nth 5 lookup))) |
hs-adjust-block-beginning (nth 5 lookup))) |
610 |
(progn |
(setq hs-minor-mode nil) |
611 |
(setq hs-minor-mode nil) |
(error "%s Mode doesn't support Hideshow Minor Mode" mode-name))) |
|
(error "%s Mode doesn't support Hideshow Minor Mode" mode-name)))) |
|
612 |
|
|
613 |
(defun hs-find-block-beginning () |
(defun hs-find-block-beginning () |
614 |
"Reposition point at block-start. |
"Reposition point at block-start. |
666 |
(if (and c-reg (nth 0 c-reg)) |
(if (and c-reg (nth 0 c-reg)) |
667 |
;; point is inside a comment, and that comment is hidable |
;; point is inside a comment, and that comment is hidable |
668 |
(goto-char (nth 0 c-reg)) |
(goto-char (nth 0 c-reg)) |
669 |
(if (and (not c-reg) |
(when (and (not c-reg) |
670 |
(hs-find-block-beginning) |
(hs-find-block-beginning) |
671 |
(looking-at hs-block-start-regexp)) |
(looking-at hs-block-start-regexp)) |
672 |
;; point is inside a block |
;; point is inside a block |
673 |
(goto-char (match-end 0))))) |
(goto-char (match-end 0))))) |
674 |
(end-of-line) |
(end-of-line) |
675 |
(let ((overlays (overlays-at (point))) |
(let ((overlays (overlays-at (point))) |
676 |
(found nil)) |
(found nil)) |
887 |
;; load-time actions |
;; load-time actions |
888 |
|
|
889 |
;; keymaps and menus |
;; keymaps and menus |
890 |
(if hs-minor-mode-map |
(unless hs-minor-mode-map |
|
nil |
|
891 |
(setq hs-minor-mode-map (make-sparse-keymap)) |
(setq hs-minor-mode-map (make-sparse-keymap)) |
892 |
(easy-menu-define hs-minor-mode-menu |
(easy-menu-define hs-minor-mode-menu |
893 |
hs-minor-mode-map |
hs-minor-mode-map |