emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Daniel M German <dmg@uvic.ca>
To: emacs-orgmode@gnu.org
Subject: Re: firefox urls
Date: Tue, 20 May 2008 14:49:39 -0700	[thread overview]
Message-ID: <87skwcbq8c.fsf@uvic.ca> (raw)
In-Reply-To: <19851.1211316397@alphaville.zko.hp.com> (Nick Dokos's message of "Tue, 20 May 2008 16:46:37 -0400")



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 <g.j.kloosterman@gmail.com>
 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 .

  reply	other threads:[~2008-05-20 21:50 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-12 15:22 firefox urls Richard G Riley
2008-05-12 15:33 ` John Rakestraw
2008-05-14  4:12   ` Daniel M German
2008-05-14  4:30     ` Carsten Dominik
2008-05-14 16:57     ` John Rakestraw
     [not found]     ` <871w44wlgz.fsf@uvic.ca>
2008-05-18  1:27       ` Alan E. Davis
2008-05-18  5:43         ` Daniel M German
2008-05-20 17:03           ` Richard G Riley
2008-05-20 17:20             ` Daniel M German
2008-05-20 20:46               ` Nick Dokos
2008-05-20 21:49                 ` Daniel M German [this message]
2008-05-21  1:49                 ` John Rakestraw
2008-05-21  5:28                   ` Carsten Dominik
2008-05-21 11:06                     ` Richard G Riley
2008-05-21 15:44                       ` John Rakestraw
2008-05-21 16:10                         ` Nick Dokos
2008-05-23 23:28                           ` Daniel M German
     [not found]                             ` <7bef1f890805232005s4755106eg2c928029e6db1767@mail.gmail.com>
2008-05-24  3:08                               ` Fwd: " Alan E. Davis
2008-05-24  3:14                             ` Alan E. Davis
2008-05-24  3:20                               ` Alan E. Davis
     [not found]                               ` <87r6bsmle5.fsf@uvic.ca>
2008-05-24  5:18                                 ` Alan E. Davis
2008-05-21 14:55                     ` John Rakestraw
2008-05-21 15:05                     ` Daniel M German
2008-05-21 14:58                   ` Nick Dokos
2008-05-21 10:51                 ` Richard G Riley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87skwcbq8c.fsf@uvic.ca \
    --to=dmg@uvic.ca \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).