all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Dragging URLs to an org buffer
@ 2006-10-03 17:27 Piotr Zielinski
  2006-10-04 11:58 ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Piotr Zielinski @ 2006-10-03 17:27 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Dragging URLs to an org buffer
  2006-10-03 17:27 Dragging URLs to an org buffer Piotr Zielinski
@ 2006-10-04 11:58 ` Carsten Dominik
  2006-10-04 15:30   ` Piotr Zielinski
  0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2006-10-04 11:58 UTC (permalink / raw)
  To: Piotr Zielinski; +Cc: emacs-orgmode


On Oct 3, 2006, at 19:27, Piotr Zielinski wrote:

> Hi,
>
> Here's a piece of elisp that allows you to drag URLs from a webbrowser
> (or other apps) to an org buffer.

Great.

> 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

I like the functionality, but I do find it too specialized to make this 
behavior the default.  So I would weaken it, or enclose turning it on 
into a customization variable.  The reasons why I find it too intrusive 
the way it is now are:

- You enforce a colon for adding to the end of the line
- you enforce a particular type of bullet.
- when inserting in a empty line, the color switches to fixed-width 
quotation
- people might want to use drag-and-drop to insert something into the 
text that happens to be a bullet item.

Proposals:

- Don't enforce the colon when inserting at the end of the line.
- In the middle of a line, just insert there.
- If the current line is a bullet or a headline, *and* if you drop *on* 
either the bullet or the headline stars, then make a new 
headline/bullet for the dragged text.  Always make the bullet after the 
current line.  (well, when inserting in front of a bullet, you could 
insert before the current...)
- Respect the type of bullet:  numbered, -, +, *.


- Carsten

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Dragging URLs to an org buffer
  2006-10-04 11:58 ` Carsten Dominik
@ 2006-10-04 15:30   ` Piotr Zielinski
  2006-10-04 15:57     ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Piotr Zielinski @ 2006-10-04 15:30 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

On 04/10/06, Carsten Dominik <dominik@science.uva.nl> wrote:
> On Oct 3, 2006, at 19:27, Piotr Zielinski wrote:
> > Here's a piece of elisp that allows you to drag URLs from a webbrowser
> > (or other apps) to an org buffer.
>
> I like the functionality, but I do find it too specialized to make this
> behavior the default.  So I would weaken it, or enclose turning it on
> into a customization variable.

Yes, I completely agree with you, this was a hack that worked for me
rather than something everybody could use.  But I thought sharing it
with others might be a good idea, even if only for useful feedback
like yours.

The only thing which I have a different opinion about is what to do
when you drop a URL in the middle of the line.  I believe this
function should be assigned to normal "paste" (middle button).  My
goal was to make drag-and-drop useful for managing org-mode lists
_without_ using a keyboard.  For me this means: (i) an easy
(keyboard-less) way of insterting a new list element before or after
the current element, and (ii) inserting the URL into the current line,
without the need of manual adjustment (adding spaces around, adding
the colon, etc.).  So while I agree that the behaviour must be
customizable, I'd like a solution that satisfies these two criteria.
Anyway, I'll do some modifications, and send the next version.

> The reasons why I find it too intrusive
> the way it is now are:
>
> - You enforce a colon for adding to the end of the line
> - you enforce a particular type of bullet.
> - when inserting in a empty line, the color switches to fixed-width
> quotation
> - people might want to use drag-and-drop to insert something into the
> text that happens to be a bullet item.
>
> Proposals:
>
> - Don't enforce the colon when inserting at the end of the line.
> - In the middle of a line, just insert there.
> - If the current line is a bullet or a headline, *and* if you drop *on*
> either the bullet or the headline stars, then make a new
> headline/bullet for the dragged text.  Always make the bullet after the
> current line.  (well, when inserting in front of a bullet, you could
> insert before the current...)
> - Respect the type of bullet:  numbered, -, +, *.

Piotr

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Dragging URLs to an org buffer
  2006-10-04 15:30   ` Piotr Zielinski
@ 2006-10-04 15:57     ` Carsten Dominik
  0 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2006-10-04 15:57 UTC (permalink / raw)
  To: Piotr Zielinski; +Cc: emacs-orgmode


On Oct 4, 2006, at 17:30, Piotr Zielinski wrote:

> The only thing which I have a different opinion about is what to do
> when you drop a URL in the middle of the line.  I believe this
> function should be assigned to normal "paste" (middle button).

Yes, I forgot that I can use mouse-2 for this.  Right.

>  My
> goal was to make drag-and-drop useful for managing org-mode lists
> _without_ using a keyboard.  For me this means: (i) an easy
> (keyboard-less) way of insterting a new list element before or after
> the current element, and (ii) inserting the URL into the current line,
> without the need of manual adjustment (adding spaces around, adding
> the colon, etc.).  So while I agree that the behaviour must be
> customizable, I'd like a solution that satisfies these two criteria.
> Anyway, I'll do some modifications, and send the next version.

OK, looking forward to it.

- Carsten



--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-10-04 15:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-03 17:27 Dragging URLs to an org buffer Piotr Zielinski
2006-10-04 11:58 ` Carsten Dominik
2006-10-04 15:30   ` Piotr Zielinski
2006-10-04 15:57     ` Carsten Dominik

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.