* idea, in-line preview link
@ 2012-04-05 9:04 Torsten Wagner
2012-04-05 11:55 ` Christian Moe
0 siblings, 1 reply; 3+ messages in thread
From: Torsten Wagner @ 2012-04-05 9:04 UTC (permalink / raw)
To: Org Mode Mailing List
Hi,
recently I was wondering if org-mode could have some sort of inline
link. This would allow quick check-ups on details without having more
and more buffers open.
That is a link to another text (org-file) including text position like
[[file:~/code/main.c::255]]
However instead of open a new buffer and jump to that line, I would
like to see the line +x lines just below the link and possible only
until I move the cursor or by any other means close the link again
Thus
[[inlinefile:~/code/main.c::255+4]]
open it
[[inlinefile:~/code/main.c::255+4]]
1. This is all code
2. from main.c
3. I can preview in org
4. without switching the buffer
5. is that useful?!
close it again and the buffer looks again like
[[inlinefile:~/code/main.c::255+4]]
Actually, I believe it is fairly easy to implement for people knowing
LISP just a bit better then me ;)
What do you think
Totti
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: idea, in-line preview link
2012-04-05 9:04 idea, in-line preview link Torsten Wagner
@ 2012-04-05 11:55 ` Christian Moe
2012-04-12 12:02 ` peter.frings
0 siblings, 1 reply; 3+ messages in thread
From: Christian Moe @ 2012-04-05 11:55 UTC (permalink / raw)
To: Torsten Wagner; +Cc: Org Mode Mailing List
Hi,
One of my first Lisp projects was a link type that behaves a bit like
what you describe.
I don't bother with placing the snippet inline, though, I just flash
it as a message in the minibuffer. But I also leave it on the kill
ring, so I can C-y it into my current buffer if I like.
The following quick and dirty adaptation to your inlinefile idea comes
with ABSOLUTELY NO WARRANTY.
#+BEGIN_SRC elisp
(defun my/org-inlinefile-get (file offset length)
"Copy the line at OFFSET and LENGTH extra lines from FILE."
(let (beg)
(save-excursion
(with-temp-buffer
(insert-file-contents file)
(forward-line (1- offset)) ; Go to beg of range
(setq beg (point))
(if length
(progn
(goto-line (+ offset length))
(kill-region beg (line-end-position)))
(kill-line))
(yank)))))
(defun my/org-inlinefile-open (path)
"Open a link by displaying the lines specified in PATH as a message
and making them available for yanking."
(let ((parts (split-string (org-no-properties path) "\\(::\\|\\+\\)"))
file offset length beg)
(setq file (car parts)
offset (string-to-number (or (nth 1 parts) "0"))
length (string-to-number (or (nth 2 parts) "0")))
(my/org-inlinefile-get file offset length)
(message (format "%s\n%s" path (current-kill 0)))))
(org-add-link-type "inlinefile" 'my/org-inlinefile-open (lambda (path
desc format) desc))
#+END_SRC
Yours,
Christian
On 4/5/12 11:04 AM, Torsten Wagner wrote:
> Hi,
>
> recently I was wondering if org-mode could have some sort of inline
> link. This would allow quick check-ups on details without having more
> and more buffers open.
> That is a link to another text (org-file) including text position like
>
> [[file:~/code/main.c::255]]
>
> However instead of open a new buffer and jump to that line, I would
> like to see the line +x lines just below the link and possible only
> until I move the cursor or by any other means close the link again
>
> Thus
>
> [[inlinefile:~/code/main.c::255+4]]
>
> open it
>
> [[inlinefile:~/code/main.c::255+4]]
> 1. This is all code
> 2. from main.c
> 3. I can preview in org
> 4. without switching the buffer
> 5. is that useful?!
>
> close it again and the buffer looks again like
>
> [[inlinefile:~/code/main.c::255+4]]
>
>
> Actually, I believe it is fairly easy to implement for people knowing
> LISP just a bit better then me ;)
>
> What do you think
>
> Totti
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: idea, in-line preview link
2012-04-05 11:55 ` Christian Moe
@ 2012-04-12 12:02 ` peter.frings
0 siblings, 0 replies; 3+ messages in thread
From: peter.frings @ 2012-04-12 12:02 UTC (permalink / raw)
To: mail; +Cc: Org Mode Mailing List
Good day all,
On 05 Apr 2012, at 13:55, Christian Moe wrote:
> One of my first Lisp projects was a link type that behaves a bit like what you describe.
>
> I don't bother with placing the snippet inline, though, I just flash it as a message in the minibuffer. But I also leave it on the kill ring, so I can C-y it into my current buffer if I like.
From a UX pov, changing the clipboard/kill-ring behind the user’s back is a bad thing to do, especially when the intention of the user action is only to have a quick look at that link. Suppose org-mode copied a whole sub-tree when all you did was to expand it... just in case you wanted to copy a piece of it.
In my opinion, it’s better to provide an explicit command to copy/insert/open/... the content of that link.
Cheers,
Peter.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-04-12 12:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-05 9:04 idea, in-line preview link Torsten Wagner
2012-04-05 11:55 ` Christian Moe
2012-04-12 12:02 ` peter.frings
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).