diff --git a/lisp/ob.el b/lisp/ob.el index e72ba155b..378939752 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -1765,13 +1765,15 @@ the file name is additionally processed by ((lambda (f) (if no-quote-p f (shell-quote-argument f))) (expand-file-name (org-babel-local-file-name name)))) -;; (defvar org-babel-temporary-directory -;; (or (and (boundp 'org-babel-temporary-directory) -;; org-babel-temporary-directory) -;; (make-temp-file "babel-" t)) -;; "Directory to hold temporary files created to execute code blocks. -;; Used by `org-babel-temp-file'. This directory will be removed on -;; Emacs shutdown.") +(unless (boundp 'org-babel-temporary-directory) + (defvar org-babel-temporary-directory + (or (and (boundp 'org-babel-temporary-directory) + (file-exists-p org-babel-temporary-directory) + org-babel-temporary-directory) + (make-temp-file "babel-" t)) + "Directory to hold temporary files created to execute code blocks. +Used by `org-babel-temp-file'. This directory will be removed on +Emacs shutdown.")) (defun org-babel-temp-file (prefix &optional suffix) "Create a temporary file in the `org-babel-temporary-directory'. @@ -1784,29 +1786,29 @@ of `org-babel-temporary-directory'." (expand-file-name prefix temporary-file-directory) nil suffix)) - ;; (let ((temporary-file-directory (expand-file-name - ;; org-babel-temporary-directory - ;; temporary-file-directory))) - ;; (make-temp-file prefix nil suffix)) - (make-temp-file prefix nil suffix))) + (let ((temporary-file-directory + (or (and (file-exists-p org-babel-temporary-directory) + org-babel-temporary-directory) + temporary-file-directory))) + (make-temp-file prefix nil suffix)))) -;; (defun org-babel-remove-temporary-directory () -;; "Remove `org-babel-temporary-directory' on Emacs shutdown." -;; (when (boundp 'org-babel-temporary-directory) -;; ;; taken from `delete-directory' in files.el -;; (mapc (lambda (file) -;; ;; This test is equivalent to -;; ;; (and (file-directory-p fn) (not (file-symlink-p fn))) -;; ;; but more efficient -;; (if (eq t (car (file-attributes file))) -;; (delete-directory file) -;; (delete-file file))) -;; ;; We do not want to delete "." and "..". -;; (directory-files org-babel-temporary-directory 'full -;; "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")) -;; (delete-directory org-babel-temporary-directory))) +(defun org-babel-remove-temporary-directory () + "Remove `org-babel-temporary-directory' on Emacs shutdown." + (when (boundp 'org-babel-temporary-directory) + ;; taken from `delete-directory' in files.el + (mapc (lambda (file) + ;; This test is equivalent to + ;; (and (file-directory-p fn) (not (file-symlink-p fn))) + ;; but more efficient + (if (eq t (car (file-attributes file))) + (delete-directory file) + (delete-file file))) + ;; We do not want to delete "." and "..". + (directory-files org-babel-temporary-directory 'full + "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")) + (delete-directory org-babel-temporary-directory))) -;; (add-hook 'kill-emacs-hook 'org-babel-remove-temporary-directory) +(add-hook 'kill-emacs-hook 'org-babel-remove-temporary-directory) (provide 'ob) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 44face169..6ce9cdde7 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1202,6 +1202,7 @@ The template may still contain \"%?\" for cursor positioning." "org-capture-template-prompt-history::" (or prompt ""))) completions (mapcar 'list completions))) + (unless (boundp histvar) (set histvar nil)) (cond ((member char '("G" "g")) (let* ((org-last-tags-completion-table diff --git a/lisp/org-src.el b/lisp/org-src.el index 6c4c464f1..c1d579cab 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -211,9 +211,7 @@ buffer." (interactive) (unless (eq context 'save) (setq org-edit-src-saved-temp-window-config (current-window-configuration))) - (let ((line (org-current-line)) - (col (current-column)) - (mark (and (use-region-p) (mark))) + (let ((mark (and (use-region-p) (mark))) (case-fold-search t) (info (org-edit-src-find-region-and-lang)) (babel-info (org-babel-get-src-block-info)) @@ -223,7 +221,7 @@ buffer." (preserve-indentation org-src-preserve-indentation) (allow-write-back-p (null code)) block-nindent total-nindent ovl lang lang-f single lfmt buffer msg - begline markline markcol) + begline markline markcol line col) (if (not info) nil (setq beg (move-marker beg (nth 0 info)) @@ -254,7 +252,10 @@ buffer." (org-set-local 'org-edit-src-content-indentation 0)))) (unless (functionp lang-f) (error "No such language mode: %s" lang-f)) - (org-goto-line line) + (save-excursion + (if (> (point) end) (goto-char end)) + (setq line (org-current-line) + col (current-column))) (if (and (setq buffer (org-edit-src-find-buffer beg end)) (if org-src-ask-before-returning-to-edit-buffer (y-or-n-p "Return to existing edit buffer? [n] will revert changes: ") t)) diff --git a/lisp/org-table.el b/lisp/org-table.el index a6f7ac447..42ede7c6f 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -1151,11 +1151,14 @@ is always the old value." (defun org-table-current-column () "Find out which column we are in." + (interactive) + (if (interactive-p) (org-table-check-inside-data-field)) (save-excursion (let ((cnt 0) (pos (point))) (beginning-of-line 1) (while (search-forward "|" pos t) (setq cnt (1+ cnt))) + (if (interactive-p) (message "In table column %d" cnt)) cnt))) (defun org-table-current-dline ()