[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: |
Tassilo Horn |
Subject: |
Re: [O] [PATCH]: New Add defun org-mode-or-derived-mode-p |
Date: |
Mon, 05 Sep 2011 09:36:14 +0200 |
User-agent: |
Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux) |
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...
Bye,
Tassilo