emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Richard <theonewiththeevillook@yahoo.fr>
To: emacs-orgmode@gnu.org
Subject: nicer error message when accessing killed buffer.
Date: Fri, 27 Feb 2015 13:16:36 +0100	[thread overview]
Message-ID: <87zj7z1rdn.fsf@yahoo.fr> (raw)

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 <theonewiththeevillook@yahoo.fr>
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	other threads:[~2015-02-27 12:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27 12:16 Nicolas Richard [this message]
2015-02-27 23:53 ` nicer error message when accessing killed buffer Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zj7z1rdn.fsf@yahoo.fr \
    --to=theonewiththeevillook@yahoo.fr \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).