From: "Piotr Zielinski" <piotr.zielinski@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Dragging URLs to an org buffer
Date: Tue, 3 Oct 2006 19:27:03 +0200 [thread overview]
Message-ID: <3c12eb8d0610031027t7d1d98e1x4258e840d66b218d@mail.gmail.com> (raw)
Hi,
Here's a piece of elisp that allows you to drag URLs from a webbrowser
(or other apps) to an org buffer. If the current line looks like
+ this is an existing item
Then releasing a drag to the left of "+" will insert the URL before:
+ http://www.dragged.url
+ this is an existing item
Releasing on the text "+ this is an existing item" will insert the URL after:
+ this is an existing item
+ http://www.dragged.url
Releasing to the right of the text will produce:
+ this is an existing item: http://www.dragged.url
Any suggestions welcome. The functionality is now part of org-mouse
(I think it requires Emacs 22):
http://www.cl.cam.ac.uk/~pz215/files/org-mouse.el
Alternatively, here's the elisp code
(defadvice dnd-insert-text (around org-mouse-dnd-insert-text activate)
(if (eq major-mode 'org-mode)
(progn
(cond
;; if this is the end of the line then just insert text here
((eolp)
(skip-chars-backward " \t")
(kill-region (point) (point-at-eol))
(unless (looking-back ":") (insert ":"))
(insert " "))
;; if this is the beginning of the line then insert before
((and (looking-at " \\|\t")
(save-excursion
(skip-chars-backward " \t") (bolp)))
(beginning-of-line)
(looking-at "[ \t]*")
(open-line 1)
(indent-to (- (match-end 0) (match-beginning 0)))
(insert "+ "))
;; if this is a middle of the line, then insert after
(t
(end-of-line)
(newline t)
(indent-relative)
(insert "+ ")))
(insert text)
(beginning-of-line))
ad-do-it))
Piotr
next reply other threads:[~2006-10-03 17:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-03 17:27 Piotr Zielinski [this message]
2006-10-04 11:58 ` Dragging URLs to an org buffer Carsten Dominik
2006-10-04 15:30 ` Piotr Zielinski
2006-10-04 15:57 ` Carsten Dominik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3c12eb8d0610031027t7d1d98e1x4258e840d66b218d@mail.gmail.com \
--to=piotr.zielinski@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).