summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2009-09-04 13:11:18 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2009-09-04 13:11:18 +0200
commit206660bc8c02e5025d5f43cd3e5fb36c2fe0c8f3 (patch)
treeb74a8cde02ecf21b3ecffa88c15dc67cb1985d48
parentc125359a9bd13baef4a1ecc75aa55e7ee22be562 (diff)
downloadorg-mode-206660bc8c02e5025d5f43cd3e5fb36c2fe0c8f3.tar.gz
Store link: Don't error before the first heading in a file
Matt Lundin writes: > When I call org-remember or org-store-link above the first headline in > an org buffer, I receive the following error message: > > Before first headline at position 1 in buffer index.org > > It seems that either org-remember or org-store-link (or both) calls > org-back-to-heading in order to grab the relevant heading for > annotation. As a result, if I try to store a link above the first > heading, emacs spits out the error message above because there is no > heading to return to. > > Is this the intended behavior? Sometimes I prefer to create a link to > the file as a whole rather than to a particular headline. E.g., I might > want to create a todo to organize notes.org, which is not an agenda > file. In this instance, it does not matter whether org-remember creates > a link to a particular headline. In fact, I would prefer a link to the > file as a whole and thus expect to be able to store a link while on the > first empty line of the file or on #+TITLE.
-rwxr-xr-xlisp/ChangeLog1
-rw-r--r--lisp/org.el3
2 files changed, 3 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5b4eba0..dcfe0f2 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -6,6 +6,7 @@
hidden.
(org-iswitchb-completing-read): Bind `switchb-use-virtual-buffers'
to nil for special completion.
+ (org-store-link): Don't error before the first heading.
* org-agenda.el (org-agenda-open-link): Pass the prefix to
`org-offer-links-in-entry'.
diff --git a/lisp/org.el b/lisp/org.el
index 1f74880..87b044b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7269,7 +7269,8 @@ For file links, arg negates `org-context-in-file-links'."
(condition-case nil
(org-make-org-heading-search-string txt)
(error "")))
- desc (or (nth 4 (org-heading-components)) "NONE"))))
+ desc (or (nth 4 (ignore-errors
+ (org-heading-components))) "NONE"))))
(if (string-match "::\\'" cpltxt)
(setq cpltxt (substring cpltxt 0 -2)))
(setq link (org-make-link cpltxt)))))