From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Carlos Pita Newsgroups: gmane.emacs.bugs Subject: bug#19748: Date: Mon, 9 Feb 2015 13:45:17 -0300 Message-ID: References: <87d25st324.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1423500372 17015 80.91.229.3 (9 Feb 2015 16:46:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 9 Feb 2015 16:46:12 +0000 (UTC) To: 19748@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 09 17:46:11 2015 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 1YKrTO-0004Ox-5n for geb-bug-gnu-emacs@m.gmane.org; Mon, 09 Feb 2015 17:46:10 +0100 Original-Received: from localhost ([::1]:33731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKrTN-0002gS-Lq for geb-bug-gnu-emacs@m.gmane.org; Mon, 09 Feb 2015 11:46:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKrTK-0002gN-9D for bug-gnu-emacs@gnu.org; Mon, 09 Feb 2015 11:46:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKrTH-0007CZ-2V for bug-gnu-emacs@gnu.org; Mon, 09 Feb 2015 11:46:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47223) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKrTG-0007CR-VS for bug-gnu-emacs@gnu.org; Mon, 09 Feb 2015 11:46:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YKrTG-0000Lo-F5 for bug-gnu-emacs@gnu.org; Mon, 09 Feb 2015 11:46:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87d25st324.fsf@gmail.com> Resent-From: Carlos Pita Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 09 Feb 2015 16:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19748 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug patch Original-Received: via spool by 19748-submit@debbugs.gnu.org id=B19748.14235003461319 (code B ref 19748); Mon, 09 Feb 2015 16:46:02 +0000 Original-Received: (at 19748) by debbugs.gnu.org; 9 Feb 2015 16:45:46 +0000 Original-Received: from localhost ([127.0.0.1]:38463 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YKrSz-0000LD-GA for submit@debbugs.gnu.org; Mon, 09 Feb 2015 11:45:45 -0500 Original-Received: from mail-lb0-f179.google.com ([209.85.217.179]:42478) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YKrSx-0000Kz-TH for 19748@debbugs.gnu.org; Mon, 09 Feb 2015 11:45:44 -0500 Original-Received: by mail-lb0-f179.google.com with SMTP id w7so6781365lbi.10 for <19748@debbugs.gnu.org>; Mon, 09 Feb 2015 08:45:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=IxsebXkJposDPRdgwNjc3Xl1LVfGqyTXhxeTTyRKQVU=; b=iTy8bncmoL9jIE+7yz7TkTmFU0aPSy3UIUzoLmXLNSJSoFacJSZ765iT6Wo/CdIJ4Q AQHXWuO5d0wnXYY+RORaGL2ytWE1fjF85M0F68zkCn4fuiJTC2yVrhLXSuXFc7VDdkSd n+zEo4lxZ+hMo6KOuOmfdjbuH0nxWf1pPKJiwCyGozHNN2QHRpMrsI8b0OM5jNlIpoBW SVwgUUhK4gNNMelveGLP+RPMoiaalNy4x6rUrJFb6JvLAooB1YI+vGVI/Li7Kkct9GJW 9HzO2DG/Kk/Ltm/jLd7Szhlpui1vD8RdUWMv8oRka0b6MtO9kHAsXaBFw/MN2yV+m7Yv bxUw== X-Received: by 10.152.204.40 with SMTP id kv8mr18579955lac.42.1423500337905; Mon, 09 Feb 2015 08:45:37 -0800 (PST) Original-Received: by 10.112.124.202 with HTTP; Mon, 9 Feb 2015 08:45:17 -0800 (PST) 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:99211 Archived-At: Sorry for reopening this, Fabi=C3=A1n. You're right in pointing that this bug was introduced by my fix to 19665. But AFAICS 19665 is indeed a bug: you want to go to the end of the defun line when the search is backward, in order to match arg defun including the current one. There is a more difficult problem here. Say * is the point: 1) You want C-M-a to move the point from def* to *def. 2) You want C-M-a to mode the point from *def to the previous definition. (1) is addressed by 19665. (2) is addressed by this report. Still, there is: 3) You want C-M-h both in def* and in *def to select the current defun. 19665 was intended to correct both cases (*def and def*), but my patch here breaks again the case *def (because for *def the selection reverts now to the pathological behavior described in 19665, just because of the additional condition in the guard, which should be kept anyway because of (2)). Note: I'm checking my assertions 1, 2 and 3 against the standard behavior of elisp mode, which I take as a reference. That's indeed the behavior there. More briefly: for C-M-a you want to distinguish between def* and *def, but for C-M-h you don't. The previous fix here and 19665 correctly address (1) and (2), and mostly address (3) except for the corner case *class, which I address in what follows. Looking at the definition of mark-defun one could clearly see what the problem is. Starting from *class, say, mark-defun will mark the previous defun and then check (if (> (point) opoint) to see that the selected defun was not the desired one. So it goes through the else part sending the point to the end of the class block and then moving backward one defun to select just the last method. I think we could fix this tweaking a bit the behavior of mark-defun, but -unusually- mark-defun allows for no local extension points. A simple advice could do the trick but I don't feel like adding an advice just for python sake to a globally and often used function. The last option I'm able figure out is to replace mark-defun in the python keymap. This is not perfect, as mark-defun could be used programatically also, but I believe it's good enough: (define-key map [remap mark-defun] 'python-mark-defun) (defun python-mark-defun () (interactive) (when (python-info-looking-at- beginning-of-defun) (end-of-line 1)) (mark-defun)) Besides that, I want to emphazise that you still need: - (when (and (< arg 0) + (when (and (> arg 0) and + (> (current-column) (current-indentation)) Also, you may want to set allow-extend for mark-defun. I will post a patch to 19665 including the original change and the mark-defun fix. The (> (current-column) (current-indentation)) fix in this report remains valid except you worked out a cleaner solution for 1, 2 and 3 above.