emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Replace all calls to (eq major-mode 'org-mode) with (derived-mode-p 'org-mode)
@ 2012-02-06 20:49 Cássio Koshikumo
  2012-04-23 13:14 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Cássio Koshikumo @ 2012-02-06 20:49 UTC (permalink / raw)
  To: emacs-orgmode

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


Hello all,

A while ago I asked about changing the Major Mode checking that happens
throughout Org, so that derived modes would function properly.  I finally had
the time to make a patch.

I just replaced every (eq major-mode 'org-mode) with (derived-mode-p 'org-mode).
All files and buffers that used to pass the test will still pass it, and the
ones that have Major Modes derived from Org now will pass it too.  I hope the
format of the patch is OK (it's my first, actually), and that the change makes
sense.

Regards,

-- 
Cássio Koshikumo


[-- Attachment #2: 0001-Replace-all-calls-to-eq-major-mode-org-mode-with-der.patch --]
[-- Type: text/plain, Size: 37532 bytes --]

From e19dd8a10d9113a803db62d83790020eb2217679 Mon Sep 17 00:00:00 2001
From: Cassio Koshikumo <ckoshikumo@gmail.com>
Date: Mon, 6 Feb 2012 15:44:46 -0200
Subject: [PATCH] Replace all calls to (eq major-mode 'org-mode) with
 (derived-mode-p 'org-mode)

* lisp/org-agenda.el
* lisp/org-archive.el
* lisp/org-ascii.el
* lisp/org-capture.el
* lisp/org-colview-xemacs.el
* lisp/org-colview.el
* lisp/org-ctags.el
* lisp/org-docbook.el
* lisp/org-footnote.el
* lisp/org-html.el
* lisp/org-id.el
* lisp/org-indent.el
* lisp/org-latex.el
* lisp/org-lparse.el
* lisp/org-macs.el
* lisp/org-mouse.el
* lisp/org-remember.el
* lisp/org-src.el
* lisp/org-table.el
* lisp/org-timer.el
* lisp/org.el

This change allows Major Modes derived from Org-Mode to perform correctly.
Several functions throughout Org would check the current Major Mode, and refuse
to work if the result was not 'org-mode.  Since derived modes would necessarily
fail this test, a whole lot of functionality did not work properly.  The new
test corrects this and should not affect Org itself, since the result will be
the same as the old test.

TINYCHANGE
---
 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-lparse.el         |    2 +-
 lisp/org-macs.el           |    2 +-
 lisp/org-mouse.el          |    4 +-
 lisp/org-remember.el       |    4 +-
 lisp/org-src.el            |    6 ++--
 lisp/org-table.el          |    4 +-
 lisp/org-timer.el          |    2 +-
 lisp/org.el                |   70 ++++++++++++++++++++++----------------------
 21 files changed, 90 insertions(+), 90 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 38fd589..a6da4e1 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2339,7 +2339,7 @@ Pressing `<' twice means to restrict to the current subtree or region
 			       nil 'face 'org-warning)))))))
 	 t t))
        ((equal keys "L")
-	(unless (eq major-mode 'org-mode)
+	(unless (derived-mode-p 'org-mode)
 	  (error "This is not an Org-mode file"))
 	(unless restriction
 	  (put 'org-agenda-files 'org-restrict (list bfn))
@@ -2374,7 +2374,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 (eq major-mode 'org-mode)))
+	   (restrict-ok (and bfn (derived-mode-p 'org-mode)))
 	   (region-p (org-region-active-p))
 	   (custom org-agenda-custom-commands)
 	   (selstring "")
@@ -2914,7 +2914,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 (eq major-mode 'org-mode))
+	(if (not (derived-mode-p 'org-mode))
 	    (setq txt "")
 	  (save-excursion
 	    (save-restriction
@@ -3030,7 +3030,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 (eq major-mode 'org-mode)
+  (or (derived-mode-p 'org-mode)
       (error "Cannot execute org-mode agenda command on buffer in %s"
 	     major-mode)))
 
@@ -3932,7 +3932,7 @@ in `org-agenda-text-search-extra-files'."
 				    file))))
 	(with-current-buffer buffer
 	  (with-syntax-table (org-search-syntax-table)
-	    (unless (eq major-mode 'org-mode)
+	    (unless (derived-mode-p 'org-mode)
 	      (error "Agenda file %s is not in `org-mode'" file))
 	    (let ((case-fold-search t))
 	      (save-excursion
@@ -4125,7 +4125,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 (eq major-mode 'org-mode)
+	    (unless (derived-mode-p 'org-mode)
 	      (error "Agenda file %s is not in `org-mode'" file))
 	    (save-excursion
 	      (save-restriction
@@ -4569,7 +4569,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 (eq major-mode 'org-mode)
+	(unless (derived-mode-p 'org-mode)
 	  (error "Agenda file %s is not in `org-mode'" file))
 	(let ((case-fold-search nil))
 	  (save-excursion
@@ -5538,7 +5538,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 (eq major-mode 'org-mode) buffer-file-name
+      (and (derived-mode-p '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
@@ -5586,7 +5586,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 (eq major-mode 'org-mode)
+      (when (derived-mode-p 'org-mode)
 	(setq effort
 	      (condition-case nil
 		  (org-get-effort
@@ -6929,7 +6929,7 @@ and by additional input from the age of a schedules or deadline entry."
     (widen)
     (push-mark)
     (goto-char pos)
-    (when (eq major-mode 'org-mode)
+    (when (derived-mode-p 'org-mode)
       (org-show-context 'agenda)
       (save-excursion
 	(and (outline-next-heading)
@@ -6958,7 +6958,7 @@ Point is in the buffer where the item originated.")
      (with-current-buffer buffer
        (save-excursion
 	 (goto-char pos)
-	 (if (and (eq major-mode 'org-mode) (not (member type '("sexp"))))
+	 (if (and (derived-mode-p '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)
@@ -7010,7 +7010,7 @@ Point is in the buffer where the item originated.")
 	 (pos (marker-position marker)))
     (org-with-remote-undo buffer
       (with-current-buffer buffer
-	(if (eq major-mode 'org-mode)
+	(if (derived-mode-p 'org-mode)
 	    (if (and confirm
 		     (not (y-or-n-p "Archive this subtree or entry? ")))
 		(error "Abort")
@@ -7115,7 +7115,7 @@ at the text of the entry itself."
       (and delete-other-windows (delete-other-windows))
       (widen)
       (goto-char pos)
-      (when (eq major-mode 'org-mode)
+      (when (derived-mode-p '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 4137e2c..b142f58 100644
--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -261,7 +261,7 @@ this heading."
 	  (let (this-command) (org-copy-subtree 1 nil t))
 	  (set-buffer buffer)
 	  ;; Enforce org-mode for the archive buffer
-	  (if (not (eq major-mode 'org-mode))
+	  (if (not (derived-mode-p '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 90f39fd..26907ef 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 (eq major-mode 'org-mode)
+      (if (derived-mode-p '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 01ec85d..6944960 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -486,7 +486,7 @@ bypassed."
 	     (error "Capture template `%s': %s"
 		    (org-capture-get :key)
 		    (nth 1 error))))
-	  (if (and (eq major-mode 'org-mode)
+	  (if (and (derived-mode-p 'org-mode)
 		   (org-capture-get :clock-in))
 	      (condition-case nil
 		  (progn
@@ -576,7 +576,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 (eq major-mode 'org-mode)
+      (when (derived-mode-p 'org-mode)
 	(save-excursion
 	  (when (ignore-errors (org-back-to-heading))
 	    (org-update-parent-todo-statistics)
@@ -724,7 +724,7 @@ already gone.  Any prefix argument will be passed to the refile command."
 	(widen)
 	(let ((hd (nth 2 target)))
 	  (goto-char (point-min))
-	  (unless (eq major-mode 'org-mode)
+	  (unless (derived-mode-p 'org-mode)
 	    (error
 	     "Target buffer \"%s\" for file+headline should be in Org mode"
 	     (current-buffer)))
@@ -756,7 +756,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 (eq major-mode 'org-mode) (org-at-heading-p))))
+	      (setq target-entry-p (and (derived-mode-p '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))
@@ -791,12 +791,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 (eq major-mode 'org-mode) (org-at-heading-p))))
+	(setq target-entry-p (and (derived-mode-p '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 (eq major-mode 'org-mode) (org-at-heading-p))))
+	(setq target-entry-p (and (derived-mode-p 'org-mode) (org-at-heading-p))))
 
        ((eq (car target) 'clock)
 	(if (and (markerp org-clock-hd-marker)
@@ -1150,11 +1150,11 @@ Point will remain at the first line after the inserted text."
     (or (bolp) (newline))
     (setq beg (point))
     (cond
-     ((and (eq type 'entry) (eq major-mode 'org-mode))
+     ((and (eq type 'entry) (derived-mode-p 'org-mode))
       (org-capture-verify-tree (org-capture-get :template))
       (org-paste-subtree nil template t))
      ((and (memq type '(item checkitem))
-	   (eq major-mode 'org-mode)
+	   (derived-mode-p '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 ec892fe..9b9bac3 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 (eq major-mode 'org-mode)
+			  (if (derived-mode-p '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 (eq major-mode 'org-mode)
+	(if (and (derived-mode-p '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 (eq major-mode 'org-mode)
+    (if (derived-mode-p '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 04d2b62..687af2f 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 (eq major-mode 'org-mode)
+			  (if (derived-mode-p '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 (eq major-mode 'org-mode)
+	(if (and (derived-mode-p '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 (eq major-mode 'org-mode)
+      (if (derived-mode-p '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 ea94d41..f9f8caa 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 (eq major-mode 'org-mode) org-ctags-enabled-p)
+    (if (and (derived-mode-p 'org-mode) org-ctags-enabled-p)
         (org-mark-ring-push))))
 
 
diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el
index 499ab5d..9fc1c27 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 (eq major-mode 'org-mode)
+      (if (derived-mode-p '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 376ee91..77320fd 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -361,7 +361,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 (eq major-mode 'org-mode)
+      (when (derived-mode-p 'org-mode)
 	(message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'."))
       t)))
 
@@ -488,7 +488,7 @@ or new, let the user edit the definition of the footnote."
   (let ((label (org-footnote-normalize-label label)))
     (cond
      ;; In an Org file.
-     ((eq major-mode 'org-mode)
+     ((derived-mode-p 'org-mode)
       ;; If `org-footnote-section' is defined, find it, or create it
       ;; at the end of the buffer.
       (when org-footnote-section
@@ -552,7 +552,7 @@ or new, let the user edit the definition of the footnote."
     (backward-char)
     ;; Only notify user about next possible action when in an Org
     ;; buffer, as the bindings may have different meanings otherwise.
-    (when (eq major-mode 'org-mode)
+    (when (derived-mode-p 'org-mode)
       (message
        "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'."))))
 
@@ -710,7 +710,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
       ;; 2. Find and remove the footnote section, if any.  Also
       ;;    determine where footnotes shall be inserted (INS-POINT).
       (cond
-       ((and org-footnote-section (eq major-mode 'org-mode))
+       ((and org-footnote-section (derived-mode-p 'org-mode))
 	(goto-char (point-min))
 	(if (re-search-forward
 	      (concat "^\\*[ \t]+" (regexp-quote org-footnote-section)
@@ -724,7 +724,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
 	(unless (bolp) (newline)))
        ;; No footnote section set: Footnotes will be added before next
        ;; headline.
-       ((eq major-mode 'org-mode)
+       ((derived-mode-p 'org-mode)
 	(org-with-limited-levels (outline-next-heading)))
        (t
 	;; Remove any left-over tag in the buffer, if one is set up.
@@ -778,7 +778,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 (eq major-mode 'org-mode))
+       ((or (not (derived-mode-p 'org-mode))
 	    org-footnote-section
 	    export-props)
 	;; Insert again the section title, if any.  Ensure that title,
@@ -787,7 +787,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 (eq major-mode 'org-mode))
+	 ((not (derived-mode-p '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 73e63c4..a18b7b7 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -721,7 +721,7 @@ command to convert it."
   (interactive "r")
   (let (reg html buf pop-up-frames)
     (save-window-excursion
-      (if (eq major-mode 'org-mode)
+      (if (derived-mode-p '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 55e826f..95c8baf 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 (eq major-mode 'org-mode) (buffer-file-name))))
+				   (and (derived-mode-p '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)) (eq major-mode 'org-mode))
+  (when (and (buffer-file-name (buffer-base-buffer)) (derived-mode-p '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 056c22b..43de325 100644
--- a/lisp/org-indent.el
+++ b/lisp/org-indent.el
@@ -223,7 +223,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 (eq major-mode 'org-mode))
+  (if (not (derived-mode-p '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 ba7f8fd..e0491e9 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 (eq major-mode 'org-mode)
+      (if (derived-mode-p 'org-mode)
 	  (setq latex (org-export-region-as-latex
 		       beg end t 'string))
 	(setq reg (buffer-substring beg end)
diff --git a/lisp/org-lparse.el b/lisp/org-lparse.el
index 51fcc05..0f2e05f 100644
--- a/lisp/org-lparse.el
+++ b/lisp/org-lparse.el
@@ -101,7 +101,7 @@ itemized list in org-mode syntax in an HTML buffer and then use
 this command to convert it."
   (let (reg backend-string buf pop-up-frames)
     (save-window-excursion
-      (if (eq major-mode 'org-mode)
+      (if (derived-mode-p '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/lisp/org-macs.el b/lisp/org-macs.el
index daeea71..481558f 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -384,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 (eq major-mode 'org-mode)) (not (featurep 'org-inlinetask)))
+  (if (or (not (derived-mode-p '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 b1d9f22..50fb594 100644
--- a/lisp/org-mouse.el
+++ b/lisp/org-mouse.el
@@ -597,12 +597,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 (eq major-mode 'org-mode)
+  (if (derived-mode-p 'org-mode)
       (org-mouse-insert-item text)
     ad-do-it))
 
 (defadvice dnd-open-file (around org-mouse-dnd-open-file activate)
-  (if (eq major-mode 'org-mode)
+  (if (derived-mode-p 'org-mode)
       (org-mouse-insert-item uri)
     ad-do-it))
 
diff --git a/lisp/org-remember.el b/lisp/org-remember.el
index 65e92ba..46e3460 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 (eq major-mode 'org-mode) (member heading '(top bottom)))
+	(unless (or (derived-mode-p '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 (eq major-mode 'org-mode))
+	       ((not (derived-mode-p '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 fc2e4ef..5d7d084 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -307,7 +307,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 (eq major-mode 'org-mode)
+	(when (derived-mode-p 'org-mode)
 	  (goto-char (point-min))
 	  (while (re-search-forward "^," nil t)
 	    (if (eq (org-current-line) line) (setq total-nindent (1+ total-nindent)))
@@ -400,7 +400,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 (eq major-mode 'org-mode))
+	(org-mode-p (derived-mode-p 'org-mode))
 	(beg (make-marker))
 	(end (make-marker))
 	(preserve-indentation org-src-preserve-indentation)
@@ -619,7 +619,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 (eq major-mode 'org-mode) "^\\(.\\)" "^\\([*]\\|[ \t]*#\\+\\)") nil t)
+		(if (derived-mode-p '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 2a84a31..5113c52 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -829,7 +829,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 (eq major-mode 'org-mode)))
+    (when (and orgtbl-mode (not (derived-mode-p '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
@@ -3840,7 +3840,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
-   ((eq major-mode 'org-mode)
+   ((derived-mode-p '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 44a53ad..1b0778a 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)))))))
-		((eq major-mode 'org-mode)
+		((derived-mode-p '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 4d3d804..ba5a106 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4476,7 +4476,7 @@ but the stars and the body are.")
 
 (defun org-set-regexps-and-options ()
   "Precompute regular expressions for current buffer."
-  (when (eq major-mode 'org-mode)
+  (when (derived-mode-p '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)
@@ -6106,7 +6106,7 @@ in special contexts.
 			  (and limit-level (1- (* limit-level 2)))
 			limit-level)))
 	   (org-outline-regexp
-	    (if (not (eq major-mode 'org-mode))
+	    (if (not (derived-mode-p 'org-mode))
 		outline-regexp
 	      (concat "\\*" (if nstars (format "\\{1,%d\\} " nstars) "+ "))))
 	   (bob-special (and org-cycle-global-at-bob (not arg) (bobp)
@@ -6349,7 +6349,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 (eq major-mode 'org-mode) org-cycle-include-plain-lists nil)))
+	 (if (derived-mode-p 'org-mode) org-cycle-include-plain-lists nil)))
     (cond
      ((integerp arg)
       (show-all)
@@ -6559,7 +6559,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 (eq major-mode 'org-mode) (buffer-file-name))
+	(if (and (derived-mode-p 'org-mode) (buffer-file-name))
 	    (let ((file (expand-file-name (buffer-file-name))))
 	      (unless (member file files)
 		(push file files))))))
@@ -6575,7 +6575,7 @@ open and agenda-wise Org files."
 
 (defun org-cycle-hide-drawers (state)
   "Re-hide all drawers after a visibility state change."
-  (when (and (eq major-mode 'org-mode)
+  (when (and (derived-mode-p 'org-mode)
 	     (not (memq state '(overview folded contents))))
     (save-excursion
       (let* ((globalp (memq state '(contents all)))
@@ -8709,7 +8709,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)) (eq major-mode 'org-mode))
+      ((and (buffer-file-name (buffer-base-buffer)) (derived-mode-p 'org-mode))
        (setq custom-id (org-entry-get nil "CUSTOM_ID"))
        (cond
 	((org-in-regexp "<<\\(.*?\\)>>")
@@ -9865,12 +9865,12 @@ visibility around point, thus ignoring
      ((string-match "^/\\(.*\\)/$" s)
       ;; A regular expression
       (cond
-       ((eq major-mode 'org-mode)
+       ((derived-mode-p '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 (eq major-mode 'org-mode) org-link-search-must-match-exact-headline)
+     ((and (derived-mode-p '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
@@ -9938,7 +9938,7 @@ visibility around point, thus ignoring
 	      (goto-char (match-beginning 1))
 	    (goto-char pos)
 	    (error "No match"))))))
-    (and (eq major-mode 'org-mode)
+    (and (derived-mode-p 'org-mode)
 	 (not stealth)
 	 (org-show-context 'link-search))
     type))
@@ -10209,7 +10209,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 (eq major-mode 'org-mode) (eq old-mode 'org-mode)
+    (and (derived-mode-p '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))))
@@ -10533,7 +10533,7 @@ such as the file name."
   (interactive "P")
   (let* ((bfn (buffer-file-name (buffer-base-buffer)))
 	 (case-fold-search nil)
-	 (path (and (eq major-mode 'org-mode) (org-get-outline-path))))
+	 (path (and (derived-mode-p 'org-mode) (org-get-outline-path))))
     (if current (setq path (append path
 				   (save-excursion
 				     (org-back-to-heading t)
@@ -10720,7 +10720,7 @@ this is used for the GOTO interface."
   (let ((org-refile-targets org-refile-targets)
 	(org-refile-use-outline-path org-refile-use-outline-path)
 	excluded-entries)
-    (when (and (eq major-mode 'org-mode)
+    (when (and (derived-mode-p 'org-mode)
 	       (not org-refile-use-cache)
 	       (not no-exclude))
       (org-map-tree
@@ -11000,7 +11000,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 (eq major-mode 'org-mode)
+  (when (derived-mode-p 'org-mode)
     (org-map-dblocks 'org-update-dblock)))
 
 
@@ -13426,7 +13426,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 (eq major-mode 'org-mode)
+		(if (derived-mode-p 'org-mode)
 		    (org-get-buffer-tags)
 		  (org-global-tags-completion-table))))
 	   (org-icompleting-read
@@ -13445,7 +13445,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 (eq major-mode 'org-mode) (org-at-heading-p))
+	  (when (or (and (derived-mode-p 'org-mode) (org-at-heading-p))
 		    (and agendap m))
 	    (setq buf (if agendap (marker-buffer m) (current-buffer))
 		  pos (if agendap m (point)))
@@ -14033,7 +14033,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 (eq major-mode 'org-mode) (org-back-to-heading t))
+		  (and (derived-mode-p 'org-mode) (org-back-to-heading t))
 		(error nil))
 	  (setq beg (point))
 	  (setq sum-props (get-text-property (point) 'org-summaries))
@@ -16257,7 +16257,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 (lambda () (eq major-mode 'org-mode)))
+  (save-some-buffers t (lambda () (derived-mode-p 'org-mode)))
   (when (featurep 'org-id) (org-id-locations-save))
   (message "Saving all Org-mode buffers... done"))
 
@@ -16281,7 +16281,7 @@ changes from another.  I believe the procedure must be like this:
     (save-window-excursion
       (mapc
        (lambda (b)
-	 (when (and (with-current-buffer b (eq major-mode 'org-mode))
+	 (when (and (with-current-buffer b (derived-mode-p 'org-mode))
 		    (with-current-buffer b buffer-file-name))
 	   (org-pop-to-buffer-same-window b)
 	   (revert-buffer t 'no-confirm)))
@@ -16333,17 +16333,17 @@ If EXCLUDE-TMP is non-nil, ignore temporary buffers."
 	 (filter
 	  (cond
 	   ((eq predicate 'files)
-	    (lambda (b) (with-current-buffer b (eq major-mode 'org-mode))))
+	    (lambda (b) (with-current-buffer b (derived-mode-p 'org-mode))))
 	   ((eq predicate 'export)
 	    (lambda (b) (string-match "\*Org .*Export" (buffer-name b))))
 	   ((eq predicate 'agenda)
 	    (lambda (b)
 	      (with-current-buffer b
-		(and (eq major-mode 'org-mode)
+		(and (derived-mode-p 'org-mode)
 		     (setq bfn (buffer-file-name b))
 		     (member (file-truename bfn) agenda-files)))))
 	   (t (lambda (b) (with-current-buffer b
-			    (or (eq major-mode 'org-mode)
+			    (or (derived-mode-p 'org-mode)
 				(string-match "\*Org .*Export"
 					      (buffer-name b)))))))))
     (delq nil
@@ -16646,7 +16646,7 @@ an embedded LaTeX fragment, let texmathp do its job.
       (interactive)
       (let (p)
 	(cond
-	 ((not (eq major-mode 'org-mode)) ad-do-it)
+	 ((not (derived-mode-p '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)))
@@ -19204,8 +19204,8 @@ Your bug report will be posted to the Org-mode mailing list.
     (save-excursion
       (while bl
 	(set-buffer (pop bl))
-	(if (eq major-mode 'org-mode) (setq bl nil)))
-      (when (eq major-mode 'org-mode)
+	(if (derived-mode-p 'org-mode) (setq bl nil)))
+      (when (derived-mode-p 'org-mode)
 	(easy-menu-change
 	 '("Org") "File List for Agenda"
 	 (append
@@ -19823,18 +19823,18 @@ block from point."
     ;; Emacs 23
     (add-hook 'occur-mode-find-occurrence-hook
 	      (lambda ()
-		(when (eq major-mode 'org-mode)
+		(when (derived-mode-p 'org-mode)
 		  (org-reveal))))
   ;; Emacs 22
   (defadvice occur-mode-goto-occurrence
     (after org-occur-reveal activate)
-    (and (eq major-mode 'org-mode) (org-reveal)))
+    (and (derived-mode-p 'org-mode) (org-reveal)))
   (defadvice occur-mode-goto-occurrence-other-window
     (after org-occur-reveal activate)
-    (and (eq major-mode 'org-mode) (org-reveal)))
+    (and (derived-mode-p 'org-mode) (org-reveal)))
   (defadvice occur-mode-display-occurrence
     (after org-occur-reveal activate)
-    (when (eq major-mode 'org-mode)
+    (when (derived-mode-p 'org-mode)
       (let ((pos (occur-mode-find-occurrence)))
 	(with-current-buffer (marker-buffer pos)
 	  (save-excursion
@@ -20990,7 +20990,7 @@ If there is no such heading, return nil."
   (org-back-to-heading invisible-OK)
   (let ((first t)
 	(level (funcall outline-level)))
-    (if (and (eq major-mode 'org-mode) (< level 1000))
+    (if (and (derived-mode-p '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
@@ -21015,7 +21015,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 (eq major-mode 'org-mode)
+  (if (derived-mode-p 'org-mode)
       (progn
 	(org-end-of-subtree nil t)
 	(unless (eobp) (backward-char 1)))
@@ -21187,7 +21187,7 @@ Show the heading too, if it is currently invisible."
   '(progn
      (add-hook 'imenu-after-jump-hook
 	       (lambda ()
-		 (if (eq major-mode 'org-mode)
+		 (if (derived-mode-p 'org-mode)
 		     (org-show-context 'org-goto))))))
 
 (defun org-link-display-format (link)
@@ -21248,7 +21248,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 (eq major-mode 'org-mode)
+	(unless (derived-mode-p '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")))
@@ -21265,7 +21265,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 (eq major-mode 'org-mode) (org-show-context 'org-goto))))))
+	       (lambda () (and (derived-mode-p 'org-mode) (org-show-context 'org-goto))))))
 
 ;;; Fixes and Hacks for problems with other packages
 
@@ -21308,12 +21308,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 (eq major-mode 'org-mode)
+     (if (derived-mode-p 'org-mode)
 	 (org-show-context))))
 
 (defun org-bookmark-jump-unhide ()
   "Unhide the current position, to show the bookmark location."
-  (and (eq major-mode 'org-mode)
+  (and (derived-mode-p 'org-mode)
        (or (outline-invisible-p)
 	   (save-excursion (goto-char (max (point-min) (1- (point))))
 			   (outline-invisible-p)))
-- 
1.7.9


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

* Re: [PATCH] Replace all calls to (eq major-mode 'org-mode) with (derived-mode-p 'org-mode)
  2012-02-06 20:49 [PATCH] Replace all calls to (eq major-mode 'org-mode) with (derived-mode-p 'org-mode) Cássio Koshikumo
@ 2012-04-23 13:14 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2012-04-23 13:14 UTC (permalink / raw)
  To: Cássio Koshikumo; +Cc: emacs-orgmode

Hi Cássio,

Cássio Koshikumo <ckoshikumo@gmail.com> writes:

> A while ago I asked about changing the Major Mode checking that happens
> throughout Org, so that derived modes would function properly.  I finally had
> the time to make a patch.

I applied an updated version of this patch.

Thanks,

-- 
 Bastien

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

end of thread, other threads:[~2012-04-23 13:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-06 20:49 [PATCH] Replace all calls to (eq major-mode 'org-mode) with (derived-mode-p 'org-mode) Cássio Koshikumo
2012-04-23 13:14 ` Bastien

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