emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: dmg@uvic.ca
Cc: emacs-orgmode@gnu.org, Richard G Riley <rileyrgdev@googlemail.com>
Subject: Re: firefox urls
Date: Tue, 20 May 2008 16:46:37 -0400	[thread overview]
Message-ID: <19851.1211316397@alphaville.zko.hp.com> (raw)
In-Reply-To: Message from Daniel M German <dmg@uvic.ca> of "Tue, 20 May 2008 10:20:11 PDT." <877idodh9w.fsf@uvic.ca>

Daniel M German <dmg@uvic.ca> 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.

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://<the web page url>::remember::<the title>::remember::<selection>
;;
;; The annotation:// url is similar but there is no <selection> 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) ;; 
;;----------------------------------------------------------------------
;;
;;
;; The handler:
;;
;;----------------------------------------------------------------------
;; #!/bin/sh
;; # org-annotation-helper -- pass a remember-url to emacs
;; #
;; # Author: Geert Kloosterman <g.j.kloosterman@gmail.com>
;; # 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)"
;;----------------------------------------------------------------------
;; 
;;
;; 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.
;;
;; 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.
;;
;;
;; 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!

  reply	other threads:[~2008-05-20 20:48 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 [this message]
2008-05-20 21:49                 ` Daniel M German
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=19851.1211316397@alphaville.zko.hp.com \
    --to=nicholas.dokos@hp.com \
    --cc=dmg@uvic.ca \
    --cc=emacs-orgmode@gnu.org \
    --cc=rileyrgdev@googlemail.com \
    /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).