From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carlos Pita Subject: bug#19749: Date: Mon, 9 Feb 2015 13:10:24 -0300 Message-ID: References: <20150202222819.GA26430@debian> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKqvT-0006xn-EJ for bug-guix@gnu.org; Mon, 09 Feb 2015 11:11:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKqvP-0001mB-2h for bug-guix@gnu.org; Mon, 09 Feb 2015 11:11:07 -0500 Received: from debbugs.gnu.org ([140.186.70.43]:47206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKqvO-0001lz-V8 for bug-guix@gnu.org; Mon, 09 Feb 2015 11:11:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YKqvO-0007wX-6U for bug-guix@gnu.org; Mon, 09 Feb 2015 11:11:02 -0500 In-Reply-To: <20150202222819.GA26430@debian> Sender: "Debbugs-submit" Resent-Message-ID: List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: 19749@debbugs.gnu.org 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)) Cheers -- Carlos