Browse Source

Better way to load uncompiled code for backtrace production

The new command `org-reload' allows to reload all Org lisp files.
By default it will load compiled files if these are available.  If
not, or when called with a C-u prefix argument, uncompiled code will
be loaded.  This is good for producing a meaningful backtrace when an
error occurs.
Carsten Dominik 16 years ago
parent
commit
825efa1ef9
3 changed files with 33 additions and 8 deletions
  1. 5 8
      doc/org.texi
  2. 4 0
      lisp/ChangeLog
  3. 24 0
      lisp/org.el

+ 5 - 8
doc/org.texi

@@ -630,14 +630,11 @@ error occurred.  Here is how to produce a useful backtrace:
 
 @enumerate
 @item
-Start a fresh Emacs or XEmacs, and make sure that it will load the
-original Lisp code in @file{org.el} instead of the compiled version in
-@file{org.elc}.  The backtrace contains much more information if it is
-produced with uncompiled code.  To do this, either rename @file{org.elc}
-to something else before starting Emacs, or ask Emacs explicitly to load
-@file{org.el} by using the command line
-@example
-emacs -l /path/to/org.el
+Reload uncompiled versions of all Org-mode lisp files.  The backtrace
+contains much more information if it is produced with uncompiled code.
+To do this, use
+@example
+C-u M-x org-reload RET
 @end example
 @item
 Go to the @code{Options} menu and select @code{Enter Debugger on Error}

+ 4 - 0
lisp/ChangeLog

@@ -1,3 +1,7 @@
+2009-02-21  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-reload): New command.
+
 2009-02-20  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-exp.el (org-export-htm-get-tag-class-name)

+ 24 - 0
lisp/org.el

@@ -14259,6 +14259,30 @@ With optional NODE, go directly to that node."
 		     org-exp org-id org-export-latex org-publish
 		     org-remember org-table org-timer)))
 
+;;;###autoload
+(defun org-reload (&optional uncompiled)
+  "Reload all org lisp files.
+With prefix arg UNCOMPILED, load the uncompiled versions."
+  (interactive "P")
+  (require 'find-func)
+  (let* ((dir (file-name-directory (find-library-name "org")))
+	 (files (directory-files dir t "\\.el\\'"))
+	 (remove-re (concat (if (featurep 'xemacs)
+				"org-colview" "org-colview-xemacs")
+			    "\\'")))
+    (setq files (mapcar 'file-name-sans-extension files))
+    (setq files (mapcar
+		 (lambda (x) (if (string-match remove-re x) nil x))
+		 files))
+    (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)))
+     files)))
+
 ;;;###autoload
 (defun org-customize ()
   "Call the customize function with org as argument."