summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2009-11-11 08:41:44 +0100
committerCarsten Dominik <carsten.dominik@gmail.com>2009-11-11 09:31:26 +0100
commit8d7d158013a3642af8239075fd7cfb39adfc518d (patch)
tree986b74e27179ff166952bd57154312d7e246a1bf
parent3ebaffe07e2a42bf844649a7a34ccb534bd87652 (diff)
downloadorg-mode-8d7d158013a3642af8239075fd7cfb39adfc518d.tar.gz
Restore working directory after computing org-version
Sebastian Rose writes > 1. Open an *.org file you can export to PDF. Ensure the file is not > located where your Org-mode sources are (org-*.el files). Choose a > file, that includes some images or a SETUPFILE using relative > paths. > 2. M-x default-directory RET > to see the value of that variable in the current buffer. > 3. C-c C-e p > to export to PDF and verify it works. > 4. C-c C-x ! > to `org-reload' > 5. Now repeat steps 2 and 3. Note, that the export fails. Sebastian also submitted the basic patch to fix this
-rw-r--r--lisp/org.el33
1 files changed, 17 insertions, 16 deletions
diff --git a/lisp/org.el b/lisp/org.el
index dd34816..c0afd10 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -102,28 +102,29 @@
"Show the org-mode version in the echo area.
With prefix arg HERE, insert it at point."
(interactive "P")
- (let* ((version org-version)
+ (let* ((origin default-directory)
+ (version org-version)
(git-version)
(dir (concat (file-name-directory (locate-library "org")) "../" )))
- (if (and (file-exists-p (expand-file-name ".git" dir))
- (executable-find "git"))
- (let ((pwd (substring (pwd) 10)))
- (cd dir)
- (if (eql 0 (shell-command "git describe --abbrev=4 HEAD"))
+ (when (and (file-exists-p (expand-file-name ".git" dir))
+ (executable-find "git"))
+ (unwind-protect
+ (progn
+ (cd dir)
+ (when (eql 0 (shell-command "git describe --abbrev=4 HEAD"))
(with-current-buffer "*Shell Command Output*"
(goto-char (point-min))
- (re-search-forward "[^\n]+")
- (setq git-version (match-string 0))
- (subst-char-in-string ?- ?. git-version t)
- (shell-command "git diff-index --name-only HEAD --")
- (unless (eql 1 (point-max))
- (setq git-version (concat git-version ".dirty")))
- (setq version (concat version " (" git-version ")")))
- (cd pwd))))
+ (setq git-version (buffer-substring (point) (point-at-eol))))
+ (subst-char-in-string ?- ?. git-version t)
+ (when (string-match "\\S-"
+ (shell-command-to-string
+ "git diff-index --name-only HEAD --"))
+ (setq git-version (concat git-version ".dirty")))
+ (setq version (concat version " (" git-version ")"))))
+ (cd origin)))
(setq version (format "Org-mode version %s" version))
(if here (insert version))
- (message version)
- version))
+ (message version)))
;;; Compatibility constants