From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Rakestraw Subject: Re: Org Remember idea Date: Tue, 6 Nov 2007 15:49:07 -0500 Message-ID: <20071106154907.5d68b019@dhcp-296-6> References: <3d6808890711060842p3ef89421xc03f0ee87257327@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1990048312==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IpUQa-0002eP-HA for emacs-orgmode@gnu.org; Tue, 06 Nov 2007 14:49:36 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IpUQY-0002bi-SY for emacs-orgmode@gnu.org; Tue, 06 Nov 2007 14:49:36 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IpUQY-0002be-Q4 for emacs-orgmode@gnu.org; Tue, 06 Nov 2007 14:49:34 -0500 Received: from relay02.pair.com ([209.68.5.16]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1IpUQY-0000Gz-6P for emacs-orgmode@gnu.org; Tue, 06 Nov 2007 14:49:34 -0500 In-Reply-To: <3d6808890711060842p3ef89421xc03f0ee87257327@mail.gmail.com> 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 --===============1990048312== Content-Type: multipart/signed; boundary="Sig_/bOri+MZbjWCI5uZR9Kle5y9"; protocol="application/pgp-signature"; micalg=PGP-SHA1 --Sig_/bOri+MZbjWCI5uZR9Kle5y9 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable > I've started using Remember mode more and more, and it has given me an > idea for new piece of functionality. >=20 > %c - insert clipboard/kill-ring at point >=20 > This is for 'auto' pasting links or snippets of text from my browser > into an org file. >=20 I used planner mode for a while before switching to org mode, and still occasionally look in on planner to see what they're doing. A couple of weeks ago I stumbled on this in the list planner-el-discuss: > Ever wanted to create a planner annotation or start remember directly > from within an external web browser, say Firefox? Here's how I do it. >=20 > I've registered special protocol handlers in the browser, > "remember://" and "annotation://". I've configured these handlers to > call a script that passes the information to a running Emacs session > using emacsclient/gnuclient. The remember/annotation handlers are > invoked through bookmarklets (bookmarks which execute JavaScript > code). >=20 > The "remember://" protocol starts M-x remember with a planner link for > the current website filled in, using the document title as the > description of the link, just like planner-w3m does. >=20 > The "annotation://" protocol handler works similar to > `planner-annotation-as-kill': it puts a planner link in the kill ring. I would really like to have something like this for org. The poster actually included the lisp code, the browser protocols, and the script that did all this. I know next to nothing about lisp so was unable to do anything with it, but is it possible that it could be easy for someone who knows this stuff to adapt it to org? In hopes that someone will look at it, I've posted the code below. Apologies for the length of the post. --John ;;; gjk-planner-annotation-helper.el --- start remember from a web browser ;; Author: Geert Kloosterman ;; Created: Sat Nov 19 22:33:18 2005 ;; Updated: Thu Oct 25 17:48:41 2007 ;; Keywords: planner remember ;;; Commentary: ;; We want to be able to pass a URL and document title directly from a ;; web browser to Emacs. ;; ;; We define a remember:// url handler in the browser and use a shell ;; script to handle the protocol. This script passes the information ;; to a running Emacs process (using emacsclient/gnuclient). We use=20 ;; bookmarklets to create the remember:// urls dynamicly. ;; ;; The protocol types currently recognized are: ;;=20 ;; remember:// start `remember' with the url and title filled in ;; annotation:// similar to `planner-annotation-as-kill'. ;; ;; The urls used internally will have the following form: ;; ;; remember://%1C ;; ;; The title will be url-hex-encoded. "%1C" is the (url-encoded) low ;; ascii value for the field separator. ;; ;; The bookmarklets: ;; ;; javascript:location.href=3D'remember://' + location.href + '%1C' + escape(document.title) ;; javascript:location.href=3D'annotation://' + location.href + '%1C' + escape(document.title) ;; The helper script: ;; ;; #!/bin/sh ;; # planner-annotation-helper -- pass a remember-url to emacs ;; # ;; # Author: Geert Kloosterman ;; # Date: Sat Nov 19 22:33:18 2005 ;;=20 ;; if [ -z "$1" ]; then ;; echo "$0: Error: no arguments given!" 1>&2 ;; exit 1 ;; fi ;;=20 ;; # For years I've been using Martin Schwenke's dtemacs script to start ;; # Emacs. The script uses gnuclient to connect to Emacs and starts a ;; # new Emacs process when necessary. ;; # See http://www.meltin.net/hacks/emacs/ ;; # ;; # dtemacs -batch -eval "(progn (gjk/planner-annotation-helper \"$1\" ) \"\")" ;;=20 ;; # As of Emacs 22 emacsclient will work too ;; emacsclient --eval "(progn (gjk/planner-annotation-helper \"$1\" ) nil)" ;;=20 ;; # EOF ;; Adding a protocol handler ;; ------------------------- ;; ;; Firefox ;; ;; To add a protocol handler (eg: remember://) in Firefox, take the ;; following steps: ;; ;; - type in "about:config" in the location bar ;; - right click, select New --> String ;; - the name should be "network.protocol-handler.app.remember"=20 ;; - the value should be the executable, eg. "planner-annotation-helper". ;; At least under Linux this does not need to be the full path to ;; the executable. ;; ;; See http://kb.mozillazine.org/Register_protocol for more details. ;; ;; Opera ;; ;; In Opera add the protocol in the Preferences->Advanced->Programs ;; dialog. ;;; Code: (autoload 'url-unhex-string "url") (defun gjk/planner-annotation-helper (urlstring) """Process an externally passed remember:// style url. URLSTRING consists of a protocol part and a url and title, separated by %1C. The protocol types currently recognized are: remember:// start `remember' with the url and title annotation:// similar to `planner-annotation-as-kill'. """ (let ((remember-annotation-functions nil)) ;; The `parse-url' functions break on the embedded url, ;; since our format is fixed we'll split the url ourselves. (if (string-match "^\\([^:]*\\):\\(/*\\)\\(.*\\)" urlstring) (let* ((proto (match-string 1 urlstring)) (url+title (match-string 3 urlstring)) (splitparts (split-string url+title "%1C")) (url (car splitparts)) (title (cadr splitparts)) plannerlink) =20 (setq title (if (> (length title) 0) (url-unhex-string title))) (setq plannerlink (planner-make-link url title t)) (raise-frame) (cond ((equal proto "remember") (remember (concat "\n\n" plannerlink))) ((equal proto "annotation") (message "Copied '%s' to the kill-ring." plannerlink) (kill-new plannerlink)) (t=20 (error "unrecognized planner-helper protocol")))) (error "could not parse argument")))) ;;; planner-annotation-helper.el ends here --Sig_/bOri+MZbjWCI5uZR9Kle5y9 Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFHMNNDuxnwM8FPA34RAlEbAJ4iL10Rvy6OGB/1jCkbojjVzoYKIQCglDy5 n7dxD81Nn08CGTcE9vrEtUI= =YpcK -----END PGP SIGNATURE----- --Sig_/bOri+MZbjWCI5uZR9Kle5y9-- --===============1990048312== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============1990048312==--