简体   繁体   中英

how do I get hs-minor-mode to load automatically on php-mode in emacs?

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?

模式函数通常接受一个数字参数来启用/禁用它们,并且在不提供任何参数的情况下用作切换,因此通常应使用:

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

In general I would recommend

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

because the hideshow is not some PHP-specific mode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM