From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Piotr Zielinski" Subject: Dragging URLs to an org buffer Date: Tue, 3 Oct 2006 19:27:03 +0200 Message-ID: <3c12eb8d0610031027t7d1d98e1x4258e840d66b218d@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GUo2s-0001dX-B3 for emacs-orgmode@gnu.org; Tue, 03 Oct 2006 13:27:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GUo2q-0001bC-Rs for emacs-orgmode@gnu.org; Tue, 03 Oct 2006 13:27:06 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GUo2q-0001au-Kn for emacs-orgmode@gnu.org; Tue, 03 Oct 2006 13:27:04 -0400 Received: from [64.233.162.203] (helo=nz-out-0102.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GUo95-0002hQ-V1 for emacs-orgmode@gnu.org; Tue, 03 Oct 2006 13:33:32 -0400 Received: by nz-out-0102.google.com with SMTP id z31so702847nzd for ; Tue, 03 Oct 2006 10:27:03 -0700 (PDT) Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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