From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: A Soare Newsgroups: gmane.emacs.devel Subject: tab binding for hs-minor mode Date: Mon, 18 Apr 2011 11:28:33 +0000 (UTC) Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1303126134 8391 80.91.229.12 (18 Apr 2011 11:28:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 18 Apr 2011 11:28:54 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 18 13:28:50 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QBmdN-0002t3-Gn for ged-emacs-devel@m.gmane.org; Mon, 18 Apr 2011 13:28:49 +0200 Original-Received: from localhost ([::1]:36647 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBmdM-0004jC-Rp for ged-emacs-devel@m.gmane.org; Mon, 18 Apr 2011 07:28:48 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:58301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBmdL-0004j7-0u for emacs-devel@gnu.org; Mon, 18 Apr 2011 07:28:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QBmdK-0002ml-4F for emacs-devel@gnu.org; Mon, 18 Apr 2011 07:28:46 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:54728) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBmdJ-0002mg-Ph for emacs-devel@gnu.org; Mon, 18 Apr 2011 07:28:46 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QBmdI-0002qz-8n for emacs-devel@gnu.org; Mon, 18 Apr 2011 13:28:44 +0200 Original-Received: from 89.238.213.66 ([89.238.213.66]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 18 Apr 2011 13:28:44 +0200 Original-Received: from as1789 by 89.238.213.66 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 18 Apr 2011 13:28:44 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 30 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 89.238.213.66 (Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:138543 Archived-At: ;; called once on a line that contains a hidden block, shows the ;; block; otherwise calls the default action of TAB; called twice on a ;; line that does not contain a hidden block, hide the block from the ;; current position of the cursor (defun tab-hs-hide ( &optional arg ) (interactive "P") (let ((sl (save-excursion (move-beginning-of-line nil) (point) ) ) (el (save-excursion (move-end-of-line nil) (point) ) ) obj) (catch 'stop (dotimes (i (- el sl)) (mapc (lambda (overlay) (when (eq 'hs (overlay-get overlay 'invisible)) (setq obj t))) (overlays-at (+ i sl))) (and obj (throw 'stop 'stop) ) ) ) (cond ((and (null obj) (eq last-command this-command) ) (hs-hide-block) ) (obj (progn (move-beginning-of-line nil) (hs-show-block) ) ) (t (save-excursion (funcall (lookup-key (current-global-map) (kbd "^I") ) arg ) ) ) ) ) ) (define-key hs-minor-mode-map [tab] 'tab-hs-hide )