From: Carlos Pita <carlosjosepita@gmail.com>
To: 19665@debbugs.gnu.org
Subject: bug#19665: 25.0.50; python.el: mark defun bug when point is in class statement
Date: Mon, 9 Feb 2015 14:36:33 -0300 [thread overview]
Message-ID: <CAELgYhdUbETUxnFo3VDCpESXMrBYtnOa8mebB9k7xkJg2hcRTA@mail.gmail.com> (raw)
In-Reply-To: <CAELgYhdvG1mU8TuVVOsL8dqG6S0TKOZDUAZYd4_ydFO6_Wkn9A@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 497 bytes --]
Here is a variation of the last patch that behaves better when the
point is in empty lines above a defun.
Another entirely different approach to solve this issue without
redefining mark-defun could be to differentiate:
class M:
def m():
pass*
and
class M:
def m():
pass
*
(where * stands for the point)
In the second case, C-M-h will select the class, while in the first it
will select the method. Then, there would be no need to hack
mark-defun.
What do you think?
[-- Attachment #2: mark-defun.patch --]
[-- Type: text/x-patch, Size: 1260 bytes --]
diff --git a/.emacs.d/lisp/python.el b/.emacs.d/lisp/python.el
index 30b62f5..0337a17 100644
--- a/.emacs.d/lisp/python.el
+++ b/.emacs.d/lisp/python.el
@@ -284,6 +284,7 @@
(define-key map [remap backward-sentence] 'python-nav-backward-block)
(define-key map [remap forward-sentence] 'python-nav-forward-block)
(define-key map [remap backward-up-list] 'python-nav-backward-up-list)
+ (define-key map [remap mark-defun] 'python-mark-defun)
(define-key map "\C-c\C-j" 'imenu)
;; Indent specific
(define-key map "\177" 'python-indent-dedent-line-backspace)
@@ -1285,7 +1286,7 @@ With positive ARG search backwards, else search forwards."
0))))
(found
(progn
- (when (and (< arg 0)
+ (when (and (> arg 0)
(python-info-looking-at-beginning-of-defun))
(end-of-line 1))
(while (and (funcall re-search-fn
@@ -4460,6 +4461,12 @@ default to utf-8."
\f
;;; Utility functions
+(defun python-mark-defun ()
+ (interactive)
+ (when (python-info-looking-at-beginning-of-defun)
+ (end-of-line 1))
+ (mark-defun))
+
(defun python-util-goto-line (line-number)
"Move point to LINE-NUMBER."
(goto-char (point-min))
next prev parent reply other threads:[~2015-02-09 17:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-23 16:12 bug#19665: 25.0.50; python.el: mark defun bug when point is in class statement Carlos Pita
2015-01-23 21:17 ` bug#19665: Carlos Pita
2015-02-02 19:33 ` bug#19665: Carlos Pita
2015-02-09 16:46 ` bug#19665: 25.0.50; python.el: mark defun bug when point is in class statement Carlos Pita
2015-02-09 17:36 ` Carlos Pita [this message]
2015-02-11 15:52 ` Carlos Pita
2015-07-06 4:05 ` Fabián Ezequiel Gallina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAELgYhdUbETUxnFo3VDCpESXMrBYtnOa8mebB9k7xkJg2hcRTA@mail.gmail.com \
--to=carlosjosepita@gmail.com \
--cc=19665@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.