0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-08-25 08:32:53 +00:00

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.
This commit is contained in:
Carsten Dominik 2009-09-04 13:11:18 +02:00
parent c125359a9b
commit 206660bc8c
2 changed files with 3 additions and 1 deletions

View file

@ -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'.

View file

@ -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)))))