[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Dragging URLs to an org buffer

From: Piotr Zielinski
Subject: [Orgmode] Dragging URLs to an org buffer
Date: Tue, 3 Oct 2006 19:27:03 +0200


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


Alternatively, here's the elisp code

(defadvice dnd-insert-text (around org-mouse-dnd-insert-text activate)
 (if (eq major-mode 'org-mode)
         ;; if this is the end of the line then just insert text here
          (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")  
                 (skip-chars-backward " \t") (bolp)))
          (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
          (newline t)
          (insert "+ ")))
        (insert text)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]