emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org Linking to Bookmark [+]
@ 2015-02-11 11:49 Tory S. Anderson
  2015-02-11 14:46 ` Drew Adams
  0 siblings, 1 reply; 4+ messages in thread
From: Tory S. Anderson @ 2015-02-11 11:49 UTC (permalink / raw)
  To: orgmode list, Drew Adams

I have weekly TODO items that link to something that needs to be updated; for instance, I write a weekly letter to my daughter where  each week the actual file for the letter will change. Right now I have to manually update that link in the org file, which is quite cumbersome. If I could just link to a bookmark then periodic updates of the bookmark would take care of any problem with updating the todo item. So, I've been tryin to kludge a solution based on the orgmode manual; while any suggestions would be useful for my budding elisp skills, in particular I'm not sure how to write the last function (org-bmkp-get-bookmark-name). Any suggestions? 

--8<---------------cut here---------------start------------->8---
;;; * bmkp links http://orgmode.org/manual/Adding-hyperlink-types.html
     (org-add-link-type "bmkp" 'org-bmkp-open)
     (add-hook 'org-store-link-functions 'org-bmkp-store-link)
     
     (defcustom org-bmkp-command 'bmkp
       "The Emacs command to be used to display a bmkp page."
       :group 'org-link
       :type '(choice (const bookmark-jump) (const bookmark-jump-other-window)))
     
     (defun org-bmkp-open (path)
       "Visit the bmkppage on PATH.
     PATH should be a bookmark name that can be thrown at the `bookmark-jump' function."
       (funcall org-bmkp-command path))
     
     (defun org-bmkp-store-link ()
       "Store a link to a bmkp bookmark."
       (when (memq major-mode '(bookmark-bmenu-mode))
         (let* ((bookmark (org-bmkp-get-bookmark-name))
                (link (concat "bmkp:" bookmark))
                (description (format "Bookmark")))
           (org-store-link-props
            :type "bmkp"
            :link link
            :description description))))
     
     (defun org-bmkp-get-bookmark-name () ;; TODO
       "Get the bookmark name at point (from bookmark list)."
       (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
           (match-string 1 (buffer-name))
         (error "Cannot create link to this bmkp bookmark")))
--8<---------------cut here---------------end--------------->8---

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Org Linking to Bookmark [+]
  2015-02-11 11:49 Org Linking to Bookmark [+] Tory S. Anderson
@ 2015-02-11 14:46 ` Drew Adams
  2015-02-11 16:45   ` [DONE] " Tory S. Anderson
  2015-02-11 21:28   ` Marcin Borkowski
  0 siblings, 2 replies; 4+ messages in thread
From: Drew Adams @ 2015-02-11 14:46 UTC (permalink / raw)
  To: torys.anderson, orgmode list

>      (defun org-bmkp-store-link ()
>        "Store a link to a bmkp bookmark."
>        (when (memq major-mode '(bookmark-bmenu-mode))
>          (let* ((bookmark (org-bmkp-get-bookmark-name))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                          |
                                          v
                             (bookmark-bmenu-bookmark)

It looks like you are trying to get the name of the bookmark at
point in buffer `*Bookmark List*'.  To do that, just evaluate
(bookmark-bmenu-bookmark).

For Bookmark+, if you pass that function a non-nil arg then you
get the full bookmark record, not just the name.  (But anyway,
most bookmark functions accept either the name or the bookmark.)

(No relation with Org links, but you can also create simple, 
non-persistent bookmark links using `bmkp-insert-bookmark-link'.
Dunno whether that will help with what you want to do.
http://www.emacswiki.org/emacs/BookmarkPlus#BookmarkLinks)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [DONE] Re: Org Linking to Bookmark [+]
  2015-02-11 14:46 ` Drew Adams
@ 2015-02-11 16:45   ` Tory S. Anderson
  2015-02-11 21:28   ` Marcin Borkowski
  1 sibling, 0 replies; 4+ messages in thread
From: Tory S. Anderson @ 2015-02-11 16:45 UTC (permalink / raw)
  To: Drew Adams; +Cc: orgmode list

Thanks, Drew; I have it now. To all concerned, it's easy to add bookmark+ link support to org-mode with the following:

--8<---------------cut here---------------start------------->8---
;;; * bmkp links http://orgmode.org/manual/Adding-hyperlink-types.html
     (org-add-link-type "bmkp" 'org-bmkp-open)
     (add-hook 'org-store-link-functions 'org-bmkp-store-link)
     
     (defcustom org-bmkp-command 'bookmark-jump
       "The Emacs command to be used to display a bmkp page."
       :group 'org-link
       :type '(choice (const bookmark-jump) (const bookmark-jump-other-window)))

     (defun org-bmkp-open (path)
       "Visit the bmkppage on PATH.
     PATH should be a bookmark name that can be thrown at the `bookmark-jump' function."
       (funcall org-bmkp-command path))
     
     (defun org-bmkp-store-link ()
       "Store a link to a bmkp bookmark."
       (when (memq major-mode '(bookmark-bmenu-mode))
         (let* ((bookmark (bookmark-bmenu-bookmark))
                (link (concat "bmkp:" bookmark))
                (description (format "Bookmark: %s" bookmark)))
           (org-store-link-props
            :type "bmkp"
            :link link
            :description description))))
--8<---------------cut here---------------end--------------->8---




Drew Adams <drew.adams@oracle.com> writes:

>>      (defun org-bmkp-store-link ()
>>        "Store a link to a bmkp bookmark."
>>        (when (memq major-mode '(bookmark-bmenu-mode))
>>          (let* ((bookmark (org-bmkp-get-bookmark-name))
>                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>                                           |
>                                           v
>                              (bookmark-bmenu-bookmark)
>
> It looks like you are trying to get the name of the bookmark at
> point in buffer `*Bookmark List*'.  To do that, just evaluate
> (bookmark-bmenu-bookmark).
>
> For Bookmark+, if you pass that function a non-nil arg then you
> get the full bookmark record, not just the name.  (But anyway,
> most bookmark functions accept either the name or the bookmark.)
>
> (No relation with Org links, but you can also create simple, 
> non-persistent bookmark links using `bmkp-insert-bookmark-link'.
> Dunno whether that will help with what you want to do.
> http://www.emacswiki.org/emacs/BookmarkPlus#BookmarkLinks)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Org Linking to Bookmark [+]
  2015-02-11 14:46 ` Drew Adams
  2015-02-11 16:45   ` [DONE] " Tory S. Anderson
@ 2015-02-11 21:28   ` Marcin Borkowski
  1 sibling, 0 replies; 4+ messages in thread
From: Marcin Borkowski @ 2015-02-11 21:28 UTC (permalink / raw)
  To: torys.anderson, orgmode list


On 2015-02-11, at 15:46, Drew Adams <drew.adams@oracle.com> wrote:

> It looks like you are trying to get the name of the bookmark at
> point in buffer `*Bookmark List*'.  To do that, just evaluate
> (bookmark-bmenu-bookmark).

           _________________________________________________________________
 __	  / 						                    \
/  \	  | 							            |
|  |	  | It looks like you are trying to get the name of the bookmark at |
@  @	  | point in buffer `*Bookmark List*'.  To do that, just evaluate   |
|| ||  <--| (bookmark-bmenu-bookmark).				            |
|| ||	  | 							            |
|\_/|	  |                                                                 |
\___/     \_________________________________________________________________/


FTFY.  (Courtesy Fuco's clippy.el.)

(SCNR...)

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-02-11 21:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-11 11:49 Org Linking to Bookmark [+] Tory S. Anderson
2015-02-11 14:46 ` Drew Adams
2015-02-11 16:45   ` [DONE] " Tory S. Anderson
2015-02-11 21:28   ` Marcin Borkowski

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