From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Org Remember idea Date: Thu, 08 Nov 2007 03:57:40 +0000 Message-ID: <877iktmlsb.fsf@bzg.ath.cx> References: <3d6808890711060842p3ef89421xc03f0ee87257327@mail.gmail.com> <20071106154907.5d68b019@dhcp-296-6> <874pfyre0g.fsf@bzg.ath.cx> <20071106215944.4f41c434@maggiejean2.rakestrawmornlocal> <87sl3iw86r.fsf@bzg.ath.cx> <20071107161734.6786e2d5@maggiejean2.rakestrawmornlocal> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IpxaX-0001bN-5K for emacs-orgmode@gnu.org; Wed, 07 Nov 2007 21:57:49 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IpxaV-0001aQ-ME for emacs-orgmode@gnu.org; Wed, 07 Nov 2007 21:57:48 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IpxaV-0001aG-FA for emacs-orgmode@gnu.org; Wed, 07 Nov 2007 21:57:47 -0500 Received: from ug-out-1314.google.com ([66.249.92.170]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IpxaU-0007iW-TN for emacs-orgmode@gnu.org; Wed, 07 Nov 2007 21:57:47 -0500 Received: by ug-out-1314.google.com with SMTP id a2so290805ugf for ; Wed, 07 Nov 2007 18:57:45 -0800 (PST) In-Reply-To: <20071107161734.6786e2d5@maggiejean2.rakestrawmornlocal> (John Rakestraw's message of "Wed, 7 Nov 2007 16:17:34 -0500") 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 --=-=-= John Rakestraw writes: > I ask because it would be great to block (and perhaps copy) a section > of a web page, click on the bookmarklet, and then see a template with > the link/title and the section of text that I blocked/copied already > entered. I tried to do that. Here's an updated version of org-annotation-helper. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=org-annotation-helper.el ;;; org-annotation-helper.el --- start remember from a web browser ;; ;; Author: bzg AT altern DOT org ;; Version: 0.2 ;; Keywords: org remember annotation ;; ;;; Commentary: ;; ;; [bzg:] This is an adapted version of the planner-mode extension the ;; was first posted by Geert Kloosterman on ;; the Planner mailing list. All comments below are his. ;; ;; 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 ;; bookmarklets to create the remember:// urls dynamicly. ;; ;; The protocol types currently recognized are: ;; ;; remember:// start `remember' with the url, title and copied text ;; annotation:// put the url and title as a link in the kill-ring ;; ;; The urls used internally will have the following form: ;; ;; remember://%1C[%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='remember://' + location.href + \ ;; '%1C' + escape(document.title) + '%1C' + escape(window.getSelection()) ;; ;; javascript:location.href='annotation://' + location.href + '%1C' + \ ;; escape(document.title) ;; ;; The helper script: ;; ;; #!/bin/sh ;; # org-annotation-helper -- pass a remember-url to emacs ;; # ;; # Author: Geert Kloosterman ;; # Date: Sat Nov 19 22:33:18 2005 ;; ;; if [ -z "$1" ]; then ;; echo "$0: Error: no arguments given!" 1>&2 ;; exit 1 ;; fi ;; ;; # 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 (bzg/org-annotation-helper \"$1\" ) \"\")" ;; ;; # As of Emacs 22 emacsclient will work too ;; emacsclient --eval "(progn (bzg/org-annotation-helper \"$1\" ) nil)" ;; ;; # 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" ;; - the value should be the executable, eg. "org-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: (require 'url) (autoload 'url-unhex-string "url") (defun bzg/org-annotation-helper (info) "Process an externally passed remember:// style url. INFO 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 `org-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 "^\\([^:]*\\):\\(/*\\)\\(.*\\)" info) (let* ((proto (match-string 1 info)) (url_title_region (match-string 3 info)) (splitparts (split-string url_title_region "%1C")) (url (car splitparts)) (type (if (string-match "^\\([a-z]+\\):" url) (match-string 1 url))) (title (cadr splitparts)) (region (url-unhex-string (caddr splitparts))) orglink) (setq title (if (> (length title) 0) (url-unhex-string title))) (setq orglink (org-make-link-string url title)) (org-store-link-props :type type :link url :region region :description title) (setq org-stored-links (cons (list url title) org-stored-links)) ;; FIXME can't access %a in the template -- how to set annotation? (raise-frame) (cond ((equal proto "remember") (kill-new orglink) (org-remember ?f) (yank)) ((equal proto "annotation") (message "Copied '%s' to the kill-ring." orglink) (kill-new orglink)) (t (error "unrecognized org-helper protocol")))) (error "could not parse argument")))) ;;; org-annotation-helper.el ends here --=-=-= The template I used is (?f "* %^{Paste the link}%?\n\n%:region") The bookmarklet: javascript:location.href='remember://' + location.href + '%1C' + \ escape(document.title) + '%1C' + escape(window.getSelection()) This basically add a :region property to the link created by the bookmarklet, :region containing data from window.getSelection() > I don't know whether others will use this functionality. Would be nice to know... I didn't use it a lot myself for now; I can put the file somewhere on the web if needed. -- Bastien --=-=-= 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 --=-=-=--