From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#16328: 24.3.50; [PATCH] Enable narrowing to defun with function header comments also visible Date: Fri, 3 Jan 2014 08:38:20 -0800 (PST) Message-ID: References: <52C67B72.3010607@orcon.net.nz> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1388767159 4119 80.91.229.3 (3 Jan 2014 16:39:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 3 Jan 2014 16:39:19 +0000 (UTC) To: Phil Sainty , 16328@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 03 17:39:24 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vz7mN-0000lG-NB for geb-bug-gnu-emacs@m.gmane.org; Fri, 03 Jan 2014 17:39:23 +0100 Original-Received: from localhost ([::1]:50626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vz7mN-0002aa-B5 for geb-bug-gnu-emacs@m.gmane.org; Fri, 03 Jan 2014 11:39:23 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vz7mC-0002QJ-3z for bug-gnu-emacs@gnu.org; Fri, 03 Jan 2014 11:39:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vz7m2-0008FX-Ed for bug-gnu-emacs@gnu.org; Fri, 03 Jan 2014 11:39:12 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46115) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vz7m2-0008FT-Af for bug-gnu-emacs@gnu.org; Fri, 03 Jan 2014 11:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Vz7m1-0001UI-W8 for bug-gnu-emacs@gnu.org; Fri, 03 Jan 2014 11:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 03 Jan 2014 16:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16328 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 16328-submit@debbugs.gnu.org id=B16328.13887671075661 (code B ref 16328); Fri, 03 Jan 2014 16:39:01 +0000 Original-Received: (at 16328) by debbugs.gnu.org; 3 Jan 2014 16:38:27 +0000 Original-Received: from localhost ([127.0.0.1]:60134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vz7lS-0001TE-4Z for submit@debbugs.gnu.org; Fri, 03 Jan 2014 11:38:26 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:47657) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vz7lP-0001T6-OR for 16328@debbugs.gnu.org; Fri, 03 Jan 2014 11:38:24 -0500 Original-Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id s03GcM5A018983 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 3 Jan 2014 16:38:23 GMT Original-Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s03GcLIX024081 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 3 Jan 2014 16:38:21 GMT Original-Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s03GcLAU024075; Fri, 3 Jan 2014 16:38:21 GMT In-Reply-To: <52C67B72.3010607@orcon.net.nz> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8 (707110) [OL 12.0.6680.5000 (x86)] X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:82858 Archived-At: > For languages where the programmer must resort to function header > comments to describe a function, I've always found it frustrating > that `narrow-to-defun' cuts out this often-critical information. >=20 > This patch provides a new function `narrow-to-defun-including- > comments' to keep these comments visible when narrowing. >=20 > As there may be multiple per-line comments instead of a single block > comment, I'm skipping back past ALL preceding comments. That seemed > reasonable instead of trying to guess how the author has structured > their comments. Stopping at an empty line would *probably* be okay, > but in the end I figured that potentially showing too much seemed > better than showing too little. >=20 > (I've included a check for page breaks within the comments, however, > as I was confident about excluding anything before one of those.) >=20 > I didn't think it was wise to encourage users to modify the > behaviour of `narrow-to-defun' itself (I certainly have programmatic > uses for that), so instead I've indicated the way to remap the > interactive bindings for users who wish to use this as standard. Hi Phil. I wonder whether we couldn't just modify `narrow-to-defun', changing to (interactive "P") and using the unused argument as prefix arg to get this behavior? Perhaps someone knows more about the history of that argument. Grepping the Emacs sources, at least, I see no programmatic uses of `narrow-to-defun' that pass an argument. And anyway, the argument is ignored. But presumably we would have kept the unused argument to allow `narrow-to-defun' to be used as a functional argument in a context where it might receive an argument? If there were such uses then perhaps passing the prefix arg could prove problematic. Dunno. Anyway, seems reasonable to try, or at least to investigate. `C-u C-x n d' would then already be one key binding for this. [BTW, I didn't check your code, but if it doesn't already, it could perhaps use code similar to that of `reposition-window', to determine the starting point for the narrowing. That command (`C-M-l') is somewhat similar.]