unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: [patch] enhanced mac drag-n-drop
Date: Wed, 06 Apr 2005 07:37:24 -0400	[thread overview]
Message-ID: <87br8sdu99.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <m2br8svi8j.fsf@Sean-ORourkes-Computer.local> (Sean O'Rourke's message of "Tue, 05 Apr 2005 17:53:00 -0700")

>   "Perform the most common action for each type of item dropped
> onto Emacs on Mac OS X.  Currently, this means:
>     * File or directory -- call `find-file'.
>     * URL -- call `browse-url-browser-function'.
>     * Text -- insert text at point."

I use my MacOSX system pretty much exclusively as an X11 server, so maybe
I don't understand enough of Mac OS X's GUI philosophy, but I believe that
the behavior by default for URL should be the same as for Text, except maybe
when the browse-url function is configured to use one of the Emacs based
webbrowsers (like W3, or emacs-w3m).
The idea is that if I want to open a URL in Safari or Firefox, I'll
drag&drop it there, whereas if I drop it onto Emacs I most likely *don't*
intend it to go to my external browser.
Of course, if I have url-handlers-mode enabled, maybe I intend URL-drops to
call find-file as well ;-)

>   (interactive "e")
>   ;; Make sure the drop target has positive co-ords before setting the
>   ;; selected frame - otherwise it won't work.  <skx@tardis.ed.ac.uk>
>   (let* ((window (posn-window (event-start event)))
>          (coords (posn-x-y (event-start event)))
>          (x (car coords))
>          (y (cdr coords)))
>     (if (and (> x 0) (> y 0))
>         (set-frame-selected-window nil window))

Under which circumstances can X and/or Y be negative?

>     (mapcar
>      (lambda (name)
>        (case (car name)

Please use dolist instead of mapcar here.

>          (text (insert (cdr name)))
>          (url (funcall browse-url-browser-function (cdr name)))

Why not (browse-url (cdr name)) ?

>          (file
>           (setq name (cdr name))
>           (if (and (file-exists-p name)
>                    (not (string-match (image-file-name-regexp) name)))
>               (find-file name)
>               (insert name)))))

What is the rationale for the (image-file-name-regexp) exception?

>      (cadd event)))
>   (raise-frame)
>   (recenter))

Why are raise-frame and recenter necessary?

> (defun mac-secondary-dnd-function (event)

Please factor out the commonality between the two functions into an
auxiliary function.

> (global-set-key [shift drag-n-drop] 'mac-secondary-dnd-function)

Does this work?  Shouldn't it be [(shift drag-n-drop)]?


        Stefan


PS: When I ask a question about a piece of code, the answer should typically
    be either to change the code, or to add a comment answering
    the question.

  reply	other threads:[~2005-04-06 11:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-06  0:53 [patch] enhanced mac drag-n-drop Sean O'Rourke
2005-04-06 11:37 ` Stefan Monnier [this message]
2005-04-06 16:17 ` Jan D.
2005-04-06 18:12   ` Sean O'Rourke
2005-04-06 19:22     ` Jan D.
     [not found]     ` <uwtrfsjhv.fsf@jasonrumney.net>
2005-04-07  4:36       ` Jan D.
2005-04-07  6:59         ` Jason Rumney
2005-04-07 13:33           ` Sean O'Rourke
2005-04-07 15:18             ` Jan D.
2005-04-11 19:39           ` Jan D.
2005-04-09 11:00 ` YAMAMOTO Mitsuharu
2005-04-09 13:46   ` Jan D.
2005-04-10  2:03     ` YAMAMOTO Mitsuharu
2005-04-10  5:47       ` Jan D.
2005-04-10 14:42       ` Stefan Monnier
2005-04-11  1:56         ` Richard Stallman
2005-04-11  3:35           ` Stefan Monnier
2005-04-11  9:49             ` YAMAMOTO Mitsuharu
2005-04-11 16:39               ` Stefan Monnier
2005-04-12  8:24                 ` YAMAMOTO Mitsuharu
2005-04-12  2:58             ` Richard Stallman
2005-04-12  3:59               ` Stefan Monnier
2005-04-12 17:24                 ` Richard Stallman
2005-04-11  1:56       ` Richard Stallman

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.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87br8sdu99.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@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.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).