From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tassilo Horn Subject: Re: [PATCH]: New Add defun org-mode-or-derived-mode-p Date: Tue, 11 Oct 2011 09:18:09 +0200 Message-ID: <87fwj0gfny.fsf@thinkpad.tsdh.de> References: <871uvz56th.fsf@thinkpad.tsdh.de> <87wrdnigpd.fsf@thinkpad.tsdh.de> <61054BA2-E0B8-40B9-B62E-FB0EB04E99CF@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:57630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDWbT-0001hK-GB for emacs-orgmode@gnu.org; Tue, 11 Oct 2011 03:18:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RDWbP-0002IV-96 for emacs-orgmode@gnu.org; Tue, 11 Oct 2011 03:18:19 -0400 Received: from deliver.uni-koblenz.de ([141.26.64.15]:51378) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDWbO-0002I6-Kg for emacs-orgmode@gnu.org; Tue, 11 Oct 2011 03:18:15 -0400 In-Reply-To: <61054BA2-E0B8-40B9-B62E-FB0EB04E99CF@gmail.com> (Carsten Dominik's message of "Thu, 6 Oct 2011 10:20:23 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Carsten Dominik Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Carsten Dominik 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 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-Replace-org-mode-p-with-usual-eq-major-mode-org-mode.patch Content-Transfer-Encoding: quoted-printable >From 92e83b95aead15a4346e671de6ba211c6ca95a43 Mon Sep 17 00:00:00 2001 From: Tassilo Horn 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 s= ubtree 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-separ= ator'." "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 `plan= ning' 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 `plan= ning' is allowed here." =20 (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))) =20 @@ -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 en= tries." (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 o= r 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 th= e 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 th= e 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)))) =20 ((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)))) =20 ((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)))) =20 ((eq (car target) 'clock) (if (and (markerp org-clock-hd-marker) @@ -1147,11 +1147,11 @@ Point will remain at the first line after the inser= ted 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))))))) =20 @@ -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=E2=80=A6 - (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))))))) =20 @@ -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)))) =20 =20 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))) =20 @@ -481,7 +481,7 @@ or new, let the user edit the definition of the footnot= e." (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 footnot= e." (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'.")))) =20 @@ -701,13 +701,13 @@ Additional note on `org-footnote-insert-pos-for-prepr= ocessor': (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-preproc= essor': ;; 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-preproc= essor': ;; 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-m= ode)) (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)) =20 -(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 poi= nt." (beginning-of-line)) =20 (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)) =20 (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)) =20 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-ninden= t))) @@ -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 variabl= e.") =20 (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 sta= rtup 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." =20 (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-link= s'." (setq cpltxt (concat "file:" file) link (org-make-link cpltxt)))) =20 - ((and (buffer-file-name (buffer-base-buffer)) (org-mode-p)) + ((and (buffer-file-name (buffer-base-buffer)) (eq major-mode 'org-mo= de)) (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 matche= s 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-head= line) (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)) =20 (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))) =20 =20 @@ -13244,7 +13244,7 @@ This works in the agenda, and also in an org-mode b= uffer." (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 b= uffer." (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 avoid= ed." 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")) =20 @@ -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 buffe= rs." (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 mail= ing 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 bl= ocks." ;; 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." =20 (defadvice outline-end-of-subtree (around prefer-org-version activate comp= ile) "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)))))) =20 (defun org-link-display-format (link) @@ -20581,7 +20581,7 @@ To get rid of the restriction, use \\[org-agenda-re= move-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-re= move-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-rest= riction-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-g= oto)))))) =20 ;;; Fixes and Hacks for problems with other packages =20 @@ -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 buff= er." - (if (org-mode-p) + (if (eq major-mode 'org-mode) (org-show-context)))) =20 (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)) --=20 1.7.7 --=-=-=--