Pergunta

For my favorite modes, I use the following snippet to load hs-minor-mode on startup:

(add-hook '____-mode-hook 'hs-minor-mode)

So far it's gotten working on css-mode, perl-mode, sh-mode (bash), and lisp-mode. But for some reason it won't load for php-mode, even if I can load it manually.

Here's my php-mode settings:

(defun php-overload-keys ()
 (let ((map php-mode-map))
  (define-key map "\t" 'dumb-indent-relative)
  (define-key map "\177" 'backward-delete-char)
  (define-key map "," nil)
  (define-key map ";" nil)
  (define-key map ":" nil)
  (define-key map "*" nil)
  (define-key map "{" nil)
  (define-key map "}" nil)
  (define-key map "(" nil)
  (define-key map ")" nil)
  (define-key map "/" nil)
  (use-local-map map)))

(add-hook 'php-mode-hook 'php-overload-keys)
(add-hook 'php-mode-hook 'hs-minor-mode)

Am I doing anything wrong? I tried wrapping hs-minor-mode in a function and it still won't load. My overloaded keys, however, do. What's the deal?

Foi útil?

Solução

Mode functions typically accept a numeric argument to enable/disable them, and act as toggles if no argument is supplied, so as a general rule you should use:

(add-hook 'php-mode-hook (lambda () (hs-minor-mode 1)))

Outras dicas

In general I would recommend

(add-hook 'prog-mode-hook #'(lambda () (hs-minor-mode t)))

because the hideshow is not some PHP-specific mode.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top