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

I have to enable hl-todo-mode in LaTeX-mode-hook? #52

Closed
avatar-lavventura opened this issue May 25, 2020 · 10 comments
Closed

I have to enable hl-todo-mode in LaTeX-mode-hook? #52

avatar-lavventura opened this issue May 25, 2020 · 10 comments
Labels

Comments

@avatar-lavventura
Copy link

avatar-lavventura commented May 25, 2020

Currenty I am on LaTeX-mode-hook and added following line global-hl-todo-mode into .emacs file to use hl-todo. On its readme it says:

To highlight keywords turn on hl-todo-mode in individual buffers or use the the global variant global-hl-todo-mode.

My setup:

; L A T E X ;
(setq LaTeX-item-indent 0)
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)
(setq-default fill-column 80)  ; M-q
(require 'tex)

(add-hook 'LaTeX-mode-hook (lambda ()
  (TeX-global-PDF-mode t)
  (global-hl-todo-mode t)  ; <= added here
  ))

(global-hl-todo-mode 1) ; <= added bottom of the page

When I open emacs -nw file.tex, I need to disable and than re-enable global-hl-todo-mode in order to use it. Is there any way to fix this issue?

Please note that, this was working perfectly fine in python-mode.

@avatar-lavventura avatar-lavventura changed the title I have to disable and re-enable in order to use hl-todo-mode I have to enable hl-todo-mode in text-mode? May 25, 2020
@avatar-lavventura avatar-lavventura changed the title I have to enable hl-todo-mode in text-mode? I have to enable hl-todo-mode in LaTeX-mode-hook? May 25, 2020
@tarsius
Copy link
Owner

tarsius commented May 25, 2020

LaTeX-mode-hook

I don't think that actually exists. LaTeX-mode is an alias for latex-mode, but as far as I can tell the same isn't true for the hook variable.

On a mode hook you should enable hl-todo-mode not global-hl-todo-mode.

But just enabling global-hl-todo-mode directly at the top-level of the init file should be enough anyway. For me that works.

@avatar-lavventura
Copy link
Author

avatar-lavventura commented May 25, 2020

Sorry yes I was using latex-mode.

I have added (global-hl-todo-mode 1) to top of the .emacs file. And also added:
(add-hook 'LaTeX-mode-hook 'hl-todo-mode).

(global-hl-todo-mode 1)

(setq LaTeX-item-indent 0)
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)
(add-hook 'LaTeX-mode-hook 'hl-todo-mode)
(require 'tex)

(add-hook 'LaTeX-mode-hook (lambda ()
  (TeX-global-PDF-mode t)
  ))

I observer that I have to do M-x hl-todo-mode (disables) and than M-x hl-todo-mode to re-enable again to make it work.

@tarsius
Copy link
Owner

tarsius commented May 25, 2020

Make sure you are using the latest hl-todo version.

(add-hook 'LaTeX-mode-hook 'hl-todo-mode)
           ^^^^^
           Again, I don't think that has any effect.
           Try `latex-mode-hook'.

@tarsius
Copy link
Owner

tarsius commented May 26, 2020

I recommend you try to reproduce this issue starting from emacs -Q. All you should need to do is to then interactively enabling global-hl-todo-mode. After that hl-todo-mode should be automatically enabled and effective in latex-mode buffers (and others).

If that works then start adding your configuration piece by piece until you hit the thing that causes the breakage.

@avatar-lavventura
Copy link
Author

avatar-lavventura commented May 26, 2020

Both version are same on linux and mac

Linux: 20200103.1239 | Mac: 20200103.1239

It works when I open an empty file and type TODO. It does working on the .tex file I was working on it. When I copy that file under a different name it works. There were other files with different endings maybe they affect the output.

$ emacs -nw Paper.tex  // does not work
$ cp Paper.tex Paper1.tex && emacs -nw Paper1.tex // works

$ ls Paper.*
Paper.aux         Paper.log
Paper.bbl          Paper.out
Paper.blg          Paper.pdf
Paper.fdb_latexmk  Paper.tex
Paper.fls          Paper.txt

@tarsius
Copy link
Owner

tarsius commented May 26, 2020

$ emacs -nw Paper.tex  // does not work
$ cp Paper.tex Paper1.tex && emacs -nw Paper1.tex // works

Well that is weird. I don't see how hl-todo itself could be responsible for that difference.

Check if the same major-mode gets enabled in both buffers. That's all I got.

@avatar-lavventura
Copy link
Author

@tarsius: I have this follow up maybe it might solve my issue:

https://emacs.stackexchange.com/a/58769/18414

@tarsius
Copy link
Owner

tarsius commented May 28, 2020

For some reason as soon as I followed the link this rang a bell.

This issue came up before in #26. Later I'll read through that again and maybe add a FAQ entry.

@avatar-lavventura
Copy link
Author

Adding: (add-hook 'TeX-update-style-hook 'hl-todo-mode) solved my problem.

@tarsius
Copy link
Owner

tarsius commented May 29, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants