From 1fc41ca61e8f7f08c57e55ad688482d956d3ccf3 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Wed, 24 Oct 2012 12:45:08 +0200 Subject: [PATCH] org.el: Add more explicit errors. Fix some declarations and one autoload. * org.el (org-refile-check-position): Throw an error when the refile target is the current buffer and is not a file. (org-agenda-file-to-front, org-remove-file): Throw an error when the current buffer is not a file. (org-check-agenda-file): Enhance the message. (org-element-type): Autoload. (org-element-context, org-element-paragraph-parser): Don't declare as these two functions are not used in org.el. --- lisp/org.el | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index b39d7c0f5..bdbba8611 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -10983,19 +10983,21 @@ this is used for the GOTO interface." (re (nth 2 refile-pointer)) (pos (nth 3 refile-pointer)) buffer) - (when (org-string-nw-p re) - (setq buffer (if (markerp pos) - (marker-buffer pos) - (or (find-buffer-visiting file) - (find-file-noselect file)))) - (with-current-buffer buffer - (save-excursion - (save-restriction - (widen) - (goto-char pos) - (beginning-of-line 1) - (unless (org-looking-at-p re) - (error "Invalid refile position, please clear the cache with `C-0 C-c C-w' before refiling")))))))) + (if (and (not (markerp pos)) (not file)) + (error "Please save the buffer to a file before refiling") + (when (org-string-nw-p re) + (setq buffer (if (markerp pos) + (marker-buffer pos) + (or (find-buffer-visiting file) + (find-file-noselect file)))) + (with-current-buffer buffer + (save-excursion + (save-restriction + (widen) + (goto-char pos) + (beginning-of-line 1) + (unless (org-looking-at-p re) + (error "Invalid refile position, please clear the cache with `C-0 C-c C-w' before refiling"))))))))) (defun org-refile-new-child (parent-target child) "Use refile target PARENT-TARGET to add new CHILD below it." @@ -16850,7 +16852,9 @@ end of the list." (file-alist (mapcar (lambda (x) (cons (file-truename x) x)) (org-agenda-files t))) - (ctf (file-truename buffer-file-name)) + (ctf (file-truename + (or buffer-file-name + (error "Please save the current buffer to a file")))) x had) (setq x (assoc ctf file-alist) had x) @@ -16869,7 +16873,8 @@ These are the files which are being checked for agenda entries. Optional argument FILE means use this file instead of the current." (interactive) (let* ((org-agenda-skip-unavailable-files nil) - (file (or file buffer-file-name)) + (file (or file buffer-file-name + (error "Current buffer does not visit a file"))) (true-file (file-truename file)) (afile (abbreviate-file-name file)) (files (delq nil (mapcar @@ -16891,7 +16896,7 @@ Optional argument FILE means use this file instead of the current." (defun org-check-agenda-file (file) "Make sure FILE exists. If not, ask user what to do." (when (not (file-exists-p file)) - (message "non-existent agenda file %s. [R]emove from list or [A]bort?" + (message "Non-existent agenda file %s. [R]emove from list or [A]bort?" (abbreviate-file-name file)) (let ((r (downcase (read-char-exclusive)))) (cond @@ -18657,13 +18662,12 @@ this function returns t, nil otherwise." nil)))) (autoload 'org-element-at-point "org-element") +(autoload 'org-element-type "org-element") (declare-function org-element-at-point "org-element" (&optional keep-trail)) (declare-function org-element-type "org-element" (element)) -(declare-function org-element-context "org-element" ()) (declare-function org-element-contents "org-element" (element)) (declare-function org-element-property "org-element" (property element)) -(declare-function org-element-paragraph-parser "org-element" (limit)) (declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion)) (declare-function org-element-nested-p "org-element" (elem-a elem-b)) (declare-function org-element-swap-A-B "org-element" (elem-a elem-b)) -- 2.11.4.GIT