I wanna add some hooks to web-mode and js2-mode
, but it doesn't go well.
Here is what I am doing. I wanna to add header line for web-mode
and js2-mode
cuz they are derived from fundamental-mode
. And I have to manually add these modes.
(which-function-mode)
;; when editing js file, this feature is very useful
;; (setq-default header-line-format
;; '((which-func-mode ("" which-func-format " "))))
(defun set-header-line ()
(setq header-line-format
'((which-func-mode ("" which-func-format " ")))))
(add-hook 'prog-mode-hook 'set-header-line)
(add-hook 'text-mode-hook 'set-header-line)
(add-hook 'js2-mode-hook 'set-header-line)
(add-hook 'web-mode-hook 'set-header-line)
The reason why the header-line disappear is due to the ranger. It shows up when I open the file with dired or treemacs, but not for ranger.
Here is the header-line-format
value opened with dired and ranger.
Dired:
Ranger:
I tried adding hooks to ranger-mode-load-hook
and set ranger-modify-header
to nil. Not working.
Does anyone have some ideas what's going on here?
(defun web-hook-test () (message "web-mode test!")) (add-hook 'web-mode-hook 'web-hook-test)
. My problem is notwhich-func-mode
, it's theheader-line-format
not enabled inweb-mode
andjs2-mode
.(message "NOOOOOOOO")
in theset-header-line
function. And it turns out I am not getting the message when I open the file but I get the message when init theweb-mode
and the header-line shows for the first opened file sometimes but doesn't for followings. ws1.sinaimg.cn/large/006tNc79gy1fkzroza0qaj30mi09fq7a.jpg