[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: suggestion for tab keybinding in hideshow minor mode.

From: Tassilo Horn
Subject: Re: suggestion for tab keybinding in hideshow minor mode.
Date: Fri, 03 Dec 2010 09:11:44 +0100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)

Thien-Thi Nguyen <address@hidden> writes:

> () Tassilo Horn <address@hidden>
> () Thu, 02 Dec 2010 18:28:56 +0100
>      (let ((obj (car (overlays-in
>                       (save-excursion (move-beginning-of-line nil) (point))
>                       (save-excursion (move-end-of-line nil) (point))))))
>        ...)
> See also ‘line-beginning-position’, ‘line-end-position’,

Yeah, first I've replaced the above with exactly those, but the behavior
was different.  When I've hidden an inner block and then an outer block
(like, a function definition with an inner for loop), I was unable to
show it again.

I suspect that `line-beginning-position' and `line-end-position'
consider "real" lines, whereas the move-functions mean visible lines.
In a hidden block {...} the open brace is not on the same real line than
the closing one.

> ‘hs-already-hidden-p’, ‘hs-overlay-at’.

Yep, that makes it much simpler:

--8<---------------cut here---------------start------------->8---
(eval-after-load 'hideshow
  ;; Use TAB to toggle hiding/showing a block.
     (define-context-key hs-minor-mode-map
       (kbd "TAB")
       (and (not (hs-already-hidden-p))
            (eq last-command this-command))

     (define-context-key hs-minor-mode-map
       (kbd "TAB")
--8<---------------cut here---------------end--------------->8---

Thanks for the hint!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]