[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [PATCH]: New Add defun org-mode-or-derived-mode-p
From: |
Carsten Dominik |
Subject: |
Re: [O] [PATCH]: New Add defun org-mode-or-derived-mode-p |
Date: |
Thu, 6 Oct 2011 10:20:23 +0200 |
On Sep 5, 2011, at 9:36 AM, Tassilo Horn wrote:
> Stefan Reichör <address@hidden> writes:
>
> Hi Stefan,
>
>>>> +(defun org-mode-or-derived-mode-p ()
>>>> + "Check if the current buffer is in Org-mode or a derived mode."
>>>> + (if (derived-mode-p 'org-mode) t nil))
>>>
>>> The if is superfluous. And instead of a new function, I'd rather add an
>>> optional `derived' parameter to `org-mode-p'.
>>
>> (derived-mode-p 'org-mode) returns either 'org-mode or nil
>>
>> The reason for the if is, that (org-mode-p) returns either t or nil
>
> Yes, but from an elisp perspective, 'org-mode is as true as t.
>
> BTW: I'm not sure if there is any reasonable benefit for `org-mode-p',
> anyway. Checking the rest of the emacs source tree, then the convention
> is to either use
>
> (eq major-mode 'foo-mode)
>
> or
>
> (derived-mode-p 'foo-mode)
>
> depending on what's needed. I don't see why (org-mode-p) or even
> (org-mode-p 'derived) is clearer...
I agree, it is not clearer, only a bit more compact.
I don't think we should have a new function here. Just make a patch
that used derived-mode-p in places where this is needed. I would
accept such a patch.
- Carsten
- Re: [O] [PATCH]: New Add defun org-mode-or-derived-mode-p,
Carsten Dominik <=