Malabarba / latex-extra

A series of usability improvements for Emacs latex-mode.
GNU General Public License v3.0
69 stars 14 forks source link

Section folding is not working within a terminal-based Emacs #20

Closed ned2 closed 8 years ago

ned2 commented 8 years ago

Shift-TAB works correctly to collapse all sections, however TAB on it's own over a section/chapter is not resulting in any folding for me. Works fine in a windowed Emacs.

Malabarba commented 8 years ago

My first guess would be that the terminal is probably intercepting the TAB key for its own completion operations. Is that possible?

ned2 commented 8 years ago

I can see the TAB keys when I look at the output of view-lossage. Does this suggest maybe not?

On Mon, 8 Feb 2016 at 23:00 Artur Malabarba notifications@github.com wrote:

My first guess would be that the terminal is probably intercepting the TAB key for its own completion operations. Is that possible?

— Reply to this email directly or view it on GitHub https://github.com/Malabarba/latex-extra/issues/20#issuecomment-181336191 .

ned2 commented 8 years ago

Ah, but if I run the command latex/hide-show manually over a section it does fold/unfold. I'll dig around further.

ned2 commented 8 years ago

So if I put (global-set-key (kbd "TAB") #'latex/hide-show) in my init file, it works. I tried changing the line (define-key map [tab] #'latex/hide-show) in latex-extra.el to use "TAB" instead of [tab] but no luck.

Malabarba commented 8 years ago

Hm. It might be that in the terminal, TAB gets translated to C-i or something.

ned2 commented 8 years ago

When I run describe key in my windowed Emacs I get

TAB (translated from <tab>) runs the command latex/hide-show, which is
an interactive compiled Lisp function in `latex-extra.el'.

It is bound to TAB.

And in the terminal:

TAB runs the command indent-for-tab-command, which is an interactive
compiled Lisp function in `indent.el'.

It is bound to TAB.

Apparently on a tty, the TAB and C-i keys are not usually distinguished: https://www.emacswiki.org/emacs/TabKey

ned2 commented 8 years ago

Based on the above, it seems like changing the binding in the latex-extra.el to use (kbd "TAB") rather than [tab] should fix the problem. Like so:

(define-key map (kbd "TAB") #'latex/hide-show)

But it doesn't. I wondered if it might have something to do with the order of bindings being set, so I tried adding this to my init and it does work:

(eval-after-load 'latex-extra 
  '(define-key latex-extra-mode-map (kbd "TAB") #'latex/hide-show))
Malabarba commented 8 years ago

I've pushed a fix that implements that keybind in a different way. Let me know if it solves your terminal problem.

ned2 commented 8 years ago

Yep it does indeed. Thanks a bunch!