[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] firefox urls
From: |
Daniel M German |
Subject: |
Re: [Orgmode] firefox urls |
Date: |
Tue, 20 May 2008 14:49:39 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
Thanks Nick,
Nick> Step 1 (and Daniel, in the mail above) talks about the "remember"
Nick> script, while the script itself and Step 3 talk about the
Nick> "org-annotation-helper" script.
I agree. The nomenclature is not the best.
Nick> Here is an attempt at clarification: it's mostly minor edits but there
Nick> are enough of them that I thought I'd send out the whole thing rather
Nick> than a patch. It is still very much oriented towards Linux.
it works also under OS X.
Nick> However, I have problems with how the remember template works, so the
Nick> description below is fuzzy, perhaps incomplete, perhaps wrong.
Perhaps the solution is to split the command line script and the elisp into
different files. And provide a shortcut create to the boorkmarklet via a
web page.
Nick> With this caveat, Richard, can you try these steps out and see if they
Nick> work/make sense? If this is deemed OK, then maybe it can replace the
Nick> comment section in org-annotation-helper.el, after the requisite
additions/
Nick> corrections/deletions are made.
Nick> Regards,
Nick> Nick
Nick>
---------------------------------------------------------------------------
Nick> [Debugging notes - skip ahead if not interested]
Nick> Assuming I have defined a remember template like this:
(?w "* %u %c \n\n%i" "~/lib/org/bookmarks.org" "Web links")
Nick> when bzg/org-annotation-helper calls org-remember with argument ?w, I
Nick> expect this template to pop up in a *Remember* buffer. Instead, I get
Nick> asked which template I want to use (I have three more templates in
Nick> org-remember-templates). When I say "w" and force the choice, the
Nick> contents of the buffer are not what I expect: I get the time stamp from
Nick> %u, and the link from %c, but *not* the selection from %i. I uncommented
Nick> the echo in the script and the browser is passing the selection to the
Nick> script correctly. I also single-stepped through
Nick> bzg/org-annotation-helper, which sets the :region property of the link
Nick> to the selection like so:
Nick> (org-store-link-props :type type
Nick> :link url
Nick> :region region
Nick> :description title)
Nick> but somehow that seems to get dropped on the floor afterwards. Maybe a
Nick> bug in org-remember? I 'm under the (possibly erroneous?) impression
Nick> that we should be going through the if-true path of the following code
Nick> 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)
Nick> ?---> (progn
Nick> (when (< (length org-remember-templates) 2)
Nick> (error "No other template available"))
Nick> (erase-buffer)
Nick> (let ((annotation (plist-get org-store-link-plist :annotation))
Nick> (initial (plist-get org-store-link-plist :initial)))
Nick> (org-remember-apply-template))
Nick> (message "Press C-c C-c to remember data"))
(if (org-region-active-p)
Nick> (org-do-remember (buffer-substring (point) (mark)))
Nick> (org-do-remember))))))
Nick> but org-finish-function is nil in this case, so we fall through to the
Nick> org-do-remember at the end.
Nick> [end of debugging notes]
Nick>
---------------------------------------------------------------------------
Nick> ;; We want to be able to pass a URL and document title directly from a
Nick> ;; web browser to Emacs.
Nick> ;;
Nick> ;; We define a remember:// url handler in the browser and use a shell
Nick> ;; script to handle the protocol. This script passes the information
Nick> ;; to a running Emacs process (using emacsclient/gnuclient). We use
Nick> ;; bookmarklets to create the remember:// urls dynamically.
Nick> ;;
Nick> ;; The protocol types currently recognized are:
Nick> ;;
Nick> ;; remember:// start `remember' with the url and title filled in
Nick> ;; annotation:// similar to `planner-annotation-as-kill' (org?)
Nick> ;;
Nick> ;; The urls used internally will have the following form:
Nick> ;;
Nick> ;; remember://<the web page url>::remember::<the
title>::remember::<selection>
Nick> ;;
Nick> ;; The annotation:// url is similar but there is no <selection>
associated
Nick> ;; with it.
Nick> ;;
Nick> ;; The web page url and the title will be url-hex-encoded.
Nick> ;;
Nick> ;;
Nick> ;; The bookmarklets:
Nick> ;;
Nick> ;;----------------------------------------------------------------------
Nick> ;; javascript:location.href='remember://' + location.href + \
Nick> ;; '::remember::' + escape(document.title) + '::remember::' +
escape(window.getSelection())
Nick> ;;----------------------------------------------------------------------
Nick> ;; javascript:location.href='annotation://' + location.href +
'::remember::' +\
Nick> ;; escape(document.title) ;;
Nick> ;;----------------------------------------------------------------------
Nick> ;;
Nick> ;;
Nick> ;; The handler:
Nick> ;;
Nick> ;;----------------------------------------------------------------------
Nick> ;; #!/bin/sh
Nick> ;; # org-annotation-helper -- pass a remember-url to emacs
Nick> ;; #
Nick> ;; # Author: Geert Kloosterman <address@hidden>
Nick> ;; # Date: Sat Nov 19 22:33:18 2005
Nick> ;;
Nick> ;; if [ -z "$1" ]; then
Nick> ;; echo "$0: Error: no arguments given!" 1>&2
Nick> ;; exit 1
Nick> ;; fi
Nick> ;;
Nick> ;; # To test uncomment following line
Nick> ;; #echo $1 >> /tmp/remember.out
Nick> ;;
Nick> ;; emacsclient --eval "(progn (bzg/org-annotation-helper \"$1\" ) nil)"
Nick> ;;----------------------------------------------------------------------
Nick> ;;
Nick> ;;
Nick> ;; To install:
Nick> ;;
Nick> ;; Step 0: Install this module.
Nick> ;;
Nick> ;; * Install this file and require it in your .emacs (or wherever you
Nick> ;; want to do it)
Nick> ;;
Nick> ;; (require 'org-annotation-helper)
Nick> ;;
Nick> ;;
Nick> ;; Step 1: Install the org-annotation-helper shell script.
Nick> ;;
Nick> ;; * Save the handler as a script, and make sure it is executable. In
Nick> ;; the following, we assume that it has been saved under the name
Nick> ;; "org-annotation-helper" in some directory in your $PATH.
Nick> ;;
Nick> ;; * Try it: Make sure emacs is running and you have started its server
Nick> ;; mode (server-start). Run this command from the command line:
Nick> ;;
Nick> ;; org-annotation-helper
'remember://http%3A//orgmode.org/::remember::Org-Mode%20Homepage::remember::Notes'
Nick> ;;
Nick> ;; Emacs should now show a remember window. If you have set up a
Nick> ;; remember template for this case, e.g. a template similar to the
Nick> ;; one in Step 4 below, the remember window will show a link to the
Nick> ;; orgmode.org site with the name "Org-Mode Homepage", with "Notes"
Nick> ;; added as initial content (XXX - this doesn't work?). Otherwise,
Nick> ;; you can insert the link with org-insert-link (commonly bound to
Nick> ;; C-c C-l).
Nick> ;;
Nick> ;;
Nick> ;; Step 2: add two bookmarklets to the browser.
Nick> ;;
Nick> ;; For Firefox:
Nick> ;;
Nick> ;; * Right click on the bookmarks area of Firefox.
Nick> ;; * Select "New Bookmark".
Nick> ;; * In the Location field, fill the javascript code above (the
bookmarklet).
Nick> ;; * Make sure "Load this bookmark in the sidebar" is deselected.
Nick> ;;
Nick> ;; Try it. You should have now a url that starts with "remember://"
Nick> ;; and your browser will not know what do to with it.
Nick> ;;
Nick> ;;
Nick> ;; Step 3: Add the handler for the "remember://" URI.
Nick> ;;
Nick> ;; For Firefox:
Nick> ;;
Nick> ;; To add a protocol handler (eg: remember://) in Firefox, take the
Nick> ;; following steps:
Nick> ;;
Nick> ;; * Type in "about:config" in the location bar.
Nick> ;; * Right click and from the drop-down menu, select New --> String.
Nick> ;; * The Preference Name should be
"network.protocol-handler.app.remember".
Nick> ;; * The Value should be the name of the executable shell script (see
Nick> ;; Step 1 above, where we called it "org-annotation-helper"). At
Nick> ;; least under Linux, this does not need to be the full path to the
Nick> ;; executable.
Nick> ;;
Nick> ;; See http://kb.mozillazine.org/Register_protocol for more details.
Nick> ;;
Nick> ;; For Opera:
Nick> ;;
Nick> ;; Add the protocol in the Preferences->Advanced->Programs
Nick> ;; dialog.
Nick> ;;
Nick> ;;
Nick> ;; Step 4: Configure a template.
Nick> ;;
Nick> ;; I personally use the following template for this mode
Nick> ;;
Nick> ;; (?w "* %u %c \n\n%i" "~/working/trunk/org/bookmarks.org" "Web
links")
Nick> ;;
Nick> ;; %c will be replaced with the hyperlink to the page, displaying the
Nick> ;; title of the page.
Nick> ;; %i will be replaced with the selected text from the browser.
Nick> ;;
Nick> ;; By default the new remember notes are placed in the bookmarks.org
Nick> ;; file under the "Web links" section, but it can be easily overriden
Nick> ;; with C-u C-c C-c.
Nick> ;;
Nick> ;; Step 5:
Nick> ;; Enjoy!
--
--
Daniel M. German
http://turingmachine.org/
http://silvernegative.com/
dmg (at) uvic (dot) ca
replace (at) with @ and (dot) with .
- Re: [Orgmode] firefox urls, (continued)
- Re: [Orgmode] firefox urls, John Rakestraw, 2008/05/12
- Re: [Orgmode] firefox urls, Daniel M German, 2008/05/14
- Re: [Orgmode] firefox urls, Carsten Dominik, 2008/05/14
- Re: [Orgmode] firefox urls, John Rakestraw, 2008/05/14
- Re: [Orgmode] firefox urls, Daniel M German, 2008/05/14
- Re: [Orgmode] firefox urls, Alan E. Davis, 2008/05/17
- Re: [Orgmode] firefox urls, Daniel M German, 2008/05/18
- Re: [Orgmode] firefox urls, Richard G Riley, 2008/05/20
- Re: [Orgmode] firefox urls, Daniel M German, 2008/05/20
- Re: [Orgmode] firefox urls, Nick Dokos, 2008/05/20
- Re: [Orgmode] firefox urls,
Daniel M German <=
- Re: [Orgmode] firefox urls, John Rakestraw, 2008/05/20
- Re: [Orgmode] firefox urls, Carsten Dominik, 2008/05/21
- Re: [Orgmode] firefox urls, Richard G Riley, 2008/05/21
- Re: [Orgmode] firefox urls, John Rakestraw, 2008/05/21
- Re: [Orgmode] firefox urls, Nick Dokos, 2008/05/21
- Re: [Orgmode] firefox urls, Daniel M German, 2008/05/23
- Message not available
- Fwd: [Orgmode] firefox urls, Alan E. Davis, 2008/05/23
- Re: [Orgmode] firefox urls, Alan E. Davis, 2008/05/23
- Re: [Orgmode] firefox urls, Alan E. Davis, 2008/05/23
- Message not available
- Re: [Orgmode] firefox urls, Alan E. Davis, 2008/05/24