From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: widen-one-level [was: Emacs's handling of line numbers] Date: Sun, 18 Apr 2010 11:15:58 -0700 Message-ID: <7DAA22BBC7FD45D9996D3EE994E01C16@us.oracle.com> References: <837ho6czb6.fsf@gnu.org><8339yucbsg.fsf@gnu.org> <83wrw5bxkc.fsf@gnu.org> <90D3EB66AA37491881EB2B26100925C2@us.oracle.com> 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 1271614569 7262 80.91.229.12 (18 Apr 2010 18:16:09 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 18 Apr 2010 18:16:09 +0000 (UTC) Cc: monnier@iro.umontreal.ca, mark.lillibridge@hp.com, emacs-devel@gnu.org To: "'Juanma Barranquero'" , "'Eli Zaretskii'" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 18 20:16:01 2010 connect(): No such file or directory 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 1O3Z2G-0001fE-Cx for ged-emacs-devel@m.gmane.org; Sun, 18 Apr 2010 20:16:00 +0200 Original-Received: from localhost ([127.0.0.1]:57215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O3Z2F-000297-Ek for ged-emacs-devel@m.gmane.org; Sun, 18 Apr 2010 14:15:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O3Z2A-00028O-P1 for emacs-devel@gnu.org; Sun, 18 Apr 2010 14:15:54 -0400 Original-Received: from [140.186.70.92] (port=39982 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O3Z28-00027c-PD for emacs-devel@gnu.org; Sun, 18 Apr 2010 14:15:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O3Z26-0008P9-C3 for emacs-devel@gnu.org; Sun, 18 Apr 2010 14:15:52 -0400 Original-Received: from rcsinet10.oracle.com ([148.87.113.121]:47373) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O3Z26-0008Oz-3X; Sun, 18 Apr 2010 14:15:50 -0400 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o3IIFkXr019452 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 18 Apr 2010 18:15:47 GMT Original-Received: from acsmt355.oracle.com (acsmt355.oracle.com [141.146.40.155]) by acsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o3II127p015721; Sun, 18 Apr 2010 18:15:45 GMT Original-Received: from abhmt019.oracle.com by acsmt353.oracle.com with ESMTP id 185563871271614543; Sun, 18 Apr 2010 11:15:43 -0700 Original-Received: from dradamslap1 (/10.175.221.180) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 18 Apr 2010 11:15:43 -0700 X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Thread-Index: Acrec3UOPBDBfDooTEK+bshz8aLA0gAADRaAACuKGeA= In-Reply-To: <90D3EB66AA37491881EB2B26100925C2@us.oracle.com> X-Auth-Type: Internal IP X-Source-IP: acsinet15.oracle.com [141.146.126.227] X-CT-RefId: str=0001.0A090207.4BCB4C54.0035:SCFMA922111,ss=1,fgs=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:123852 Archived-At: > One thing I've sometimes thought would be handy is an > additional widening command, `widen-one-level', which > would widen only as far as the next-to-last narrowing. > > You can narrow and then narrow further, any number of times. > But `widen' always widens completely. Sometimes I would like > to just undo the last level of narrowing, returning to the > previous level (or to the top level, if there is > only one narrowing). > > This would require managing a list or stack of narrowing > limits etc. > > I have no idea whether anyone else would find such a command > useful. And I can't really characterize useful use cases. > But I know I've sometimes wanted such a feature. If you want to get a quick idea what this would be like, eval this code and bind `widen-one-level' (e.g. to `C-x n w' ;-)). --- (defvar restriction-stack () "Stack of buffer restrictions.") (make-variable-buffer-local 'restriction-stack) (defun widen-one-level (top) "Widen to the previous buffer restriction. With a prefix argument, widen completely." (interactive "P") (unless restriction-stack (error "Cannot widen; buffer is not narrowed")) (if top (widen) (pop restriction-stack) (if (null restriction-stack) (widen) (narrow-to-region (caar restriction-stack) (cdar restriction-stack)) (pop restriction-stack)))) (defadvice narrow-to-region (before push-restriction-stack activate) (setq restriction-stack (cons (cons start end) restriction-stack)) (when (and (= start 1) (= end (1+ (buffer-size)))) (setq restriction-stack ()))) (defadvice widen (before empty-restriction-stack activate) (setq restriction-stack ())) ; (define-key ctl-x-map "nw" 'widen-one-level) --- Another possibility would be to make a restriction ring, instead of a stack, and let you browse among the restrictions...