logangrado / hideshow-orgmode

Orgmode-like folding for sideshow
MIT License
11 stars 2 forks source link

No effect when invoking hide(all) #1

Closed novoid closed 7 years ago

novoid commented 7 years ago

Hi, I've read the reddit thread and tried it.

Some remarks first:

You might want to add this snippet for users of use-package as well:

(use-package hideshow-orgmode
  :load-path  (lambda () (expand-file-name (concat my-user-emacs-directory "contrib/hideshow-orgmode")))
  :config
  (global-set-key (kbd "M-h") 'hs-cycle)
  (global-set-key (kbd "M-H") 'hs-cycle-all)
)

I do code in Python only so your package description suits me. However, I was wondering whether or not your package only handles Python folding or other programming languages as well. You should elaborate on this question in your readme.

My issue:

When I open up a python file and invoke hs-hide-all, or hs-cycle-all, or hs-cycle I don't get any effect at all. Nothing changes in my buffer, no error message is thrown as well.

A quick check with C-h k M-h shows that my key binding works. Invocation of the functions via M-x does not show any effect as well.

Write me when I should check anything for you on my setup.

logangrado commented 7 years ago

1) use-package I'm not completely familiar with how to write a package to be compatible with use-package, but from my understanding, as long as the package is in your load path, you can call use-package hideshow-orgmode with no issue.

2) As for nothing happening... That's curious. My initial thought is that you don't have hideshow minor mode properly enabled, because if you did, hs-hide-all should work. Do any of the other hideshow functions work for you? Please let me know.

EDIT: I'm guessing that `hideshow minor mode` is not being loaded with your `python major mode`. I have these lines in my `init.el` file to automatically load `hideshow minor mode` any time a programming major mode is loaded:

It defines a list of `code-editing-mode-hooks` (you can put whichever major-modes in this list you'd like), and then adds `hs-minor-mode` to the hooks for each of those major modes.
```
(defvar code-editing-mode-hooks '(c-mode-common-hook
              clojure-mode-hook
              emacs-lisp-mode-hook
              java-mode-hook
              js-mode-hook
              web-mode-hook
              html-mode-hook
              lisp-mode-hook
              perl-mode-hook
              python-mode-hook
              sh-mode-hook))
;; add a hs-minor-mode hook to code editing major modes
(load-library "hideshow")
(dolist (mode code-editing-mode-hooks)
  (add-hook mode 'hs-minor-mode))

(add-to-list 'load-path "~/.emacs.d/hideshow-orgmode")
(require 'hideshow-orgmode)
```

3) Finally, for other languages I have not extensively tested it on other languages. However, as it leverages hideshow minor mode, it *should* work anywhere that hideshow minor mode works. It searches the file for foldable code blocks and unfolds them progressively. I'd imagine with extensively nested code/text (I'm looking at you HTML) it might do too much folding, but it should still work.

novoid commented 7 years ago
  1. Yes. Almost. use-package installs from repositories like ELPA. Additionally, it can load packages that are found on the local machine. My snippet shows how to use use-package to load the package from a local path within the .emacs.d folder. Many users of use-package do not know that use-package is able to define a load-path.

  2. I did not know anything about hideshow minor mode and therefore I thought that the description was referring to itself instead of an additional package. You code works now. My suggestion is that you emphasize for people like me that this needs actually a different package to work + add a link to (description of) it. Maybe a quick check for missing hideshow minor mode + error message would prevent issues like mine.

  3. As I did not get the hideshow minor mode beforehand, I now understand.

Thanks for your code and your quick help!