From 61530a1db1558d27fd92d1e52b4b309fb8193ec0 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Mon, 6 Apr 2009 07:23:46 +0200 Subject: [PATCH] Reload: Only load files that were loaded before The command org-reload did not only reload any loaded files, but all lisp files in the Org distribution. Also, it actually never reloaded any files from the contrib directory. Both of these problems are now fixed. --- contrib/README | 1 + contrib/lisp/org-contribdir.el | 38 ++++++++++++++++++++++++++++++++++ lisp/ChangeLog | 3 +++ lisp/org-compat.el | 14 +++++++++++++ lisp/org.el | 31 ++++++++++++++------------- 5 files changed, 71 insertions(+), 16 deletions(-) create mode 100644 contrib/lisp/org-contribdir.el diff --git a/contrib/README b/contrib/README index 8c1500e1a..9f518bdc7 100644 --- a/contrib/README +++ b/contrib/README @@ -16,6 +16,7 @@ org-bookmark.el --- Links to bookmarks org-browser-url.el --- Store links to webpages directly from Firefox/Opera org-choose.el --- Use TODO keywords to mark decision states org-collector.el --- Collect properties into tables +org-contribdir.el --- Dummy file to mark the org contrib Lisp directory org-depend.el --- TODO dependencies for Org-mode org-elisp-symbol.el --- Org links to emacs-lisp symbols org-eval.el --- The tag, adapted from Muse diff --git a/contrib/lisp/org-contribdir.el b/contrib/lisp/org-contribdir.el new file mode 100644 index 000000000..92c50a083 --- /dev/null +++ b/contrib/lisp/org-contribdir.el @@ -0,0 +1,38 @@ +;;; org-contribdir.el --- Mark the location of the contrib directory +;; Copyright (C) 2009 Free Software Foundation, Inc. +;; +;; Author: Carsten Dominik +;; Keywords: outlines, hypermedia, calendar, wp +;; Homepage: http://orgmode.org +;; Version: 0.01 +;; +;; This file is not yet part of GNU Emacs. +;; +;; GNU Emacs is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; + +;; The sole purpose of this file is to be located in the same place +;; as where the contributed Org files are located, typically in the +;; contrib/lisp directory of the Org-mode distribution. This is to +;; make sure that the command `org-reload' can reliably locate +;; contributed org files. + +(provide 'org-contribdir) + +;;; org-contribdir.el ends here diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3f5ff4170..23b7c2b0a 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,7 +1,10 @@ 2009-04-06 Carsten Dominik + * org-compat.el (org-find-library-name): New function. + * org.el (org-pre-cycle-hook): New hook. (org-cycle): Call the new hook in appropriate places. + (org-reload): Only reload files that have been loaded before. 2009-04-05 Carsten Dominik diff --git a/lisp/org-compat.el b/lisp/org-compat.el index c2c0cf57b..6e03bec36 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -33,6 +33,8 @@ (require 'org-macs) +(declare-function find-library-name "find-func" (library)) + (defconst org-xemacs-p (featurep 'xemacs)) ; not used by org.el itself (defconst org-format-transports-properties-p (let ((x "a")) @@ -295,6 +297,16 @@ that can be added." (org-no-properties (substring string (or from 0) to)) (substring-no-properties string from to))) +(defun org-find-library-name (library) + (if (fboundp 'find-library-name) + (file-name-directory (find-library-name library)) + ; XEmacs does not have `find-library-name' + (flet ((find-library-name-helper (filename ignored-codesys) + filename) + (find-library-name (library) + (find-library library nil 'find-library-name-helper))) + (file-name-directory (find-library-name library))))) + (defun org-count-lines (s) "How many lines in string S?" (let ((start 0) (n 1)) @@ -304,6 +316,8 @@ that can be added." (setq n (1- n))) n)) + + (provide 'org-compat) ;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe diff --git a/lisp/org.el b/lisp/org.el index 469e2dd66..1eee016b9 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -2750,7 +2750,6 @@ Normal means, no org-mode-specific context." (defvar mark-active) ;; Various packages -(declare-function find-library-name "find-func" (library)) (declare-function calendar-absolute-from-iso "cal-iso" (date)) (declare-function calendar-forward-day "cal-move" (arg)) (declare-function calendar-goto-date "cal-move" (date)) @@ -7474,7 +7473,7 @@ Org-mode syntax." (defun org-open-at-point (&optional in-emacs reference-buffer) "Open link at or after point. If there is no link at point, this function will search forward up to -the end of the current subtree. +the end of the current line. Normally, files will be opened by an appropriate application. If the optional argument IN-EMACS is non-nil, Emacs will visit the file. With a double prefix argument, try to open outside of Emacs, in the @@ -14727,16 +14726,15 @@ With optional NODE, go directly to that node." With prefix arg UNCOMPILED, load the uncompiled versions." (interactive "P") (require 'find-func) - (let* ((dir - (if (fboundp 'find-library-name) - (file-name-directory (find-library-name "org")) - (flet ((find-library-name-helper (filename ignored-codesys) - filename) - (find-library-name - (library) - (find-library library nil 'find-library-name-helper))) - (file-name-directory (find-library-name "org"))))) - (files (directory-files dir t "\\.el\\'")) + (let* ((file-re "^\\(org\\|orgtbl\\)\\(\\.el\\|-.*\\.el\\)") + (dir-org (file-name-directory (org-find-library-name "org"))) + (dir-org-contrib (ignore-errors + (file-name-directory + (org-find-library-name "org-contribdir")))) + (files + (append (directory-files dir-org t file-re) + (and dir-org-contrib + (directory-files dir-org-contrib t file-re)))) (remove-re (concat (if (featurep 'xemacs) "org-colview" "org-colview-xemacs") "\\'"))) @@ -14747,10 +14745,11 @@ With prefix arg UNCOMPILED, load the uncompiled versions." (setq files (delq nil files)) (mapc (lambda (f) - (if (and (not uncompiled) - (file-exists-p (concat f ".elc"))) - (load (concat f ".elc") nil nil t) - (load (concat f ".el") nil nil t))) + (when (featurep (intern (file-name-nondirectory f))) + (if (and (not uncompiled) + (file-exists-p (concat f ".elc"))) + (load (concat f ".elc") nil nil t) + (load (concat f ".el") nil nil t)))) files))) ;;;###autoload