Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook hs-minor-mode into verilog-mode #14

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

abradd
Copy link
Contributor

@abradd abradd commented Jan 11, 2024

Add hook to verilog-mode for hs-minor-mode.

verilog-ts-mode loads verilog-mode so it seemed sensible to hook into verilog-mode.

ERT tests are failing on what seems like the absence of a treesitter dependency, but they fail before and after the patch so it likely unrelated.

@gmlarumbe
Copy link
Owner

Hi @abradd ,

Thanks a lot for the PR! Much appreciated :)

Just a couple of minor things before merging:

verilog-ts-mode loads verilog-mode so it seemed sensible to hook into verilog-mode.

You are right, and for the time being that would be the simplest way of setting it up. However I would suggest adding the hook also to verilog-ts-mode since at some point it might not be derived from verilog-mode anymore but from a verilog-base-mode similar to how it is being done for other programming languages such as C/Python.

Finally, there is a minor issue when lazy loading the package with use-package and setting it up with verilog-ext-mode-setup in the :config section. In this case the first time a Verilog buffer is opened hs-minor-mode will still be disabled. There is a simple workaround that is also used for font-lock.

Could you try if everything still works well for you after applying this patch?

diff --git a/verilog-ext-hs.el b/verilog-ext-hs.el
index 855a20b..ef505b4 100644
--- a/verilog-ext-hs.el
+++ b/verilog-ext-hs.el
@@ -70,7 +70,12 @@
                                            ,verilog-ext-hs-block-end-keywords-re
                                            nil
                                            ,(cdr mode))))
-  (add-hook 'verilog-mode-hook 'hs-minor-mode))
+  (dolist (hook '(verilog-mode-hook verilog-ts-mode-hook))
+    (add-hook hook #'hs-minor-mode))
+  ;; Workaround to enable `hideshow' on first file visit with lazy loading using
+  ;; :config section with `use-package'
+  (when (member major-mode '(verilog-mode verilog-ts-mode))
+    (hs-minor-mode 1)))
 
 (defun verilog-ext-hs-toggle-hiding (&optional e)
   "Wrapper for `hs-toggle-hiding' depending on current Verilog `major-mode'.

Thanks a lot!

@abradd
Copy link
Contributor Author

abradd commented Jan 12, 2024 via email

@gmlarumbe gmlarumbe linked an issue Jan 12, 2024 that may be closed by this pull request
@gmlarumbe gmlarumbe merged commit 3f54bcc into gmlarumbe:main Jan 12, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hs-minor-mode not enabled
2 participants