emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] nicer error message when accessing killed buffer.


From: Nicolas Richard
Subject: [O] nicer error message when accessing killed buffer.
Date: Fri, 27 Feb 2015 13:16:36 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Hello,

I often kill org buffers and then Org agenda throws errors at me when i
want to access a line which was that buffer :

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  goto-char(nil)
  (let* ((marker (or (org-get-at-bol (quote org-marker)) (org-agenda-error))) 
(buffer (marker-buffer marker)) (pos (marker-position marker))) 
(org-pop-to-buffer-same-window buffer) (and delete-other-windows 
(delete-other-windows)) (widen) (goto-char pos) (org-back-to-heading t) (if 
(derived-mode-p (quote org-mode)) (progn (org-show-context (quote agenda)) 
(save-excursion (and (outline-next-heading) (org-flag-heading nil))) (if 
(outline-invisible-p) (progn (show-entry))) (run-hooks (quote 
org-agenda-after-show-hook)))))
  (if (and org-return-follows-link (not (org-get-at-bol (quote org-marker))) 
(org-in-regexp org-bracket-link-regexp)) (org-open-link-from-string 
(match-string 0)) (let* ((marker (or (org-get-at-bol (quote org-marker)) 
(org-agenda-error))) (buffer (marker-buffer marker)) (pos (marker-position 
marker))) (org-pop-to-buffer-same-window buffer) (and delete-other-windows 
(delete-other-windows)) (widen) (goto-char pos) (org-back-to-heading t) (if 
(derived-mode-p (quote org-mode)) (progn (org-show-context (quote agenda)) 
(save-excursion (and (outline-next-heading) (org-flag-heading nil))) (if 
(outline-invisible-p) (progn (show-entry))) (run-hooks (quote 
org-agenda-after-show-hook))))))
  org-agenda-switch-to()
  funcall-interactively(org-agenda-switch-to)
  call-interactively(org-agenda-switch-to nil nil)
  command-execute(org-agenda-switch-to)

I'd like to suggest the following trivial patch:


>From 7c1f9a9f966057a68ae34d1dfc0431aec553142e Mon Sep 17 00:00:00 2001
From: Nicolas Richard <address@hidden>
Date: Fri, 27 Feb 2015 13:12:45 +0100
Subject: [PATCH] * lisp/org-agenda.el (org-agenda-switch-to): Throw an error
 if marker points to no buffer.

---
 lisp/org-agenda.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 29313a1..53a2c2b 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -8583,6 +8583,8 @@ (defun org-agenda-switch-to (&optional 
delete-other-windows)
                       (org-agenda-error)))
           (buffer (marker-buffer marker))
           (pos (marker-position marker)))
+      (unless buffer
+       (user-error "Trying to switch to non-existent buffer."))
       (org-pop-to-buffer-same-window buffer)
       (and delete-other-windows (delete-other-windows))
       (widen)
-- 
2.1.4



reply via email to

[Prev in Thread] Current Thread [Next in Thread]