From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Lander Subject: [PATCH] add firefox/vimperator support to contrib/lisp/org-mac-link-grabber.el Date: Thu, 1 Jul 2010 11:20:15 -0400 Message-ID: <5BF8BAAB-4371-4AC3-BDB6-54E4F745B9D7@yahoo.com> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: multipart/mixed; boundary=Apple-Mail-38--957295067 Return-path: Received: from [140.186.70.92] (port=47534 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OULYu-0007ez-1d for emacs-orgmode@gnu.org; Thu, 01 Jul 2010 11:20:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OULYs-0006pZ-FW for emacs-orgmode@gnu.org; Thu, 01 Jul 2010 11:20:23 -0400 Received: from smtp103.prem.mail.ac4.yahoo.com ([76.13.13.42]:27262) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OULYs-0006pE-BZ for emacs-orgmode@gnu.org; Thu, 01 Jul 2010 11:20:22 -0400 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 Mode --Apple-Mail-38--957295067 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit This patch adds a new option, [v]imperator, to the org-mac-link- grabber menu. Use this to grab links from Firefox running the Vimperator plugin. Code by Michael Kohl (http://github.com/citizen428). --Apple-Mail-38--957295067 Content-Disposition: attachment; filename=org-mac-link-grabber-vimperator-patch.txt Content-Type: text/plain; x-unix-mode=0644; name="org-mac-link-grabber-vimperator-patch.txt" Content-Transfer-Encoding: quoted-printable diff --git a/contrib/lisp/org-mac-link-grabber.el = b/contrib/lisp/org-mac-link-grabber.el index bb12204..8ec428b 100644 --- a/contrib/lisp/org-mac-link-grabber.el +++ b/contrib/lisp/org-mac-link-grabber.el @@ -4,7 +4,7 @@ ;; Copyright (c) 2010 Free Software Foundation, Inc. ;;=20 ;; Author: Anthony Lander -;; Version: 1.0 +;; Version: 1.0.1 ;; Keywords: org, mac, hyperlink ;; ;; This program is free software; you can redistribute it and/or modify @@ -39,6 +39,7 @@ ;; Mail.app - grab links to the selected messages in the message list ;; AddressBook.app - Grab links to the selected addressbook Cards ;; Firefox.app - Grab the url of the frontmost tab in the frontmost = window +;; Vimperator/Firefox.app - Grab the url of the frontmost tab in the = frontmost window ;; Safari.app - Grab the url of the frontmost tab in the frontmost = window ;; Google Chrome.app - Grab the url of the frontmost tab in the = frontmost window ;; Together.app - Grab links to the selected items in the library list @@ -108,6 +109,12 @@ applications and inserting them in org documents" :group 'org-mac-link-grabber :type 'boolean) =20 +(defcustom org-mac-grab-Firefox+Vimperator-p nil + "Enable menu option [v]imperator to grab links from Firefox.app = running the Vimperator plugin" + :tag "Grab Vimperator/Firefox.app links" + :group 'org-mac-link-grabber + :type 'boolean) + (defcustom org-mac-grab-Chrome-app-p t "Enable menu option [f]irefox to grab links from Google Chrome.app" :tag "Grab Google Chrome.app links" @@ -129,6 +136,7 @@ applications and inserting them in org documents" ("a" "ddressbook" = org-mac-addressbook-insert-selected ,org-mac-grab-Addressbook-app-p) ("s" "afari" = org-mac-safari-insert-frontmost-url ,org-mac-grab-Safari-app-p) ("f" "irefox" = org-mac-firefox-insert-frontmost-url ,org-mac-grab-Firefox-app-p) + ("v" "imperator" = org-mac-vimperator-insert-frontmost-url = ,org-mac-grab-Firefox+Vimperator-p) ("c" "hrome" = org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p) ("t" "ogether" = org-mac-together-insert-selected ,org-mac-grab-Together-app-p))) (menu-string (make-string 0 ?x)) @@ -232,6 +240,51 @@ applications and inserting them in org documents" (insert (org-mac-firefox-get-frontmost-url))) =20 =0C +;; Handle links from Google Firefox.app running the Vimperator = extension +;; Grab the frontmost url from Firefox+Vimperator. Same limitations are +;; Firefox + +(defun as-mac-vimperator-get-frontmost-url () + (let ((result (do-applescript + (concat + "set oldClipboard to the = clipboard\n" + "set frontmostApplication to = path to frontmost application\n" + "tell application = \"Firefox\"\n" + " activate\n" + " delay 0.15\n" + " tell application = \"System Events\"\n" + " keystroke = \"y\"\n" + " end tell\n" + " delay 0.15\n" + " set theUrl to the = clipboard\n" + " set the clipboard to = oldClipboard\n" + " set theResult to (get = theUrl) & \"::split::\" & (get name of window 1)\n" + "end tell\n" + "activate application = (frontmostApplication as text)\n" + "set links to {}\n" + "copy theResult to the end of = links\n" + "return links as string\n")))) + (replace-regexp-in-string "\s+-\s+Vimperator" "" (car (split-string = result "[\r\n]+" t))))) + + +(defun org-mac-vimperator-get-frontmost-url () + (interactive) + (message "Applescript: Getting Vimperator url...") + (let* ((url-and-title (as-mac-vimperator-get-frontmost-url)) + (split-link (split-string url-and-title "::split::")) + (URL (car split-link)) + (description (cadr split-link)) + (org-link)) + (when (not (string=3D URL "")) + (setq org-link (org-make-link-string URL description))) + (kill-new org-link) + org-link)) + +(defun org-mac-vimperator-insert-frontmost-url () + (interactive) + (insert (org-mac-vimperator-get-frontmost-url))) + +=0C ;; Handle links from Google Chrome.app ;; Grab the frontmost url from Google Chrome. Same limitations are ;; Firefox because Chrome doesn't publish an Applescript dictionary --Apple-Mail-38--957295067 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit --Apple-Mail-38--957295067 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --Apple-Mail-38--957295067--