snosov1 / toc-org

toc-org is an Emacs utility to have an up-to-date table of contents in the org files without exporting (useful primarily for readme files on GitHub)
GNU General Public License v3.0
286 stars 29 forks source link

Doesn't work? #11

Closed alphapapa closed 8 years ago

alphapapa commented 8 years ago

I was excited to use this package, but it doesn't seem to be working. I installed from MELPA and used the code in the instructions to add the hook. Then I made a headline and gave it the :TOC: tag, but when I save the file, no table of contents is created.

Currently using Emacs 24.4 and Org 8.2.4.

When I eval the code to add the hook, this shows up in *Messages*:

(toc-org-enable org-mark-readonly (lambda nil (org-bullets-mode 1)) adp/org-mode-hook #[nil "ÅÆ  >ƒ

As you can see, there seems to be some garbage characters in there. Either Emacs wouldn't copy it all to the clipboard, or Firefox wouldn't paste it all here. :/

snosov1 commented 8 years ago

Hey!

That's pretty awkward. I didn't make any changes for quite some time

Let's try to make a "clean" experiment.

  1. Put
(eval-after-load "toc-org-autoloads"
    '(progn
       (if (require 'toc-org nil t)
           (add-hook 'org-mode-hook 'toc-org-enable)
         (message "WARNING: toc-org not found"))))

into your .emacs

  1. Restart Emacs
  2. Open a file in org-mode, say hello.org.
  3. Make sure that the major mode is, in fact, org-mode. You can use F1 m for that
  4. Make sure org-mode-hook contains toc-org-enable function. You can use F1 v org-mode-hook for that.
  5. Type
* Hi
* Hello
* Good-bye
  1. Save the file. Nothing should happen
  2. Change the contents to
* Hi
* Hello :TOC:
* Good-bye
  1. Save the file. The contents should change to
* Hi
* Hello :TOC:
 - [[#hi][Hi]]
 - [[#good-bye][Good-bye]]

* Good-bye

Please, let me know if it works.

alphapapa commented 8 years ago

Hi,

Thanks for the quick response!

I ran your tests exactly as you described, and it did indeed work fine! So then I opened the file I tried to add a TOC to before...and it doesn't work. When I save the file, the :TOC: heading doesn't change at all.

I'm guessing that there must be something in the file itself that is causing the problem...and, yes, I just found it. When I remove this heading from the file, it works:

* Screenshot
Here's an example of what you get in Emacs from capturing [[http://kitchingroup.cheme.cmu.edu/blog/2014/07/17/Pandoc-does-org-mode-now/][this page]]:
[[screenshot.png]]

...and then, after reverting the buffer, and leaving that headline in the file...it still works. This is very weird.

The file in question is the readme here: https://github.com/alphapapa/org-protocol-capture-html/blob/b522d32a3c48faf94bc49676e47185b94807e028/README.org Maybe you can figure out what's going on. :)

Thanks, it sure is nice when it works! :D

snosov1 commented 8 years ago

Thanks! I'll have a look!

snosov1 commented 8 years ago

Just had a look. Couldn't reproduce the issue with the provided file.

Please, let me know if this (or some other) issue is still bothering you.

alphapapa commented 8 years ago

Thanks. Yeah, I'm not sure what the problem was. If it happens again I'll let you know. Keep up the good work. :)