Function: hs-grok-mode-type

hs-grok-mode-type is a byte-compiled function defined in hideshow.el.gz.

Signature

(hs-grok-mode-type)

Documentation

Set up hideshow variables for new buffers.

If hs-special-modes-alist has information associated with the current buffer's major mode, use that. Otherwise, guess start, end and comment-start regexps; forward-sexp function; and adjust-block-beginning function.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/hideshow.el.gz
(defun hs-grok-mode-type ()
  "Set up hideshow variables for new buffers.
If `hs-special-modes-alist' has information associated with the
current buffer's major mode, use that.
Otherwise, guess start, end and `comment-start' regexps; `forward-sexp'
function; and adjust-block-beginning function."
  (if (and (bound-and-true-p comment-start)
           (bound-and-true-p comment-end))
      (let* ((lookup (assoc major-mode hs-special-modes-alist))
             (start-elem (or (nth 1 lookup) "\\s(")))
        (if (listp start-elem)
            ;; handle (START-REGEXP MDATA-SELECT)
            (setq hs-block-start-regexp (car start-elem)
                  hs-block-start-mdata-select (cadr start-elem))
          ;; backwards compatibility: handle simple START-REGEXP
          (setq hs-block-start-regexp start-elem
                hs-block-start-mdata-select 0))
        (setq hs-block-end-regexp (or (nth 2 lookup) "\\s)")
              hs-c-start-regexp (or (nth 3 lookup)
                                    (let ((c-start-regexp
                                           (regexp-quote comment-start)))
                                      (if (string-match " +$" c-start-regexp)
                                          (substring c-start-regexp
                                                     0 (1- (match-end 0)))
                                        c-start-regexp)))
              hs-forward-sexp-func (or (nth 4 lookup) #'forward-sexp)
              hs-adjust-block-beginning (or (nth 5 lookup) #'identity)))
    (setq hs-minor-mode nil)
    (error "%s Mode doesn't support Hideshow Minor Mode"
           (format-mode-line mode-name))))