From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cassio Koshikumo Subject: Re: [PATCH]: New Add defun org-mode-or-derived-mode-p Date: Thu, 03 Nov 2011 19:35:01 -0200 Message-ID: References: <871uvz56th.fsf@thinkpad.tsdh.de> <87wrdnigpd.fsf@thinkpad.tsdh.de> <61054BA2-E0B8-40B9-B62E-FB0EB04E99CF@gmail.com> <87fwj0gfny.fsf@thinkpad.tsdh.de> <874nz1jrti.fsf@gnu.org> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:54910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RM51g-0008Em-9X for emacs-orgmode@gnu.org; Thu, 03 Nov 2011 17:40:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RM51e-0007Eb-Sj for emacs-orgmode@gnu.org; Thu, 03 Nov 2011 17:40:44 -0400 Received: from mail-gy0-f169.google.com ([209.85.160.169]:51169) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RM51e-0007ES-Q6 for emacs-orgmode@gnu.org; Thu, 03 Nov 2011 17:40:42 -0400 Received: by gyg10 with SMTP id 10so2083587gyg.0 for ; Thu, 03 Nov 2011 14:40:42 -0700 (PDT) In-Reply-To: <874nz1jrti.fsf@gnu.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Tassilo Horn Cc: emacs-orgmode@gnu.org, Carsten Dominik Hi, all, On the last few days I've been working on a major mode derived from org-mod= e. While I was at it, I've encoutered some difficulties related to those repor= ted by the OP (Stefan). Specifically: in a lot of places, org-mode will check if it's the current major-mode and, if it's not, will refuse to perform some important task. But this poses a problem: a derived mode will always fail the test (eq major-mode 'org-mode) So, as long as org-mode relies on this test to perform some tasks, a derived mode will have non-functional pieces and bugs. Before this patch, all the checking was centralized in the defsubst `org-mode-p'. While I was developing my mode, I just changed it to (defsubst org-mode-p () (derived-mode-p 'org-mode)) Of course, this was just a temporary workaround, but I was actually plannin= g on submitting a patch that implemented the (already discussed) `org-mode-or-derived-mode-p' alternative, replacing all calls to `org-mode-= p' with calls to it. But then comes this patch, which removes `org-mode-p' altogether. So, now, = there are several instances of the always-failing test on the code. Clearly, this= is a big problem for anyone writing derived modes (there doesn't seem to be a lo= t of people doing that, but still). So, finally, here's my question: would it be possible to change all the (eq major-mode 'org-mode) tests and replace them with (derived-mode-p 'org-mode= )? Is there any reason not to do this? That's effectively what happened when I changed the defsubst and I haven't noticed any problems. After all, org-mode will continue to always pass that= test -- it's just that the derived modes will start to pass it too. If no ones' against it, I think I could create the patch. I haven't signed = the FSF papers, but this change falls neatly into the "repetitive" category. Cheers, --=20 C=C3=A1ssio Koshikumo At Sat, 22 Oct 2011 11:31:21 +0200, Bastien wrote: >=20 > Hi Tassilo, >=20 > Tassilo Horn writes: >=20 > > Ups, I've slightly misread your suggestion. Currently, there is only > > one place in org-src.el that check for being a mode derived from > > org-mode or org-mode itself. The second is useless, because > > (derived-mode-p 'org-mode) is true for org-mode, too. > > > > But as I've said, I've misread your suggestion and made a patch that > > completely erases org-mode-p and all its calls. Feel free to apply or > > discard it. :-) >=20 > I applied this patch -- thanks for it. >=20 > IMHO another reason for using (eq major-mode 'org-mode) instead of > (org-mode-p) is that new contributors are likely to use this more > explicit (though longer) expression before they find out that a=20 > defsubst is available for that. >=20 > --=20 > Bastien >=20 >=20