From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: suggestion for tab keybinding in hideshow minor mode. Date: Fri, 03 Dec 2010 09:11:44 +0100 Message-ID: <874oav1dj3.fsf@member.fsf.org> References: <87ipzcqe1z.fsf@fastmail.fm> <87tyiv3foe.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1291363930 28732 80.91.229.12 (3 Dec 2010 08:12:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 3 Dec 2010 08:12:10 +0000 (UTC) Cc: emacs-devel@gnu.org To: Thien-Thi Nguyen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 03 09:12:02 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1POQkJ-0003BD-Bh for ged-emacs-devel@m.gmane.org; Fri, 03 Dec 2010 09:11:59 +0100 Original-Received: from localhost ([127.0.0.1]:50693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POQkI-0007ck-J8 for ged-emacs-devel@m.gmane.org; Fri, 03 Dec 2010 03:11:58 -0500 Original-Received: from [140.186.70.92] (port=42204 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POQkB-0007bT-57 for emacs-devel@gnu.org; Fri, 03 Dec 2010 03:11:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POQk8-0002dH-QW for emacs-devel@gnu.org; Fri, 03 Dec 2010 03:11:50 -0500 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:13532) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POQk8-0002cf-KM for emacs-devel@gnu.org; Fri, 03 Dec 2010 03:11:48 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by deliver.uni-koblenz.de (Postfix) with ESMTP id 49C2B780145A; Fri, 3 Dec 2010 09:11:47 +0100 (CET) Original-Received: from deliver.uni-koblenz.de ([127.0.0.1]) by localhost (deliver.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 14177-02; Fri, 3 Dec 2010 09:11:46 +0100 (CET) X-CHKRCPT: Envelopesender noch tassilo@member.fsf.org Original-Received: from thinkpad (95-88-32-105-dynip.superkabel.de [95.88.32.105]) by deliver.uni-koblenz.de (Postfix) with ESMTP id 597E77801454; Fri, 3 Dec 2010 09:11:46 +0100 (CET) In-Reply-To: <87tyiv3foe.fsf@ambire.localdomain> (Thien-Thi Nguyen's message of "Fri, 03 Dec 2010 00:42:25 +0100") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) X-Virus-Scanned: amavisd-new at uni-koblenz.de X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:133336 Archived-At: Thien-Thi Nguyen writes: > () Tassilo Horn > () 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 =E2=80=98line-beginning-position=E2=80=99, =E2=80=98line-end-pos= ition=E2=80=99, 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. > =E2=80=98hs-already-hidden-p=E2=80=99, =E2=80=98hs-overlay-at=E2=80=99. Yep, that makes it much simpler: --8<---------------cut here---------------start------------->8--- (eval-after-load 'hideshow ;; Use TAB to toggle hiding/showing a block. '(progn (define-context-key hs-minor-mode-map (kbd "TAB") (and (not (hs-already-hidden-p)) (eq last-command this-command)) hs-hide-block) (define-context-key hs-minor-mode-map (kbd "TAB") hs-already-hidden-p hs-show-block))) --8<---------------cut here---------------end--------------->8--- Thanks for the hint! Tassilo