* Feature request: custom link handlers
@ 2007-11-30 10:25 Tom Weissmann
2007-11-30 12:46 ` Bastien
0 siblings, 1 reply; 10+ messages in thread
From: Tom Weissmann @ 2007-11-30 10:25 UTC (permalink / raw)
To: emacs-orgmode
This is basically a request to be able to create custom link handlers.
For example, my `org-link-abbrev-alist' is this:
`(("wiki" . org-link-abbrev-wiki)
("bmk" . org-link-abbrev-bookmark)
("POA" . org-link-abbrev-poa))
Only one of these actually returns a link that Org mode can use: wiki returns a
url. "bmk" opens a bookmark and "POA" opens another application; neither return
anything, so using them raises an error message.
One possibility would be to allow the link abbreviations to return two values:
nil and a message. `org-link-abbrev-poa' could then return
'(nil
"Opening POA XYZ")
and Org mode wouldn't fret about not receiving a null link, but simply display
the message.
Another possibility would be to create a door to add custom link handlers with
custom completion - that way one could add bookmark links with minibuffer
completion...
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Feature request: custom link handlers
2007-11-30 10:25 Feature request: custom link handlers Tom Weissmann
@ 2007-11-30 12:46 ` Bastien
2007-11-30 13:50 ` Tom Weissmann
0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2007-11-30 12:46 UTC (permalink / raw)
To: emacs-orgmode
Tom Weissmann <trmsw@yahoo.co.uk> writes:
> This is basically a request to be able to create custom link handlers.
>
> For example, my `org-link-abbrev-alist' is this:
>
> `(("wiki" . org-link-abbrev-wiki)
> ("bmk" . org-link-abbrev-bookmark)
> ("POA" . org-link-abbrev-poa))
>
>
> Only one of these actually returns a link that Org mode can use: wiki returns a
> url. "bmk" opens a bookmark and "POA" opens another application; neither return
> anything, so using them raises an error message.
I'm not sure to understand.
For now `org-link-abbrev-alist' looks like:
'(("google" . "http://www.google.com/search?q=%s"))
where the cdr of each cell is a formatting string in which %s stand for
the text after "::" (or ":"). So for example :
[[google::orgmode]]
is the abbreviated form of
[[http://www.google.com/search?q=orgmode]]
Are you suggesting to replace "http://www.google.com/search?q=%s" by a
function that would handle the text after "::" in a different way than
`format' is currently doing?
I think a step by step example would be useful here.
--
Bastien
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Feature request: custom link handlers
2007-11-30 12:46 ` Bastien
@ 2007-11-30 13:50 ` Tom Weissmann
2007-11-30 14:02 ` Bastien
0 siblings, 1 reply; 10+ messages in thread
From: Tom Weissmann @ 2007-11-30 13:50 UTC (permalink / raw)
To: emacs-orgmode
Bastien <bzg <at> altern.org> writes:
> Are you suggesting to replace "http://www.google.com/search?q=%s" by a
> function that would handle the text after "::" in a different way than
> `format' is currently doing?
No.
Here's an example. I sometimes create links to Emacs bookmarks, eg
"bmk:org-mode-tweaks"
The bmk abbreviation is expanded to a link Org mode understands, by
this function:
(defun org-link-abbrev-bookmark (bookmark)
"Opens a bookmark in another window"
(bookmark-jump-other-window bookmark))
- which happens to return nil, NOT a link that Org mode understands,
so even though it opens the bookmark I still get an error -
essentially because I'm using a function that expands an
abbreviation simply for its side effects.
If possible I would like Org mode to display a message like "Opening
bookmark org-mode-tweaks" instead of "if: Wrong type argument:
stringp, nil", which is why I suggested the multiple return value.
On the other hand I could return an elisp link and set
`org-confirm-elisp-link-function' to nil, to avoid having to confirm
every time I clicked one of these links
---
The other suggestion I realise doesn't make sense because when you
create a link with C-c C-l, the only minibuffer completion is of the
link type (file, new, mailto, etc.), not what follows.
It would be very cool to do C-c C-l, entry "bmk:" as the bookmark
type, and then have minibuffer completion of all the existing
bookmarks, but `org-store-link' works fine :)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Re: Feature request: custom link handlers
2007-11-30 13:50 ` Tom Weissmann
@ 2007-11-30 14:02 ` Bastien
2007-11-30 14:14 ` Bastien
0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2007-11-30 14:02 UTC (permalink / raw)
To: emacs-orgmode
Tom Weissmann <trmsw@yahoo.co.uk> writes:
> Bastien <bzg <at> altern.org> writes:
>
>> Are you suggesting to replace "http://www.google.com/search?q=%s" by a
>> function that would handle the text after "::" in a different way than
>> `format' is currently doing?
> No.
>
> Here's an example. I sometimes create links to Emacs bookmarks, eg
> "bmk:org-mode-tweaks"
Thanks for the example.
> It would be very cool to do C-c C-l, entry "bmk:" as the bookmark
> type, and then have minibuffer completion of all the existing
> bookmarks, but `org-store-link' works fine :)
I think what you are trying to achieve is better described as a new
hyperlink mechanism rather than an extension of abbrev links.
Check this:
(info "(org)Adding hyperlink types")
You can have a new hyperlink facility for bookmarked files. When an a
buffer visiting a file, storing a link to this buffer would really store
a link to a bookmark, and when visiting a link to a bookmark Emacs will
find the bookmark.
What do you think?
--
Bastien
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Re: Feature request: custom link handlers
2007-11-30 14:02 ` Bastien
@ 2007-11-30 14:14 ` Bastien
2007-11-30 14:44 ` Tom Weissmann
0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2007-11-30 14:14 UTC (permalink / raw)
To: emacs-orgmode
Bastien <bzg@altern.org> writes:
>> type, and then have minibuffer completion of all the existing
>> bookmarks, but `org-store-link' works fine :)
>
> I think what you are trying to achieve is better described as a new
> hyperlink mechanism rather than an extension of abbrev links.
Sorry, should read: "as a new hyperlink type"...
--
Bastien
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Feature request: custom link handlers
2007-11-30 14:14 ` Bastien
@ 2007-11-30 14:44 ` Tom Weissmann
2007-11-30 15:01 ` Bastien
0 siblings, 1 reply; 10+ messages in thread
From: Tom Weissmann @ 2007-11-30 14:44 UTC (permalink / raw)
To: emacs-orgmode
Bastien <bzg <at> altern.org> writes:
> > I think what you are trying to achieve is better described as a new
> > hyperlink mechanism rather than an extension of abbrev links.
>
> Sorry, should read: "as a new hyperlink type"...
Yes. But a cheap alternative is just to let abbrev link functions return nil if
they want to.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Re: Feature request: custom link handlers
2007-11-30 14:44 ` Tom Weissmann
@ 2007-11-30 15:01 ` Bastien
2007-11-30 16:22 ` Tom Weissmann
0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2007-11-30 15:01 UTC (permalink / raw)
To: emacs-orgmode
Tom Weissmann <trmsw@yahoo.co.uk> writes:
> Bastien <bzg <at> altern.org> writes:
>
>> > I think what you are trying to achieve is better described as a new
>> > hyperlink mechanism rather than an extension of abbrev links.
>>
>> Sorry, should read: "as a new hyperlink type"...
>
> Yes. But a cheap alternative is just to let abbrev link functions
> return nil if they want to.
I find this a bit confusing to use a function that expands an
abbreviation only for its side effects.
But maybe you can just tell your function to return a string:
(defun org-link-abbrev-bookmark (bookmark)
"Opens a bookmark in another window"
(progn (bookmark-jump-other-window bookmark) ""))
No?
--
Bastien
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Feature request: custom link handlers
2007-11-30 15:01 ` Bastien
@ 2007-11-30 16:22 ` Tom Weissmann
2007-11-30 16:37 ` Tom Weissmann
0 siblings, 1 reply; 10+ messages in thread
From: Tom Weissmann @ 2007-11-30 16:22 UTC (permalink / raw)
To: emacs-orgmode
Bastien <bzg <at> altern.org> writes:
> I find this a bit confusing to use a function that expands an
> abbreviation only for its side effects.
Yes. It would be nice to be able to add custom link handlers and define
completion functions for them :)
> But maybe you can just tell your function to return a string:
...
> No?
oops! I tried that before and it kept moving me back to the beginning of my org
file, whereas now it, um, doesn't. Can't see for the egg on my face.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Feature request: custom link handlers
2007-11-30 16:22 ` Tom Weissmann
@ 2007-11-30 16:37 ` Tom Weissmann
2007-11-30 16:51 ` Bastien
0 siblings, 1 reply; 10+ messages in thread
From: Tom Weissmann @ 2007-11-30 16:37 UTC (permalink / raw)
To: emacs-orgmode
Tom Weissmann <trmsw <at> yahoo.co.uk> writes:
> oops! I tried that before and it kept moving me back to the beginning of my org
> file, whereas now it, um, doesn't. Can't see for the egg on my face.
In the meantime I discovered `org-add-link-type' which does everything I want
except the completions.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Re: Feature request: custom link handlers
2007-11-30 16:37 ` Tom Weissmann
@ 2007-11-30 16:51 ` Bastien
0 siblings, 0 replies; 10+ messages in thread
From: Bastien @ 2007-11-30 16:51 UTC (permalink / raw)
To: emacs-orgmode
Tom Weissmann <trmsw@yahoo.co.uk> writes:
> Tom Weissmann <trmsw <at> yahoo.co.uk> writes:
>
>> oops! I tried that before and it kept moving me back to the beginning of my org
>> file, whereas now it, um, doesn't. Can't see for the egg on my face.
>
> In the meantime I discovered `org-add-link-type' which does everything I want
> except the completions.
Yes. Go and read the example about adding link type in the manual, I'm
pretty sure it will help you doing what you want.
--
Bastien
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-11-30 16:51 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-30 10:25 Feature request: custom link handlers Tom Weissmann
2007-11-30 12:46 ` Bastien
2007-11-30 13:50 ` Tom Weissmann
2007-11-30 14:02 ` Bastien
2007-11-30 14:14 ` Bastien
2007-11-30 14:44 ` Tom Weissmann
2007-11-30 15:01 ` Bastien
2007-11-30 16:22 ` Tom Weissmann
2007-11-30 16:37 ` Tom Weissmann
2007-11-30 16:51 ` Bastien
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).