From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard G Riley Subject: Re: firefox urls Date: Wed, 21 May 2008 12:51:17 +0200 Message-ID: References: <20080512113321.45188d4b@dhcp-296-6> <87k5hxa5ia.fsf@uvic.ca> <871w44wlgz.fsf@uvic.ca> <7bef1f890805171827w40525d0fi95b7e9d31400ac96@mail.gmail.com> <87wslsgoai.fsf@uvic.ca> <3ziqx86h7a.fsf@richardriley.net> <877idodh9w.fsf@uvic.ca> <19851.1211316397@alphaville.zko.hp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jylum-0006Nd-HA for emacs-orgmode@gnu.org; Wed, 21 May 2008 06:51:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jylul-0006NQ-K8 for emacs-orgmode@gnu.org; Wed, 21 May 2008 06:51:24 -0400 Received: from [199.232.76.173] (port=40712 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jylul-0006NN-Gr for emacs-orgmode@gnu.org; Wed, 21 May 2008 06:51:23 -0400 Received: from gv-out-0910.google.com ([216.239.58.187]:49511) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jyluk-0005NP-RC for emacs-orgmode@gnu.org; Wed, 21 May 2008 06:51:23 -0400 Received: by gv-out-0910.google.com with SMTP id i36so660793gve.17 for ; Wed, 21 May 2008 03:51:21 -0700 (PDT) In-Reply-To: <19851.1211316397@alphaville.zko.hp.com> (Nick Dokos's message of "Tue, 20 May 2008 16:46:37 -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: nicholas.dokos@hp.com Cc: emacs-orgmode@gnu.org, Richard G Riley , dmg@uvic.ca Nick Dokos writes: > Daniel M German wrote: > >> >> >> >> Hi Alan, >> >> >> >> Did you download the file as I indicated in my previous message? It has >> >> detailed instructions on how to get all the pieces working. >> >> >> >> --dmg >> >> Richard> I followed the instructions but I cant get it working. >> >> Richard> Are the instructions for adding 2 bookmarklets lacking since >> Richard> it only really describes remember protocol? (Step 2). >> >> Richard> Step 3 only mentioned the remember handler. Should there also be an >> Richard> annotate handler? >> >> >> Start by doing remember first. Are you able to get the remember command >> line script (what I call the handler) working? Try it from the command >> line. >> >> I suspect your javascript bookmarklet is not passing the info of the >> page correctly. I would double check that first. >> >> --dmg >> >> >> Richard> I dont think I did anything too silly and wonder if anyone else managed >> Richard> to install this properly? Currently when I click on the remember >> Richard> bookmarklet the pane empties and emacs prompts me for a template type >> Richard> but then does not insert the link. It just inserts "about:blank" as the >> Richard> link. >> > > I think part of the problem is that the comments are inconsistent: > > Step 1 (and Daniel, in the mail above) talks about the "remember" > script, while the script itself and Step 3 talk about the > "org-annotation-helper" script. > > Here is an attempt at clarification: it's mostly minor edits but there > are enough of them that I thought I'd send out the whole thing rather > than a patch. It is still very much oriented towards Linux. > > However, I have problems with how the remember template works, so the > description below is fuzzy, perhaps incomplete, perhaps wrong. I still get prompted for a template type. Is there no way for the bookmark code to auto select a "Bookmarks" template type? > > With this caveat, Richard, can you try these steps out and see if they > work/make sense? If this is deemed OK, then maybe it can replace the > comment section in org-annotation-helper.el, after the requisite additions/ > corrections/deletions are made. > > Regards, > Nick > > --------------------------------------------------------------------------- > [Debugging notes - skip ahead if not interested] > > Assuming I have defined a remember template like this: > > (?w "* %u %c \n\n%i" "~/lib/org/bookmarks.org" "Web links") > > when bzg/org-annotation-helper calls org-remember with argument ?w, I > expect this template to pop up in a *Remember* buffer. Instead, I get > asked which template I want to use (I have three more templates in > org-remember-templates). When I say "w" and force the choice, the > contents of the buffer are not what I expect: I get the time stamp from > %u, and the link from %c, but *not* the selection from %i. I uncommented > the echo in the script and the browser is passing the selection to the > script correctly. I also single-stepped through > bzg/org-annotation-helper, which sets the :region property of the link > to the selection like so: > > (org-store-link-props :type type > :link url > :region region > :description title) > > but somehow that seems to get dropped on the floor afterwards. Maybe a > bug in org-remember? I 'm under the (possibly erroneous?) impression > that we should be going through the if-true path of the following code > in org-remember (as shown by the arrow): > > ... > ;; `org-select-remember-template' > (setq org-select-template-temp-major-mode major-mode) > (setq org-select-template-original-buffer (current-buffer)) > (if (eq org-finish-function 'org-remember-finalize) > ?---> (progn > (when (< (length org-remember-templates) 2) > (error "No other template available")) > (erase-buffer) > (let ((annotation (plist-get org-store-link-plist :annotation)) > (initial (plist-get org-store-link-plist :initial))) > (org-remember-apply-template)) > (message "Press C-c C-c to remember data")) > (if (org-region-active-p) > (org-do-remember (buffer-substring (point) (mark))) > (org-do-remember)))))) > > but org-finish-function is nil in this case, so we fall through to the > org-do-remember at the end. > > [end of debugging notes] > --------------------------------------------------------------------------- > > ;; 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 dynamically. > ;; > ;; The protocol types currently recognized are: > ;; > ;; remember:// start `remember' with the url and title filled in > ;; annotation:// similar to `planner-annotation-as-kill' (org?) > ;; > ;; The urls used internally will have the following form: > ;; > ;; remember://::remember::::remember:: > ;; > ;; The annotation:// url is similar but there is no associated > ;; with it. > ;; > ;; The web page url and the title will be url-hex-encoded. > ;; > ;; > ;; The bookmarklets: > ;; > ;;---------------------------------------------------------------------- > ;; javascript:location.href='remember://' + location.href + \ > ;; '::remember::' + escape(document.title) + '::remember::' + escape(window.getSelection()) > ;;---------------------------------------------------------------------- > ;; javascript:location.href='annotation://' + location.href + '::remember::' +\ > ;; escape(document.title) ;; > ;;---------------------------------------------------------------------- Two of them - only one mentioned below. There is still no comment as to what "annotate" actually means. Could I also suggest for the non "codey" types that the code is kept on a single like to avoid the need to paste into a seperate buffer and rejoin the code before pasting it into the single line firefox properties dialog. > ;; > ;; > ;; The handler: > ;; > ;;---------------------------------------------------------------------- > ;; #!/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 > ;; > ;; # To test uncomment following line > ;; #echo $1 >> /tmp/remember.out > ;; > ;; emacsclient --eval "(progn (bzg/org-annotation-helper \"$1\" ) > nil)" Works ok from command line. > ;;---------------------------------------------------------------------- > ;; > ;; > ;; To install: > ;; > ;; Step 0: Install this module. > ;; > ;; * Install this file and require it in your .emacs (or wherever you > ;; want to do it) > ;; > ;; (require 'org-annotation-helper) > ;; > ;; > ;; Step 1: Install the org-annotation-helper shell script. > ;; > ;; * Save the handler as a script, and make sure it is executable. In > ;; the following, we assume that it has been saved under the name > ;; "org-annotation-helper" in some directory in your $PATH. > ;; > ;; * Try it: Make sure emacs is running and you have started its server > ;; mode (server-start). Run this command from the command line: > ;; > ;; org-annotation-helper 'remember://http%3A//orgmode.org/::remember::Org-Mode%20Homepage::remember::Notes' > ;; > ;; Emacs should now show a remember window. If you have set up a > ;; remember template for this case, e.g. a template similar to the > ;; one in Step 4 below, the remember window will show a link to the > ;; orgmode.org site with the name "Org-Mode Homepage", with "Notes" > ;; added as initial content (XXX - this doesn't work?). Otherwise, > ;; you can insert the link with org-insert-link (commonly bound to > ;; C-c C-l). > ;; > ;; > ;; Step 2: add two bookmarklets to the browser. Only one described, maybe better to describe both. > ;; > ;; For Firefox: > ;; > ;; * Right click on the bookmarks area of Firefox. > ;; * Select "New Bookmark". > ;; * In the Location field, fill the javascript code above (the bookmarklet). > ;; * Make sure "Load this bookmark in the sidebar" is deselected. > ;; > ;; Try it. You should have now a url that starts with "remember://" > ;; and your browser will not know what do to with it. "The bookmark now references a url type of remember. We now tell the browser what to do with it:" > ;; > ;; > ;; Step 3: Add the handler for the "remember://" URI. > ;; > ;; For Firefox: > ;; > ;; To add a protocol handler (eg: remember://) in Firefox, take the > ;; following steps: > ;; > ;; * Type in "about:config" in the location bar. > ;; * Right click and from the drop-down menu, select New --> String. > ;; * The Preference Name should be "network.protocol-handler.app.remember". > ;; * The Value should be the name of the executable shell script (see > ;; Step 1 above, where we called it "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. > ;; > ;; For Opera: > ;; > ;; Add the protocol in the Preferences->Advanced->Programs > ;; dialog. > ;; > ;; > ;; Step 4: Configure a template. > ;; > ;; I personally use the following template for this mode > ;; > ;; (?w "* %u %c \n\n%i" "~/working/trunk/org/bookmarks.org" "Web links") > ;; > ;; %c will be replaced with the hyperlink to the page, displaying the > ;; title of the page. > ;; %i will be replaced with the selected text from the browser. > ;; > ;; By default the new remember notes are placed in the bookmarks.org > ;; file under the "Web links" section, but it can be easily overriden > ;; with C-u C-c C-c. > ;; > ;; Step 5: > ;; Enjoy! Unfortunately when running from iceweasel under Debian I am sill being prompted for a template and then I'm still getting about:blank as the link inserted into the title. It might be useful to add that adding location of org-annotation-helper (is this a misnomer as I am a tad confused as to remember and annotate here) to .gnomerc is important for desktop apps. I guess it can also be added to an emacs shell path?