From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ivan Andrus Newsgroups: gmane.emacs.bugs Subject: bug#18854: 25.0.50; Inferior Python mode should use derived-mode-p [with patch] Date: Mon, 27 Oct 2014 16:02:15 +0000 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_D073C8A5CE6Aiandrusadobecom_" X-Trace: ger.gmane.org 1414427792 2652 80.91.229.3 (27 Oct 2014 16:36:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 Oct 2014 16:36:32 +0000 (UTC) To: 18854@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 27 17:36:25 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 1XinHJ-0006Hl-7o for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Oct 2014 17:36:21 +0100 Original-Received: from localhost ([::1]:34838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XinHI-0007kt-SQ for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Oct 2014 12:36:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XinH8-0007jP-90 for bug-gnu-emacs@gnu.org; Mon, 27 Oct 2014 12:36:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XinH0-0006jR-Ph for bug-gnu-emacs@gnu.org; Mon, 27 Oct 2014 12:36:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44773) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XinH0-0006jA-N2 for bug-gnu-emacs@gnu.org; Mon, 27 Oct 2014 12:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XinH0-0006qB-2z for bug-gnu-emacs@gnu.org; Mon, 27 Oct 2014 12:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ivan Andrus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Oct 2014 16:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 18854 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: "bug-gnu-emacs@gnu.org" Original-Received: via spool by submit@debbugs.gnu.org id=B.141442770426216 (code B ref -1); Mon, 27 Oct 2014 16:36:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Oct 2014 16:35:04 +0000 Original-Received: from localhost ([127.0.0.1]:36871 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XinG3-0006ol-5N for submit@debbugs.gnu.org; Mon, 27 Oct 2014 12:35:03 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42837) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XinFz-0006oC-En for submit@debbugs.gnu.org; Mon, 27 Oct 2014 12:35:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XinFm-0006LP-V8 for submit@debbugs.gnu.org; Mon, 27 Oct 2014 12:34:54 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:48106) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XinFm-0006LL-Sz for submit@debbugs.gnu.org; Mon, 27 Oct 2014 12:34:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XinFg-0006uU-51 for bug-gnu-emacs@gnu.org; Mon, 27 Oct 2014 12:34:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XinFY-0006Jh-6K for bug-gnu-emacs@gnu.org; Mon, 27 Oct 2014 12:34:40 -0400 Original-Received: from mail-by2on0072.outbound.protection.outlook.com ([207.46.100.72]:64451 helo=na01-by2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XinFX-0006IZ-Sr for bug-gnu-emacs@gnu.org; Mon, 27 Oct 2014 12:34:32 -0400 Original-Received: from BY2PR0201MB0711.namprd02.prod.outlook.com (25.160.124.17) by BY2PR0201MB0710.namprd02.prod.outlook.com (25.160.124.16) with Microsoft SMTP Server (TLS) id 15.1.6.9; Mon, 27 Oct 2014 16:02:15 +0000 Original-Received: from BY2PR0201MB0711.namprd02.prod.outlook.com ([25.160.124.17]) by BY2PR0201MB0711.namprd02.prod.outlook.com ([25.160.124.17]) with mapi id 15.01.0006.000; Mon, 27 Oct 2014 16:02:15 +0000 Thread-Topic: 25.0.50; Inferior Python mode should use derived-mode-p [with patch] Thread-Index: AQHP8f9gynUtvvKMskuV4sJwl4M1LQ== Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.4.5.141003 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [192.150.9.200] x-microsoft-antispam: BCL:0;PCL:0;RULEID:;SRVR:BY2PR0201MB0710; x-exchange-antispam-report-test: UriScan:; x-forefront-prvs: 0377802854 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(199003)(5423002)(189002)(77096002)(16236675004)(4396001)(92566001)(122556002)(40100003)(15975445006)(83506001)(19580395003)(50986999)(54356999)(92726001)(230783001)(66066001)(86362001)(2656002)(87936001)(20776003)(85306004)(21056001)(101416001)(85852003)(64706001)(97736003)(106356001)(107046002)(120916001)(99396003)(95666004)(99286002)(36756003)(110136001)(31966008)(105586002)(107886001)(19617315012)(76482002)(46102003)(80022003)(106116001)(2351001)(229853001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0201MB0710; H:BY2PR0201MB0711.namprd02.prod.outlook.com; FPR:; MLV:sfv; PTR:InfoNoRecords; A:1; MX:1; LANG:en; X-OriginatorOrg: adobe.com X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). 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:95160 --_000_D073C8A5CE6Aiandrusadobecom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I maintain sage-mode which is implemented as a derived mode of python-mode. Likewise with inferior-sage-mode and inferior-python-mode. There are some places in python-mode where major-mode is checked with eq. This causes some weird breakage when using sage-mode, particularly it causes inferior-sage-mode to hang in some situations [1]. I could probably work around it on the sage-mode side, but I think it makes sense to use derived-mode-p instead, so I'm including this patch -Ivan [1] https://bitbucket.org/gvol/sage-mode/issue/42/run-sage-freezing-emacs-u= pon-launch diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index b230992..06f1ffe 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2221,7 +2221,7 @@ Signals an error if no shell buffer is available for = current buffer." (when (and python-shell--font-lock-buffer (buffer-live-p python-shell--font-lock-buffer)) (kill-buffer python-shell--font-lock-buffer) - (when (eq major-mode 'inferior-python-mode) + (when (derived-mode-p 'inferior-python-mode) (setq python-shell--font-lock-buffer nil))))) (defmacro python-shell-font-lock-with-font-lock-buffer (&rest body) @@ -2238,7 +2238,7 @@ also `with-current-buffer'." (set-buffer python-shell--font-lock-buffer) (set (make-local-variable 'delay-mode-hooks) t) (let ((python-indent-guess-indent-offset nil)) - (when (not (eq major-mode 'python-mode)) + (when (not (derived-mode-p 'python-mode)) (python-mode)) ,@body)))) @@ -2501,7 +2501,7 @@ startup." (defun python-shell-get-buffer () "Return inferior Python buffer for current buffer. If current buffer is in `inferior-python-mode', return it." - (if (eq major-mode 'inferior-python-mode) + (if (derived-mode-p 'inferior-python-mode) (current-buffer) (let* ((dedicated-proc-name (python-shell-get-process-name t)) (dedicated-proc-buffer-name (format "*%s*" dedicated-proc-name)= ) @@ -3482,7 +3482,7 @@ The skeleton will be bound to python-skeleton-NAME." (defun python-ffap-module-path (module) "Function for `ffap-alist' to return path for MODULE." (let ((process (or - (and (eq major-mode 'inferior-python-mode) + (and (derived-mode-p 'inferior-python-mode) (get-buffer-process (current-buffer))) (python-shell-get-process)))) (if (not process) --_000_D073C8A5CE6Aiandrusadobecom_ Content-Type: text/html; charset="us-ascii" Content-ID: <0DF8EB4DE1E2D24CBB0053498EE8AC5B@namprd02.prod.outlook.com> Content-Transfer-Encoding: quoted-printable
I maintain sage-mode which is implemented as a derived mode of
python-mode.  Likewise with inferior-sage-mode and inferior-= python-mode.
There are some places in python-mode where major-mode is checked with<= /div>
eq.  This causes some weird breakage when using sage-mode, p= articularly
it causes inferior-sage-mode to hang in some situations [1]. &nbs= p;I could
probably work around it on the sage-mode side, but I think it makes
sense to use derived-mode-p instead, so I'm including this patch

-Ivan


diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index b230992..06f1ffe 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2221,7 +2221,7 @@ Signals an error if no shell buffer is avail= able for current buffer."
     (when (and python-shell--font-lock-buffer
           &nbs= p;    (buffer-live-p python-shell--font-lock-buffer))
       (kill-buffer python-shell--font-l= ock-buffer)
-      (when (eq major-mode 'inferior-py= thon-mode)
+      (when (derived-mode-p 'inferi= or-python-mode)
         (setq python-shell--f= ont-lock-buffer nil)))))
(defmacro python-shell-font-lock-with-font-lock-buffer (&rest body= )
@@ -2238,7 +2238,7 @@ also `with-current-buffer'."
        (set-buffer python-she= ll--font-lock-buffer)
        (set (make-local-varia= ble 'delay-mode-hooks) t)
        (let ((python-indent-g= uess-indent-offset nil))
-         (when (not (eq major= -mode 'python-mode))
+         (when (not (deri= ved-mode-p 'python-mode))
           &nbs= p;(python-mode))
          ,@body))))=
@@ -2501,7 +2501,7 @@ startup."
(defun python-shell-get-buffer ()
   "Return inferior Python buffer for current buffer.
If current buffer is in `inferior-python-mode', return it."
-  (if (eq major-mode 'inferior-python-mode)
+  (if (derived-mode-p 'inferior-python-mode)
       (current-buffer)
     (let* ((dedicated-proc-name (python-shell-get= -process-name t))
           &nbs= p;(dedicated-proc-buffer-name (format "*%s*" dedicated-proc-name)= )
@@ -3482,7 +3482,7 @@ The skeleton will be bound to python-skeleto= n-NAME."
(defun python-ffap-module-path (module)
   "Function for `ffap-alist' to return path for MODULE= ."
   (let ((process (or
-           &nb= sp;      (and (eq major-mode 'inferior-python= -mode)
+           = ;       (and (derived-mode-p 'inferior-p= ython-mode)
           &nbs= p;            (= get-buffer-process (current-buffer)))
           &nbs= p;       (python-shell-get-process))))
     (if (not process)



--_000_D073C8A5CE6Aiandrusadobecom_--