emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH]: New Add defun org-mode-or-derived-mode-p
@ 2011-09-02 11:09 Stefan Reichör
  2011-09-02 14:59 ` Tassilo Horn
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Reichör @ 2011-09-02 11:09 UTC (permalink / raw)
  To: emacs-orgmode

2011-09-02  Stefan Reichoer  <stefan@xsteve.at>

    Add org-mode-or-derived-mode-p to support org-mode derived modes

	* org-macs.el (org-mode-or-derived-mode-p): New defun

	* org-src.el (org-edit-src-code): Use org-mode-or-derived-mode-p

	* org.el (org-entry-properties): Use org-mode-or-derived-mode-p instead of org-mode-p


git diff -M  HEAD
                                                                        
  M lisp/org-macs.el 
  M lisp/org-src.el 
  M lisp/org.el 
                                                                        

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 13aff02..7603b42 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -276,6 +276,10 @@ we turn off invisibility temporarily.  Use this in a `let' form."
   "Check if the current buffer is in Org-mode."
   (eq major-mode 'org-mode))
 
+(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))
+
 (defsubst org-last (list)
   "Return the last element of LIST."
   (car (last list)))
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 0e8b1b1..a62f8da 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -215,7 +215,7 @@ buffer."
 	(case-fold-search t)
 	(info (org-edit-src-find-region-and-lang))
 	(full-info (org-babel-get-src-block-info))
-	(org-mode-p (or (org-mode-p) (derived-mode-p 'org-mode)))
+	(org-mode-p (org-mode-or-derived-mode-p))
 	(beg (make-marker))
 	(end (make-marker))
 	(allow-write-back-p (null code))
diff --git a/lisp/org.el b/lisp/org.el
index d63b854..d82425c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13828,7 +13828,7 @@ things up because then unnecessary parsing is avoided."
 	  beg end range props sum-props key key1 value string clocksum)
       (save-excursion
 	(when (condition-case nil
-		  (and (org-mode-p) (org-back-to-heading t))
+		  (and (org-mode-or-derived-mode-p) (org-back-to-heading t))
 		(error nil))
 	  (setq beg (point))
 	  (setq sum-props (get-text-property (point) 'org-summaries))

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH]: New Add defun org-mode-or-derived-mode-p
  2011-09-02 11:09 [PATCH]: New Add defun org-mode-or-derived-mode-p Stefan Reichör
@ 2011-09-02 14:59 ` Tassilo Horn
  2011-09-05  6:50   ` Stefan Reichör
  0 siblings, 1 reply; 9+ messages in thread
From: Tassilo Horn @ 2011-09-02 14:59 UTC (permalink / raw)
  To: emacs-orgmode

Stefan Reichör <stefan@xsteve.at> writes:

> +(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'.

Bye,
Tassilo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH]: New Add defun org-mode-or-derived-mode-p
  2011-09-02 14:59 ` Tassilo Horn
@ 2011-09-05  6:50   ` Stefan Reichör
  2011-09-05  7:36     ` Tassilo Horn
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Reichör @ 2011-09-05  6:50 UTC (permalink / raw)
  To: emacs-orgmode

Tassilo Horn <tassilo@member.fsf.org> writes:

> Stefan Reichör <stefan@xsteve.at> writes:
>
>> +(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

The optional derived parameter for org-mode-p is a good idea.
Going one step further I think that using a strict parameter would be
even better.

Because I think that org-mode-p should also return t in derived modes.
Only in some rare cases (org-mode-p t) can be used to allow a strict org-mode check.


I'd like to preper a patch. Please tell me, if I should use the derived
or the strict parameter.

Thanks,
  Stefan.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH]: New Add defun org-mode-or-derived-mode-p
  2011-09-05  6:50   ` Stefan Reichör
@ 2011-09-05  7:36     ` Tassilo Horn
  2011-10-06  8:20       ` Carsten Dominik
  0 siblings, 1 reply; 9+ messages in thread
From: Tassilo Horn @ 2011-09-05  7:36 UTC (permalink / raw)
  To: emacs-orgmode

Stefan Reichör <stefan@xsteve.at> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH]: New Add defun org-mode-or-derived-mode-p
  2011-09-05  7:36     ` Tassilo Horn
@ 2011-10-06  8:20       ` Carsten Dominik
  2011-10-11  7:18         ` Tassilo Horn
  0 siblings, 1 reply; 9+ messages in thread
From: Carsten Dominik @ 2011-10-06  8:20 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-orgmode


On Sep 5, 2011, at 9:36 AM, Tassilo Horn wrote:

> Stefan Reichör <stefan@xsteve.at> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH]: New Add defun org-mode-or-derived-mode-p
  2011-10-06  8:20       ` Carsten Dominik
@ 2011-10-11  7:18         ` Tassilo Horn
  2011-10-22  9:31           ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Tassilo Horn @ 2011-10-11  7:18 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1069 bytes --]

Carsten Dominik <carsten.dominik@gmail.com> writes:

Hi Carsten,

>> 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.

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. :-)

Bye,
Tassilo

[-- Attachment #2: 0001-Replace-org-mode-p-with-usual-eq-major-mode-org-mode.patch --]
[-- Type: text/x-patch, Size: 41993 bytes --]

From 92e83b95aead15a4346e671de6ba211c6ca95a43 Mon Sep 17 00:00:00 2001
From: Tassilo Horn <tassilo@member.fsf.org>
Date: Tue, 11 Oct 2011 09:07:27 +0200
Subject: [PATCH] Replace org-mode-p with usual (eq major-mode 'org-mode)
 check

Additionally, replace one

  (or (org-mode-p) (derived-mode-p 'org-mode))

with

  (derived-mode-p 'org-mode)

cause that is reflexive anyway (returns true, if the current mode is
org-mode).

Delete one check testing for org-mode or org derived mode
---
 BUGFIXING/org-log.el              |    4 +-
 contrib/lisp/org-annotate-file.el |    2 +-
 contrib/lisp/org-contacts.el      |    4 +-
 contrib/lisp/org-expiry.el        |    4 +-
 contrib/lisp/org-lparse.el        |    2 +-
 contrib/lisp/org-registry.el      |    2 +-
 contrib/lisp/org-toc.el           |    2 +-
 lisp/org-agenda.el                |   26 +++++++-------
 lisp/org-archive.el               |    2 +-
 lisp/org-ascii.el                 |    2 +-
 lisp/org-capture.el               |   16 ++++----
 lisp/org-colview-xemacs.el        |    6 ++--
 lisp/org-colview.el               |    6 ++--
 lisp/org-ctags.el                 |    2 +-
 lisp/org-docbook.el               |    2 +-
 lisp/org-footnote.el              |   14 ++++----
 lisp/org-html.el                  |    2 +-
 lisp/org-id.el                    |    4 +-
 lisp/org-indent.el                |    2 +-
 lisp/org-latex.el                 |    2 +-
 lisp/org-macs.el                  |    6 +---
 lisp/org-mouse.el                 |    4 +-
 lisp/org-remember.el              |    4 +-
 lisp/org-src.el                   |    8 ++--
 lisp/org-table.el                 |    4 +-
 lisp/org-timer.el                 |    2 +-
 lisp/org.el                       |   68 ++++++++++++++++++------------------
 testing/org-test.el               |    2 +-
 28 files changed, 100 insertions(+), 104 deletions(-)

diff --git a/BUGFIXING/org-log.el b/BUGFIXING/org-log.el
index 8ebedfe..1fb82e6 100644
--- a/BUGFIXING/org-log.el
+++ b/BUGFIXING/org-log.el
@@ -21,7 +21,7 @@
     (and delete-other-windows (delete-other-windows))
     (widen)
     (goto-char pos)
-    (when (org-mode-p)
+    (when (eq major-mode 'org-mode)
       (org-show-context 'agenda)
       (save-excursion
 	(and (outline-next-heading)
@@ -54,7 +54,7 @@
     (switch-to-buffer-other-window buffer)
     (widen)
     (goto-char pos)
-    (when (org-mode-p)
+    (when (eq major-mode 'org-mode)
       (org-show-context 'agenda)
       (save-excursion
 	(and (outline-next-heading)
diff --git a/contrib/lisp/org-annotate-file.el b/contrib/lisp/org-annotate-file.el
index 265b55f..eb53ab1 100644
--- a/contrib/lisp/org-annotate-file.el
+++ b/contrib/lisp/org-annotate-file.el
@@ -99,7 +99,7 @@ show the relevant section"
                        (concat "file:" filename "::" line)
                                (org-annotate-file-elipsify-desc line))))
     (with-current-buffer (find-file org-annotate-file-storage-file)
-      (unless (org-mode-p)
+      (unless (eq major-mode 'org-mode)
         (org-mode))
       (goto-char (point-min))
       (widen)
diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index f4d9cd7..167caa0 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/org-contacts.el
@@ -157,7 +157,7 @@ If both match values are nil, return all contacts."
     (dolist (file (org-contacts-files))
       (org-check-agenda-file file)
       (with-current-buffer (org-get-agenda-file-buffer file)
-        (unless (org-mode-p)
+        (unless (eq major-mode 'org-mode)
           (error "File %s is no in `org-mode'" file))
         (org-scan-tags
          '(add-to-list 'markers (set-marker (make-marker) (point)))
@@ -263,7 +263,7 @@ If both match values are nil, return all contacts."
     (when marker
       (switch-to-buffer-other-window (marker-buffer marker))
       (goto-char marker)
-      (when (org-mode-p)
+      (when (eq major-mode 'org-mode)
         (org-show-context 'agenda)
         (save-excursion
           (and (outline-next-heading)
diff --git a/contrib/lisp/org-expiry.el b/contrib/lisp/org-expiry.el
index 9fab74c..bc4840b 100644
--- a/contrib/lisp/org-expiry.el
+++ b/contrib/lisp/org-expiry.el
@@ -185,7 +185,7 @@ restart `org-mode' if necessary."
 	      (lambda() (add-hook 'before-save-hook
 				  'org-expiry-process-entries t t)))
     ;; need this to refresh org-mode hooks
-    (when (org-mode-p)
+    (when (eq major-mode 'org-mode)
       (org-mode)
       (if (org-called-interactively-p)
 	  (message "Org-expiry insinuated, `org-mode' restarted.")))))
@@ -206,7 +206,7 @@ and restart `org-mode' if necessary."
 				   'org-expiry-process-entries t t)))
   (when arg
     ;; need this to refresh org-mode hooks
-    (when (org-mode-p)
+    (when (eq major-mode 'org-mode)
       (org-mode)
       (if (org-called-interactively-p)
 	  (message "Org-expiry de-insinuated, `org-mode' restarted.")))))
diff --git a/contrib/lisp/org-lparse.el b/contrib/lisp/org-lparse.el
index fbc9024..46888e9 100755
--- a/contrib/lisp/org-lparse.el
+++ b/contrib/lisp/org-lparse.el
@@ -118,7 +118,7 @@ this command to convert it."
   (interactive "Mbackend: \nr")
   (let (reg backend-string buf pop-up-frames)
     (save-window-excursion
-      (if (org-mode-p)
+      (if (eq major-mode 'org-mode)
 	  (setq backend-string (org-lparse-region backend beg end t 'string))
 	(setq reg (buffer-substring beg end)
 	      buf (get-buffer-create "*Org tmp*"))
diff --git a/contrib/lisp/org-registry.el b/contrib/lisp/org-registry.el
index 9f4b65c..01d059d 100644
--- a/contrib/lisp/org-registry.el
+++ b/contrib/lisp/org-registry.el
@@ -219,7 +219,7 @@ Use with caution.  This could slow down things a bit."
 (defun org-registry-update ()
   "Update the registry for the current Org file."
   (interactive)
-  (unless (org-mode-p) (error "Not in org-mode"))
+  (unless (eq major-mode 'org-mode) (error "Not in org-mode"))
   (let* ((from-file (expand-file-name (buffer-file-name)))
 	 (new-entries (org-registry-get-entries from-file)))
     (with-temp-buffer
diff --git a/contrib/lisp/org-toc.el b/contrib/lisp/org-toc.el
index 2ea3be8..3e3b972 100644
--- a/contrib/lisp/org-toc.el
+++ b/contrib/lisp/org-toc.el
@@ -218,7 +218,7 @@ specified, then make `org-toc-recenter' use this value."
 (defun org-toc-show (&optional depth position)
   "Show the table of contents of the current Org-mode buffer."
   (interactive "P")
-  (if (org-mode-p)
+  (if (eq major-mode 'org-mode)
       (progn (setq org-toc-base-buffer (current-buffer))
 	     (setq org-toc-odd-levels-only org-odd-levels-only))
     (if (eq major-mode 'org-toc-mode)
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index b208d1e..ef81a2f 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2315,7 +2315,7 @@ Pressing `<' twice means to restrict to the current subtree or region
 			       nil 'face 'org-warning)))))))
 	 t t))
        ((equal keys "L")
-	(unless (org-mode-p)
+	(unless (eq major-mode 'org-mode)
 	  (error "This is not an Org-mode file"))
 	(unless restriction
 	  (put 'org-agenda-files 'org-restrict (list bfn))
@@ -2350,7 +2350,7 @@ Agenda views are separated by `org-agenda-block-separator'."
   "The user interface for selecting an agenda command."
   (catch 'exit
     (let* ((bfn (buffer-file-name (buffer-base-buffer)))
-	   (restrict-ok (and bfn (org-mode-p)))
+	   (restrict-ok (and bfn (eq major-mode 'org-mode)))
 	   (region-p (org-region-active-p))
 	   (custom org-agenda-custom-commands)
 	   (selstring "")
@@ -2896,7 +2896,7 @@ removed from the entry content.  Currently only `planning' is allowed here."
   (let (txt drawer-re kwd-time-re ind)
     (save-excursion
       (with-current-buffer (marker-buffer marker)
-	(if (not (org-mode-p))
+	(if (not (eq major-mode 'org-mode))
 	    (setq txt "")
 	  (save-excursion
 	    (save-restriction
@@ -3012,7 +3012,7 @@ removed from the entry content.  Currently only `planning' is allowed here."
 
 (defun org-check-for-org-mode ()
   "Make sure current buffer is in org-mode.  Error if not."
-  (or (org-mode-p)
+  (or (eq major-mode 'org-mode)
       (error "Cannot execute org-mode agenda command on buffer in %s"
 	     major-mode)))
 
@@ -3899,7 +3899,7 @@ in `org-agenda-text-search-extra-files'."
 				    file))))
 	(with-current-buffer buffer
 	  (with-syntax-table (org-search-syntax-table)
-	    (unless (org-mode-p)
+	    (unless (eq major-mode 'org-mode)
 	      (error "Agenda file %s is not in `org-mode'" file))
 	    (let ((case-fold-search t))
 	      (save-excursion
@@ -4092,7 +4092,7 @@ The prefix arg TODO-ONLY limits the search to TODO entries."
 		       (format "ORG-AGENDA-ERROR: No such org-file %s" file))
 		  rtnall (append rtnall rtn))
 	  (with-current-buffer buffer
-	    (unless (org-mode-p)
+	    (unless (eq major-mode 'org-mode)
 	      (error "Agenda file %s is not in `org-mode'" file))
 	    (save-excursion
 	      (save-restriction
@@ -4536,7 +4536,7 @@ the documentation of `org-diary'."
 	;; If file does not exist, make sure an error message ends up in diary
 	(list (format "ORG-AGENDA-ERROR: No such org-file %s" file))
       (with-current-buffer buffer
-	(unless (org-mode-p)
+	(unless (eq major-mode 'org-mode)
 	  (error "Agenda file %s is not in `org-mode'" file))
 	(let ((case-fold-search nil))
 	  (save-excursion
@@ -5494,7 +5494,7 @@ Any match of REMOVE-RE will be removed from TXT."
 	   (time-of-day (and dotime (org-get-time-of-day ts)))
 	   stamp plain s0 s1 s2 rtn srp l
 	   duration thecategory)
-      (and (org-mode-p) buffer-file-name
+      (and (eq major-mode 'org-mode) buffer-file-name
 	   (add-to-list 'org-agenda-contributing-files buffer-file-name))
       (when (and dotime time-of-day)
 	;; Extract starting and ending time and move them to prefix
@@ -5542,7 +5542,7 @@ Any match of REMOVE-RE will be removed from TXT."
 		     (concat (make-string (max (- 50 (length txt)) 1) ?\ )
 			     (match-string 2 txt))
 		     t t txt))))
-      (when (org-mode-p)
+      (when (eq major-mode 'org-mode)
 	(setq effort
 	      (condition-case nil
 		  (org-get-effort
@@ -6820,7 +6820,7 @@ and by additional input from the age of a schedules or deadline entry."
     (widen)
     (push-mark)
     (goto-char pos)
-    (when (org-mode-p)
+    (when (eq major-mode 'org-mode)
       (org-show-context 'agenda)
       (save-excursion
 	(and (outline-next-heading)
@@ -6849,7 +6849,7 @@ Point is in the buffer where the item originated.")
      (with-current-buffer buffer
        (save-excursion
 	 (goto-char pos)
-	 (if (and (org-mode-p) (not (member type '("sexp"))))
+	 (if (and (eq major-mode 'org-mode) (not (member type '("sexp"))))
 	     (setq dbeg (progn (org-back-to-heading t) (point))
 		   dend (org-end-of-subtree t t))
 	   (setq dbeg (point-at-bol)
@@ -6901,7 +6901,7 @@ Point is in the buffer where the item originated.")
 	 (pos (marker-position marker)))
     (org-with-remote-undo buffer
       (with-current-buffer buffer
-	(if (org-mode-p)
+	(if (eq major-mode 'org-mode)
 	    (if (and confirm
 		     (not (y-or-n-p "Archive this subtree or entry? ")))
 		(error "Abort")
@@ -7006,7 +7006,7 @@ at the text of the entry itself."
       (and delete-other-windows (delete-other-windows))
       (widen)
       (goto-char pos)
-      (when (org-mode-p)
+      (when (eq major-mode 'org-mode)
 	(org-show-context 'agenda)
 	(save-excursion
 	  (and (outline-next-heading)
diff --git a/lisp/org-archive.el b/lisp/org-archive.el
index 16c35cf..1d68a9e 100644
--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -253,7 +253,7 @@ this heading."
 	(let (this-command) (org-copy-subtree 1 nil t))
 	(set-buffer buffer)
 	;; Enforce org-mode for the archive buffer
-	(if (not (org-mode-p))
+	(if (not (eq major-mode 'org-mode))
 	    ;; Force the mode for future visits.
 	    (let ((org-insert-mode-line-in-empty-file t)
 		  (org-inhibit-startup t))
diff --git a/lisp/org-ascii.el b/lisp/org-ascii.el
index 056f44b..def34ec 100644
--- a/lisp/org-ascii.el
+++ b/lisp/org-ascii.el
@@ -144,7 +144,7 @@ command to convert it."
   (interactive "r")
   (let (reg ascii buf pop-up-frames)
     (save-window-excursion
-      (if (org-mode-p)
+      (if (eq major-mode 'org-mode)
 	  (setq ascii (org-export-region-as-ascii
 		      beg end t 'string))
 	(setq reg (buffer-substring beg end)
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index a7dc92b..e1b8a4f 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -485,7 +485,7 @@ bypassed."
 	     (error "Capture template `%s': %s"
 		    (org-capture-get :key)
 		    (nth 1 error))))
-	  (if (and (org-mode-p)
+	  (if (and (eq major-mode 'org-mode)
 		   (org-capture-get :clock-in))
 	      (condition-case nil
 		  (progn
@@ -575,7 +575,7 @@ captured item after finalizing."
 	  (org-capture-empty-lines-after
 	   (or (org-capture-get :empty-lines 'local) 0))))
       ;; Postprocessing:  Update Statistics cookies, do the sorting
-      (when (org-mode-p)
+      (when (eq major-mode 'org-mode)
 	(save-excursion
 	  (when (ignore-errors (org-back-to-heading))
 	    (org-update-parent-todo-statistics)
@@ -723,7 +723,7 @@ already gone.  Any prefix argument will be passed to the refile command."
 	(widen)
 	(let ((hd (nth 2 target)))
 	  (goto-char (point-min))
-	  (unless (org-mode-p)
+	  (unless (eq major-mode 'org-mode)
 	    (error
 	     "Target buffer \"%s\" for file+headline should be in Org mode"
 	     (current-buffer)))
@@ -755,7 +755,7 @@ already gone.  Any prefix argument will be passed to the refile command."
 	      (goto-char (if (org-capture-get :prepend)
 			     (match-beginning 0) (match-end 0)))
 	      (org-capture-put :exact-position (point))
-	      (setq target-entry-p (and (org-mode-p) (org-at-heading-p))))
+	      (setq target-entry-p (and (eq major-mode 'org-mode) (org-at-heading-p))))
 	  (error "No match for target regexp in file %s" (nth 1 target))))
 
        ((memq (car target) '(file+datetree file+datetree+prompt))
@@ -789,12 +789,12 @@ already gone.  Any prefix argument will be passed to the refile command."
 	(widen)
 	(funcall (nth 2 target))
 	(org-capture-put :exact-position (point))
-	(setq target-entry-p (and (org-mode-p) (org-at-heading-p))))
+	(setq target-entry-p (and (eq major-mode 'org-mode) (org-at-heading-p))))
 
        ((eq (car target) 'function)
 	(funcall (nth 1 target))
 	(org-capture-put :exact-position (point))
-	(setq target-entry-p (and (org-mode-p) (org-at-heading-p))))
+	(setq target-entry-p (and (eq major-mode 'org-mode) (org-at-heading-p))))
 
        ((eq (car target) 'clock)
 	(if (and (markerp org-clock-hd-marker)
@@ -1147,11 +1147,11 @@ Point will remain at the first line after the inserted text."
     (or (bolp) (newline))
     (setq beg (point))
     (cond
-     ((and (eq type 'entry) (org-mode-p))
+     ((and (eq type 'entry) (eq major-mode 'org-mode))
       (org-capture-verify-tree (org-capture-get :template))
       (org-paste-subtree nil template t))
      ((and (memq type '(item checkitem))
-	   (org-mode-p)
+	   (eq major-mode 'org-mode)
 	   (save-excursion (skip-chars-backward " \t\n")
 			   (setq pp (point))
 			   (org-in-item-p)))
diff --git a/lisp/org-colview-xemacs.el b/lisp/org-colview-xemacs.el
index b32e741..3b66925 100644
--- a/lisp/org-colview-xemacs.el
+++ b/lisp/org-colview-xemacs.el
@@ -353,7 +353,7 @@ This is the compiled version of the format.")
 			  (funcall org-columns-modify-value-for-display-function
 				   title val))
 			 ((equal property "ITEM")
-			  (if (org-mode-p)
+			  (if (eq major-mode 'org-mode)
 			      (org-columns-cleanup-item
 			       val org-columns-current-fmt-compiled)))
 			 ((and calc (functionp calc)
@@ -657,7 +657,7 @@ Where possible, use the standard interface for changing this line."
 		(org-columns-eval eval))
 	    (org-columns-display-here)))
 	(org-move-to-column col)
-	(if (and (org-mode-p)
+	(if (and (eq major-mode 'org-mode)
 		 (nth 3 (assoc key org-columns-current-fmt-compiled)))
 	    (org-columns-update key)))))))
 
@@ -1166,7 +1166,7 @@ Don't set this, this is meant for dynamic scoping.")
     (if (marker-position org-columns-begin-marker)
 	(goto-char org-columns-begin-marker))
     (org-columns-remove-overlays)
-    (if (org-mode-p)
+    (if (eq major-mode 'org-mode)
 	(call-interactively 'org-columns)
       (org-agenda-redo)
       (call-interactively 'org-agenda-columns)))
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 829a134..ca1c65e 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -186,7 +186,7 @@ This is the compiled version of the format.")
 		    (cons "ITEM"
 			  ;; When in a buffer, get the whole line,
 			  ;; we'll clean it later…
-			  (if (org-mode-p)
+			  (if (eq major-mode 'org-mode)
 			      (save-match-data
 				(org-no-properties
 				 (org-remove-tabs
@@ -497,7 +497,7 @@ Where possible, use the standard interface for changing this line."
 		(org-columns-eval eval))
 	    (org-columns-display-here)))
 	(org-move-to-column col)
-	(if (and (org-mode-p)
+	(if (and (eq major-mode 'org-mode)
 		 (nth 3 (assoc key org-columns-current-fmt-compiled)))
 	    (org-columns-update key)))))))
 
@@ -1003,7 +1003,7 @@ Don't set this, this is meant for dynamic scoping.")
       (if (marker-position org-columns-begin-marker)
 	  (goto-char org-columns-begin-marker))
       (org-columns-remove-overlays)
-      (if (org-mode-p)
+      (if (eq major-mode 'org-mode)
 	  (call-interactively 'org-columns)
 	(org-agenda-redo)
 	(call-interactively 'org-agenda-columns)))
diff --git a/lisp/org-ctags.el b/lisp/org-ctags.el
index ad219c5..609c094 100644
--- a/lisp/org-ctags.el
+++ b/lisp/org-ctags.el
@@ -306,7 +306,7 @@ The new topic will be titled NAME (or TITLE if supplied)."
 			    activate compile)
   "Before trying to find a tag, save our current position on org mark ring."
   (save-excursion
-    (if (and (org-mode-p) org-ctags-enabled-p)
+    (if (and (eq major-mode 'org-mode) org-ctags-enabled-p)
         (org-mark-ring-push))))
 
 
diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el
index f09740f..13cb039 100644
--- a/lisp/org-docbook.el
+++ b/lisp/org-docbook.el
@@ -293,7 +293,7 @@ then use this command to convert it."
   (interactive "r")
   (let (reg docbook buf)
     (save-window-excursion
-      (if (org-mode-p)
+      (if (eq major-mode 'org-mode)
 	  (setq docbook (org-export-region-as-docbook
 			 beg end t 'string))
 	(setq reg (buffer-substring beg end)
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index 76e7af3..cee0b53 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -353,7 +353,7 @@ Return a non-nil value when a definition has been found."
       (looking-at (format "\\[%s\\]\\|\\[%s:" label label))
       (goto-char (match-end 0))
       (org-show-context 'link-search)
-      (when (org-mode-p)
+      (when (eq major-mode 'org-mode)
 	(message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'."))
       t)))
 
@@ -481,7 +481,7 @@ or new, let the user edit the definition of the footnote."
   (let ((label (org-footnote-normalize-label label)))
     (cond
      ;; In an Org file.
-     ((org-mode-p)
+     ((eq major-mode 'org-mode)
       ;; If `org-footnote-section' is defined, find it, or create it
       ;; at the end of the buffer.
       (when org-footnote-section
@@ -543,7 +543,7 @@ or new, let the user edit the definition of the footnote."
     (insert "\n[" label "] ")
     ;; Only notify user about next possible action when in an Org
     ;; buffer, as the bindings may have different meanings otherwise.
-    (when (org-mode-p)
+    (when (eq major-mode 'org-mode)
       (message
        "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'."))))
 
@@ -701,13 +701,13 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
       (goto-char (point-min))
       (cond
        ((and org-footnote-section
-	     (org-mode-p)
+	     (eq major-mode 'org-mode)
 	     (re-search-forward
 	      (concat "^\\*[ \t]+" (regexp-quote org-footnote-section)
 		      "[ \t]*$")
 	      nil t))
 	(delete-region (match-beginning 0) (org-end-of-subtree t)))
-       ((org-mode-p)
+       ((eq major-mode 'org-mode)
 	(goto-char (point-max))
 	(unless (bolp) (newline)))
        (t
@@ -761,7 +761,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
        ;; No footnote: exit.
        ((not ref-table))
        ;; Cases when footnotes should be inserted in one place.
-       ((or (not (org-mode-p))
+       ((or (not (eq major-mode 'org-mode))
 	    org-footnote-section
 	    (not sort-only))
 	;; Insert again the section title, if any.  Ensure that title,
@@ -770,7 +770,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
 	;; separate section with a blank line, unless explicitly
 	;; stated in `org-blank-before-new-entry'.
 	(cond
-	 ((not (org-mode-p))
+	 ((not (eq major-mode 'org-mode))
 	  (skip-chars-backward " \t\n\r")
 	  (delete-region (point) ins-point)
 	  (unless (bolp) (newline))
diff --git a/lisp/org-html.el b/lisp/org-html.el
index 38df432..f1f1186 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -713,7 +713,7 @@ command to convert it."
   (interactive "r")
   (let (reg html buf pop-up-frames)
     (save-window-excursion
-      (if (org-mode-p)
+      (if (eq major-mode 'org-mode)
 	  (setq html (org-export-region-as-html
 		      beg end t 'string))
 	(setq reg (buffer-substring beg end)
diff --git a/lisp/org-id.el b/lisp/org-id.el
index 1bc8dfd..a00297d 100644
--- a/lisp/org-id.el
+++ b/lisp/org-id.el
@@ -431,7 +431,7 @@ When CHECK is given, prepare detailed information about duplicate IDs."
 		 (delq nil
 		       (mapcar (lambda (b)
 				 (with-current-buffer b
-				   (and (org-mode-p) (buffer-file-name))))
+				   (and (eq major-mode 'org-mode) (buffer-file-name))))
 			       (buffer-list)))
 		 ;; All files known to have IDs
 		 org-id-files)))
@@ -600,7 +600,7 @@ optional argument MARKERP, return the position as a new marker."
 (defun org-id-store-link ()
   "Store a link to the current entry, using its ID."
   (interactive)
-  (when (and (buffer-file-name (buffer-base-buffer)) (org-mode-p))
+  (when (and (buffer-file-name (buffer-base-buffer)) (eq major-mode 'org-mode))
     (let* ((link (org-make-link "id:" (org-id-get-create)))
 	   (case-fold-search nil)
 	   (desc (save-excursion
diff --git a/lisp/org-indent.el b/lisp/org-indent.el
index 0f8c025..034b163 100644
--- a/lisp/org-indent.el
+++ b/lisp/org-indent.el
@@ -222,7 +222,7 @@ during idle time." nil " Ind" nil
 (defun org-indent-indent-buffer ()
   "Add indentation properties to the accessible part of the buffer."
   (interactive)
-  (if (not (org-mode-p))
+  (if (not (eq major-mode 'org-mode))
       (error "Not in Org mode")
     (message "Setting buffer indentation. It may take a few seconds...")
     (org-indent-remove-properties (point-min) (point-max))
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index 63b3cf0..a639129 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -723,7 +723,7 @@ then use this command to convert it."
   (interactive "r")
   (let (reg latex buf)
     (save-window-excursion
-      (if (org-mode-p)
+      (if (eq major-mode 'org-mode)
 	  (setq latex (org-export-region-as-latex
 		       beg end t 'string))
 	(setq reg (buffer-substring beg end)
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 13aff02..521f5fd 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -272,10 +272,6 @@ we turn off invisibility temporarily.  Use this in a `let' form."
   "Make VAR local in current buffer and set it to VALUE."
   (set (make-local-variable var) value))
 
-(defsubst org-mode-p ()
-  "Check if the current buffer is in Org-mode."
-  (eq major-mode 'org-mode))
-
 (defsubst org-last (list)
   "Return the last element of LIST."
   (car (last list)))
@@ -388,7 +384,7 @@ point nowhere."
 (defun org-get-limited-outline-regexp ()
   "Return outline-regexp with limited number of levels.
 The number of levels is controlled by `org-inlinetask-min-level'"
-  (if (or (not (org-mode-p)) (not (featurep 'org-inlinetask)))
+  (if (or (not (eq major-mode 'org-mode)) (not (featurep 'org-inlinetask)))
       org-outline-regexp
     (let* ((limit-level (1- org-inlinetask-min-level))
 	   (nstars (if org-odd-levels-only (1- (* limit-level 2)) limit-level)))
diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el
index 346ba6d..1e615e4 100644
--- a/lisp/org-mouse.el
+++ b/lisp/org-mouse.el
@@ -615,12 +615,12 @@ This means, between the beginning of line and the point."
   (beginning-of-line))
 
 (defadvice dnd-insert-text (around org-mouse-dnd-insert-text activate)
-  (if (org-mode-p)
+  (if (eq major-mode 'org-mode)
       (org-mouse-insert-item text)
     ad-do-it))
 
 (defadvice dnd-open-file (around org-mouse-dnd-open-file activate)
-  (if (org-mode-p)
+  (if (eq major-mode 'org-mode)
       (org-mouse-insert-item uri)
     ad-do-it))
 
diff --git a/lisp/org-remember.el b/lisp/org-remember.el
index 45e0685..4f3190c 100644
--- a/lisp/org-remember.el
+++ b/lisp/org-remember.el
@@ -943,7 +943,7 @@ See also the variable `org-reverse-note-order'."
 	(throw 'quit t))
       ;; Find the file
       (with-current-buffer (or visiting (find-file-noselect file))
-	(unless (or (org-mode-p) (member heading '(top bottom)))
+	(unless (or (eq major-mode 'org-mode) (member heading '(top bottom)))
 	  (error "Target files for notes must be in Org-mode if not filing to top/bottom"))
 	(save-excursion
 	  (save-restriction
@@ -953,7 +953,7 @@ See also the variable `org-reverse-note-order'."
 	    ;; Find the default location
 	    (when heading
 	      (cond
-	       ((not (org-mode-p))
+	       ((not (eq major-mode 'org-mode))
 		(if (eq heading 'top)
 		    (goto-char (point-min))
 		  (goto-char (point-max))
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 0e8b1b1..1bb1e5a 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -215,7 +215,7 @@ buffer."
 	(case-fold-search t)
 	(info (org-edit-src-find-region-and-lang))
 	(full-info (org-babel-get-src-block-info))
-	(org-mode-p (or (org-mode-p) (derived-mode-p 'org-mode)))
+	(org-mode-p (derived-mode-p 'org-mode)) ;; derived-mode-p is reflexive
 	(beg (make-marker))
 	(end (make-marker))
 	(allow-write-back-p (null code))
@@ -306,7 +306,7 @@ buffer."
 	     (error "Language mode `%s' fails with: %S" lang-f (nth 1 e)))))
 	(dolist (pair transmitted-variables)
 	  (org-set-local (car pair) (cadr pair)))
-	(when org-mode-p
+	(when eq major-mode 'org-mode
 	  (goto-char (point-min))
 	  (while (re-search-forward "^," nil t)
 	    (if (eq (org-current-line) line) (setq total-nindent (1+ total-nindent)))
@@ -398,7 +398,7 @@ the fragment in the Org-mode buffer."
 	(case-fold-search t)
 	(msg (substitute-command-keys
 	      "Edit, then exit with C-c ' (C-c and single quote)"))
-	(org-mode-p (org-mode-p))
+	(org-mode-p (eq major-mode 'org-mode))
 	(beg (make-marker))
 	(end (make-marker))
 	(preserve-indentation org-src-preserve-indentation)
@@ -617,7 +617,7 @@ the language, a switch telling if the content should be in a single line."
       (when (org-bound-and-true-p org-edit-src-from-org-mode)
 	(goto-char (point-min))
 	(while (re-search-forward
-		(if (org-mode-p) "^\\(.\\)" "^\\([*]\\|[ \t]*#\\+\\)") nil t)
+		(if (eq major-mode 'org-mode) "^\\(.\\)" "^\\([*]\\|[ \t]*#\\+\\)") nil t)
 	  (if (eq (org-current-line) line) (setq delta (1+ delta)))
 	  (replace-match ",\\1")))
       (when (org-bound-and-true-p org-edit-src-picture)
diff --git a/lisp/org-table.el b/lisp/org-table.el
index c35e770..e85d034 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -821,7 +821,7 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
     (delete-region (point) end)
     (move-marker end nil)
     (move-marker org-table-aligned-end-marker (point))
-    (when (and orgtbl-mode (not (org-mode-p)))
+    (when (and orgtbl-mode (not (eq major-mode 'org-mode)))
       (goto-char org-table-aligned-begin-marker)
       (while (org-hide-wide-columns org-table-aligned-end-marker)))
     ;; Try to move to the old location
@@ -3799,7 +3799,7 @@ Use COMMAND to do the motion, repeat if necessary to end up in a data line."
   :lighter " OrgTbl" :keymap orgtbl-mode-map
   (org-load-modules-maybe)
   (cond
-   ((org-mode-p)
+   ((eq major-mode 'org-mode)
     ;; Exit without error, in case some hook functions calls this
     ;; by accident in org-mode.
     (message "Orgtbl-mode is not useful in org-mode, command ignored"))
diff --git a/lisp/org-timer.el b/lisp/org-timer.el
index c1ad768..ef5dba6 100644
--- a/lisp/org-timer.el
+++ b/lisp/org-timer.el
@@ -372,7 +372,7 @@ replace any running timer."
 		     (org-show-entry)
 		     (or (ignore-errors (org-get-heading))
 			 (concat "File:" (file-name-nondirectory (buffer-file-name)))))))
-		((org-mode-p)
+		((eq major-mode 'org-mode)
 		 (or (ignore-errors (org-get-heading))
 		     (concat "File:" (file-name-nondirectory (buffer-file-name)))))
 		(t (error "Not in an Org buffer"))))
diff --git a/lisp/org.el b/lisp/org.el
index b26e1a3..d6a90de 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4363,7 +4363,7 @@ means to push this value onto the list in the variable.")
 
 (defun org-set-regexps-and-options ()
   "Precompute regular expressions for current buffer."
-  (when (org-mode-p)
+  (when (eq major-mode 'org-mode)
     (org-set-local 'org-todo-kwd-alist nil)
     (org-set-local 'org-todo-key-alist nil)
     (org-set-local 'org-todo-key-trigger nil)
@@ -5980,7 +5980,7 @@ in special contexts.
 			  (and limit-level (1- (* limit-level 2)))
 			limit-level)))
 	   (org-outline-regexp
-	    (if (not (org-mode-p))
+	    (if (not (eq major-mode 'org-mode))
 		outline-regexp
 	      (concat "\\*" (if nstars (format "\\{1,%d\\} " nstars) "+ "))))
 	   (bob-special (and org-cycle-global-at-bob (not arg) (bobp)
@@ -6219,7 +6219,7 @@ With \\[universal-argument] prefix arg, switch to startup visibility.
 With a numeric prefix, show all headlines up to that level."
   (interactive "P")
   (let ((org-cycle-include-plain-lists
-	 (if (org-mode-p) org-cycle-include-plain-lists nil)))
+	 (if (eq major-mode 'org-mode) org-cycle-include-plain-lists nil)))
     (cond
      ((integerp arg)
       (show-all)
@@ -6429,7 +6429,7 @@ open and agenda-wise Org files."
   (let ((files (mapcar 'expand-file-name (org-agenda-files))))
     (dolist (buf (buffer-list))
       (with-current-buffer buf
-	(if (and (org-mode-p) (buffer-file-name))
+	(if (and (eq major-mode 'org-mode) (buffer-file-name))
 	    (let ((file (expand-file-name (buffer-file-name))))
 	      (unless (member file files)
 		(push file files))))))
@@ -6445,7 +6445,7 @@ open and agenda-wise Org files."
 
 (defun org-cycle-hide-drawers (state)
   "Re-hide all drawers after a visibility state change."
-  (when (and (org-mode-p)
+  (when (and (eq major-mode 'org-mode)
 	     (not (memq state '(overview folded contents))))
     (save-excursion
       (let* ((globalp (memq state '(contents all)))
@@ -8590,7 +8590,7 @@ For file links, arg negates `org-context-in-file-links'."
 	 (setq cpltxt (concat "file:" file)
 	       link (org-make-link cpltxt))))
 
-      ((and (buffer-file-name (buffer-base-buffer)) (org-mode-p))
+      ((and (buffer-file-name (buffer-base-buffer)) (eq major-mode 'org-mode))
        (setq custom-id (org-entry-get nil "CUSTOM_ID"))
        (cond
 	((org-in-regexp "<<\\(.*?\\)>>")
@@ -9732,12 +9732,12 @@ in all files.  If AVOID-POS is given, ignore matches near that position."
      ((string-match "^/\\(.*\\)/$" s)
       ;; A regular expression
       (cond
-       ((org-mode-p)
+       ((eq major-mode 'org-mode)
 	(org-occur (match-string 1 s)))
        ;;((eq major-mode 'dired-mode)
        ;; (grep (concat "grep -n -e '" (match-string 1 s) "' *")))
        (t (org-do-occur (match-string 1 s)))))
-     ((and (org-mode-p) org-link-search-must-match-exact-headline)
+     ((and (eq major-mode 'org-mode) org-link-search-must-match-exact-headline)
       (and (equal (string-to-char s) ?*) (setq s (substring s 1)))
       (goto-char (point-min))
       (cond
@@ -9805,7 +9805,7 @@ in all files.  If AVOID-POS is given, ignore matches near that position."
 	      (goto-char (match-beginning 1))
 	    (goto-char pos)
 	    (error "No match"))))))
-    (and (org-mode-p) (org-show-context 'link-search))
+    (and (eq major-mode 'org-mode) (org-show-context 'link-search))
     type))
 
 (defun org-search-not-self (group &rest args)
@@ -10074,7 +10074,7 @@ If the file does not exist, an error is thrown."
 	  (set-match-data link-match-data)
 	  (eval cmd))))
      (t (funcall (cdr (assq 'file org-link-frame-setup)) file)))
-    (and (org-mode-p) (eq old-mode 'org-mode)
+    (and (eq major-mode 'org-mode) (eq old-mode 'org-mode)
 	 (or (not (equal old-buffer (current-buffer)))
 	     (not (equal old-pos (point))))
 	 (org-mark-ring-push old-pos old-buffer))))
@@ -10397,7 +10397,7 @@ such as the file name."
   (interactive "P")
   (let* ((bfn (buffer-file-name (buffer-base-buffer)))
 	 (case-fold-search nil)
-	 (path (and (org-mode-p) (org-get-outline-path))))
+	 (path (and (eq major-mode 'org-mode) (org-get-outline-path))))
     (if current (setq path (append path
 				   (save-excursion
 				     (org-back-to-heading t)
@@ -10858,7 +10858,7 @@ Error if there is no such block at point."
   "Update all dynamic blocks in the buffer.
 This function can be used in a hook."
   (interactive)
-  (when (org-mode-p)
+  (when (eq major-mode 'org-mode)
     (org-map-dblocks 'org-update-dblock)))
 
 
@@ -13244,7 +13244,7 @@ This works in the agenda, and also in an org-mode buffer."
   (interactive
    (list (region-beginning) (region-end)
 	 (let ((org-last-tags-completion-table
-		(if (org-mode-p)
+		(if (eq major-mode 'org-mode)
 		    (org-get-buffer-tags)
 		  (org-global-tags-completion-table))))
 	   (org-icompleting-read
@@ -13263,7 +13263,7 @@ This works in the agenda, and also in an org-mode buffer."
     (loop for l from l1 to l2 do
 	  (org-goto-line l)
 	  (setq m (get-text-property (point) 'org-hd-marker))
-	  (when (or (and (org-mode-p) (org-on-heading-p))
+	  (when (or (and (eq major-mode 'org-mode) (org-on-heading-p))
 		    (and agendap m))
 	    (setq buf (if agendap (marker-buffer m) (current-buffer))
 		  pos (if agendap m (point)))
@@ -13833,7 +13833,7 @@ things up because then unnecessary parsing is avoided."
 	  beg end range props sum-props key key1 value string clocksum)
       (save-excursion
 	(when (condition-case nil
-		  (and (org-mode-p) (org-back-to-heading t))
+		  (and (eq major-mode 'org-mode) (org-back-to-heading t))
 		(error nil))
 	  (setq beg (point))
 	  (setq sum-props (get-text-property (point) 'org-summaries))
@@ -15962,7 +15962,7 @@ Entries containing a colon are interpreted as H:MM by
   "Save all Org-mode buffers without user confirmation."
   (interactive)
   (message "Saving all Org-mode buffers...")
-  (save-some-buffers t 'org-mode-p)
+  (save-some-buffers t (lambda () (eq major-mode 'org-mode)))
   (when (featurep 'org-id) (org-id-locations-save))
   (message "Saving all Org-mode buffers... done"))
 
@@ -15986,7 +15986,7 @@ changes from another.  I believe the procedure must be like this:
     (save-window-excursion
       (mapc
        (lambda (b)
-	 (when (and (with-current-buffer b (org-mode-p))
+	 (when (and (with-current-buffer b (eq major-mode 'org-mode))
 		    (with-current-buffer b buffer-file-name))
 	   (org-pop-to-buffer-same-window b)
 	   (revert-buffer t 'no-confirm)))
@@ -16038,17 +16038,17 @@ If EXCLUDE-TMP is non-nil, ignore temporary buffers."
 	 (filter
 	  (cond
 	   ((eq predicate 'files)
-	    (lambda (b) (with-current-buffer b (org-mode-p))))
+	    (lambda (b) (with-current-buffer b (eq major-mode 'org-mode))))
 	   ((eq predicate 'export)
 	    (lambda (b) (string-match "\*Org .*Export" (buffer-name b))))
 	   ((eq predicate 'agenda)
 	    (lambda (b)
 	      (with-current-buffer b
-		(and (org-mode-p)
+		(and (eq major-mode 'org-mode)
 		     (setq bfn (buffer-file-name b))
 		     (member (file-truename bfn) agenda-files)))))
 	   (t (lambda (b) (with-current-buffer b
-			    (or (org-mode-p)
+			    (or (eq major-mode 'org-mode)
 				(string-match "\*Org .*Export"
 					      (buffer-name b)))))))))
     (delq nil
@@ -16347,7 +16347,7 @@ an embedded LaTeX fragment, let texmathp do its job.
       (interactive)
       (let (p)
 	(cond
-	 ((not (org-mode-p)) ad-do-it)
+	 ((not (eq major-mode 'org-mode)) ad-do-it)
 	 ((eq this-command 'cdlatex-math-symbol)
 	  (setq ad-return-value t
 		texmathp-why '("cdlatex-math-symbol in org-mode" . 0)))
@@ -18670,8 +18670,8 @@ Your bug report will be posted to the Org-mode mailing list.
     (save-excursion
       (while bl
 	(set-buffer (pop bl))
-	(if (org-mode-p) (setq bl nil)))
-      (when (org-mode-p)
+	(if (eq major-mode 'org-mode) (setq bl nil)))
+      (when (eq major-mode 'org-mode)
 	(easy-menu-change
 	 '("Org") "File List for Agenda"
 	 (append
@@ -19257,18 +19257,18 @@ NAMES is a list of strings containing names of blocks."
     ;; Emacs 23
     (add-hook 'occur-mode-find-occurrence-hook
 	      (lambda ()
-		(when (org-mode-p)
+		(when (eq major-mode 'org-mode)
 		  (org-reveal))))
   ;; Emacs 22
   (defadvice occur-mode-goto-occurrence
     (after org-occur-reveal activate)
-    (and (org-mode-p) (org-reveal)))
+    (and (eq major-mode 'org-mode) (org-reveal)))
   (defadvice occur-mode-goto-occurrence-other-window
     (after org-occur-reveal activate)
-    (and (org-mode-p) (org-reveal)))
+    (and (eq major-mode 'org-mode) (org-reveal)))
   (defadvice occur-mode-display-occurrence
     (after org-occur-reveal activate)
-    (when (org-mode-p)
+    (when (eq major-mode 'org-mode)
       (let ((pos (occur-mode-find-occurrence)))
 	(with-current-buffer (marker-buffer pos)
 	  (save-excursion
@@ -20323,7 +20323,7 @@ If there is no such heading, return nil."
   (org-back-to-heading invisible-OK)
   (let ((first t)
 	(level (funcall outline-level)))
-    (if (and (org-mode-p) (< level 1000))
+    (if (and (eq major-mode 'org-mode) (< level 1000))
 	;; A true heading (not a plain list item), in Org-mode
 	;; This means we can easily find the end by looking
 	;; only for the right number of stars.  Using a regexp to do
@@ -20348,7 +20348,7 @@ If there is no such heading, return nil."
 
 (defadvice outline-end-of-subtree (around prefer-org-version activate compile)
   "Use Org version in org-mode, for dramatic speed-up."
-  (if (org-mode-p)
+  (if (eq major-mode 'org-mode)
       (progn
 	(org-end-of-subtree nil t)
 	(unless (eobp) (backward-char 1)))
@@ -20520,7 +20520,7 @@ Show the heading too, if it is currently invisible."
   '(progn
      (add-hook 'imenu-after-jump-hook
 	       (lambda ()
-		 (if (org-mode-p)
+		 (if (eq major-mode 'org-mode)
 		     (org-show-context 'org-goto))))))
 
 (defun org-link-display-format (link)
@@ -20581,7 +20581,7 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
       (with-current-buffer (find-file-noselect
 			    (let ((default-directory dir))
 			      (expand-file-name txt)))
-	(unless (org-mode-p)
+	(unless (eq major-mode 'org-mode)
 	  (error "Cannot restrict to non-Org-mode file"))
 	(org-agenda-set-restriction-lock 'file)))
      (t (error "Don't know how to restrict Org-mode's agenda")))
@@ -20598,7 +20598,7 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
      (define-key speedbar-file-key-map ">" 'org-agenda-remove-restriction-lock)
      (define-key speedbar-file-key-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
      (add-hook 'speedbar-visiting-tag-hook
-	       (lambda () (and (org-mode-p) (org-show-context 'org-goto))))))
+	       (lambda () (and (eq major-mode 'org-mode) (org-show-context 'org-goto))))))
 
 ;;; Fixes and Hacks for problems with other packages
 
@@ -20641,12 +20641,12 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
 (eval-after-load "ecb"
   '(defadvice ecb-method-clicked (after esf/org-show-context activate)
      "Make hierarchy visible when jumping into location from ECB tree buffer."
-     (if (org-mode-p)
+     (if (eq major-mode 'org-mode)
 	 (org-show-context))))
 
 (defun org-bookmark-jump-unhide ()
   "Unhide the current position, to show the bookmark location."
-  (and (org-mode-p)
+  (and (eq major-mode 'org-mode)
        (or (outline-invisible-p)
 	   (save-excursion (goto-char (max (point-min) (1- (point))))
 			   (outline-invisible-p)))
diff --git a/testing/org-test.el b/testing/org-test.el
index a2285a0..57b7252 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -151,7 +151,7 @@ currently executed.")
      (save-window-excursion
        (save-match-data
 	 (find-file my-file)
-	 (unless (org-mode-p)
+	 (unless (eq major-mode 'org-mode)
 	   (org-mode))
 	 (setq to-be-removed (current-buffer))
 	 (goto-char (point-min))
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH]: New Add defun org-mode-or-derived-mode-p
  2011-10-11  7:18         ` Tassilo Horn
@ 2011-10-22  9:31           ` Bastien
  2011-11-03 21:35             ` Cassio Koshikumo
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2011-10-22  9:31 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-orgmode, Carsten Dominik

Hi Tassilo,

Tassilo Horn <tassilo@member.fsf.org> writes:

> 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. :-)

I applied this patch -- thanks for it.

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 
defsubst is available for that.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH]: New Add defun org-mode-or-derived-mode-p
  2011-10-22  9:31           ` Bastien
@ 2011-11-03 21:35             ` Cassio Koshikumo
  2011-11-06 15:11               ` David Maus
  0 siblings, 1 reply; 9+ messages in thread
From: Cassio Koshikumo @ 2011-11-03 21:35 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-orgmode, Carsten Dominik

Hi, all,

On the last few days I've been working on a major mode derived from org-mode.
While I was at it, I've encoutered some difficulties related to those reported
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 planning 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 lot 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,

-- 
Cássio Koshikumo


At Sat, 22 Oct 2011 11:31:21 +0200,
Bastien wrote:
> 
> Hi Tassilo,
> 
> Tassilo Horn <tassilo@member.fsf.org> writes:
> 
> > 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. :-)
> 
> I applied this patch -- thanks for it.
> 
> 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 
> defsubst is available for that.
> 
> -- 
>  Bastien
> 
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH]: New Add defun org-mode-or-derived-mode-p
  2011-11-03 21:35             ` Cassio Koshikumo
@ 2011-11-06 15:11               ` David Maus
  0 siblings, 0 replies; 9+ messages in thread
From: David Maus @ 2011-11-06 15:11 UTC (permalink / raw)
  To: Cassio Koshikumo; +Cc: Tassilo Horn, emacs-orgmode, Carsten Dominik

[-- Attachment #1: Type: text/plain, Size: 991 bytes --]

At Thu, 03 Nov 2011 19:35:01 -0200,
Cassio Koshikumo wrote:
>
> Hi, all,
>
> On the last few days I've been working on a major mode derived from org-mode.
> While I was at it, I've encoutered some difficulties related to those reported
> 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.
>
> ...
>
> 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?

Please see Carsten's post about the issue:

http://article.gmane.org/gmane.emacs.orgmode/47508

If you could provide a list of the functions that need to run in the
derived mode or a patch which changes these functions we could put in
the `derived-mode-p' selectively.

Best,
 -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #2: Type: application/pgp-signature, Size: 230 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-11-06 15:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-02 11:09 [PATCH]: New Add defun org-mode-or-derived-mode-p Stefan Reichör
2011-09-02 14:59 ` Tassilo Horn
2011-09-05  6:50   ` Stefan Reichör
2011-09-05  7:36     ` Tassilo Horn
2011-10-06  8:20       ` Carsten Dominik
2011-10-11  7:18         ` Tassilo Horn
2011-10-22  9:31           ` Bastien
2011-11-03 21:35             ` Cassio Koshikumo
2011-11-06 15:11               ` David Maus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).