emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* OT: remember'ing from other programs with stumpwm
@ 2007-07-05  5:39 Dmitri Minaev
  2007-07-05 12:17 ` Nikos Apostolakis
  2007-07-05 18:45 ` Scott Jaderholm
  0 siblings, 2 replies; 8+ messages in thread
From: Dmitri Minaev @ 2007-07-05  5:39 UTC (permalink / raw)
  To: emacs-orgmode

Sorry for off-topic, but in the absence of stumpwm-users list, this
place is just as good as any other :)

The ability of remember-mode to store notes with links to other
buffers is great, but I always wanted to use it to store clips from
other programs, especially Firefox and Thunderbird. I do use gnus
sometimes, but I'm not proficient enough with it. At last, I installed
stumpwm window manager. After some tries and crashes, I can now select
a part of a web page in Firefox, press one key and it is pasted into a
new remember buffer. The result is like this:

* Pasted clips
** Thu Jul  5 09:36:38 2007 (eon - Mozilla Firefox)
   eon - Mozilla Firefox
   Eon is a rich content linking/annotation mechanism with multiple
   interface styles. Its primitives may be combined with each other and
   with other emacs modules to produce a variety of behaviors similar to
   the features of the above-mentioned packages.
** Thu Jul  5 10:06:17 2007 (Roman Empire: gold standard of
immigration - Los Angeles Tim)
   Roman Empire: gold standard of immigration - Los Angeles Times -
   Mozilla Firefox
   There's a widespread view that the Roman Empire was swept away mainly
   by a relentless tide of hostile outsiders; we've all heard ugly
   references to the "barbarian hordes" in today's immigration
   debates. But the truth is that Rome was the world's most successful
   multiethnic state until our own \u2014 and history's longest lasting
   one, bar none.

   So it's natural to wonder if the Romans might have anything to teach
   Americans. I'd argue that they do. One lesson is that the notion of
   "taking control of the borders" is overrated; borders were pliable
   then, and are even harder to define (or police) now. A second lesson
   is the importance of nurturing a national culture. It was the source
   of Rome's power, just as it is the source of ours.

Obviously, one thing is missing here -- the URL. Unfortunately, I
couldn't find a way to retrieve it from Firefox programmatically.
Anyway, in most occasions, it is enough to just select the URL in the
address bar and to paste it into the remember buffer with some
comments. After all, the window title often contains all the
information I need, like here:

** Thu Jul  5 10:06:40 2007 (Chinese archaeologists locate sunken ship
laden with Ming Dy)
   Chinese archaeologists locate sunken ship laden with Ming Dynasty
   porcelain - Mozilla Firefox
   http://thestar.com.my/news/story.asp?file=/2007/6/14/apworld/20070614201348&sec=apworld

And, finally, Thunderbird. Once again, I cannot get the necessary
metadata other than from the window title, like here:

** Thu Jul  5 10:21:19 2007 (Re: [CLASSICS-L] Book collection software
- Thunderbird)
   Re: [CLASSICS-L] Book collection software - Thunderbird
   > > Like many Classics-L members, I'd suppose, I have too many books
   scattered
   > > around, and I'd like to get some control over them. I'm looking
   for a
   > > fairly simple, fairly basic program for Mac OS X that would allow
   me to
   > > enter data like author, title, publisher, date and maybe some
   additional
   > > notes. I once used ProCite, which was quite good but is no longer
   > > available for the Mac. Offline responses would be fine:
   > > aszegedymasz*AT*wesleyan.edu

   Have you looked into LibraryThing?  Go to:
    http://www.librarything.com/

To get all this working, I just had to set up remember-mode
(shamelessly copying the instructions from the org-mode manual) and to
add the following into ~/.stumpwmrc file:

(define-stumpwm-command "emacs-remember" ()
  (let ((window-name (if (current-window) (window-title
(current-window)) "No current window")))
    (run-or-raise "emacs" :class "Emacs")
    (send-meta-key (current-screen) (kbd "M-x"))
    (window-send-string (current-window) "org-remember")
    (send-meta-key (current-screen) (kbd "RET"))
    (window-send-string (current-window) "f")
    (window-send-string (current-window) window-name)
    (send-meta-key (current-screen) (kbd "RET"))
    (window-send-string (current-window) (get-x-selection))))
(define-key *top-map* (kbd "F12") "emacs-remember")

-- 
With best regards,
Dmitri Minaev

Russian history blog: http://minaev.blogspot.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OT: remember'ing from other programs with stumpwm
  2007-07-05  5:39 OT: remember'ing from other programs with stumpwm Dmitri Minaev
@ 2007-07-05 12:17 ` Nikos Apostolakis
  2007-07-05 18:45 ` Scott Jaderholm
  1 sibling, 0 replies; 8+ messages in thread
From: Nikos Apostolakis @ 2007-07-05 12:17 UTC (permalink / raw)
  To: emacs-orgmode

"Dmitri Minaev" <minaev@gmail.com> writes:

>
> Obviously, one thing is missing here -- the URL. Unfortunately, I
> couldn't find a way to retrieve it from Firefox programmatically.

This may not be what you want but there is Conkeror, an emacs-like
keyboard-driven version of firefox.  In Conkeror the
"copy-current-url" is bund to "c".  So, if I understood your code
correctly you would have to add a few lines like

  (window-send-string (current-window) "c")

to copy the URL to the x-clipboard and later
  
  (window-send-string (current-window) (kbd "C-y"))
        
to copy the clipboard to the relelevant emacs buffer.

>
> To get all this working, I just had to set up remember-mode
> (shamelessly copying the instructions from the org-mode manual) and to
> add the following into ~/.stumpwmrc file:
>
> (define-stumpwm-command "emacs-remember" ()
>  (let ((window-name (if (current-window) (window-title
> (current-window)) "No current window")))
>    (run-or-raise "emacs" :class "Emacs")
>    (send-meta-key (current-screen) (kbd "M-x"))
>    (window-send-string (current-window) "org-remember")
>    (send-meta-key (current-screen) (kbd "RET"))
>    (window-send-string (current-window) "f")
>    (window-send-string (current-window) window-name)
>    (send-meta-key (current-screen) (kbd "RET"))
>    (window-send-string (current-window) (get-x-selection))))
> (define-key *top-map* (kbd "F12") "emacs-remember")
>

For some time I've been considering to switch to stumpwm from
ratpoison.  The naturality of the above (at least in the eyes of an
emacs user) finally did it.  I am now determined that in a week that
I'll be back home I'll try stumpwm.  Thanks for posting this (even
though it's OT).

HTH,
Nikos

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OT: remember'ing from other programs with stumpwm
  2007-07-05  5:39 OT: remember'ing from other programs with stumpwm Dmitri Minaev
  2007-07-05 12:17 ` Nikos Apostolakis
@ 2007-07-05 18:45 ` Scott Jaderholm
  2007-07-05 20:49   ` Dmitri Minaev
  1 sibling, 1 reply; 8+ messages in thread
From: Scott Jaderholm @ 2007-07-05 18:45 UTC (permalink / raw)
  To: Dmitri Minaev; +Cc: emacs-orgmode

On 7/4/07, Dmitri Minaev <minaev@gmail.com> wrote:
> Obviously, one thing is missing here -- the URL. Unfortunately, I
> couldn't find a way to retrieve it from Firefox programmatically.

Have you tried sending control l, end, shift-home, control c and then
pasting it where you need it?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OT: remember'ing from other programs with stumpwm
  2007-07-05 18:45 ` Scott Jaderholm
@ 2007-07-05 20:49   ` Dmitri Minaev
  2007-07-06  6:17     ` Dmitri Minaev
  2007-07-06 11:24     ` Jason F. McBrayer
  0 siblings, 2 replies; 8+ messages in thread
From: Dmitri Minaev @ 2007-07-05 20:49 UTC (permalink / raw)
  To: Scott Jaderholm; +Cc: emacs-orgmode

On 7/5/07, Scott Jaderholm <jaderholm@gmail.com> wrote:
> On 7/4/07, Dmitri Minaev <minaev@gmail.com> wrote:
> > Obviously, one thing is missing here -- the URL. Unfortunately, I
> > couldn't find a way to retrieve it from Firefox programmatically.
>
> Have you tried sending control l, end, shift-home, control c and then
> pasting it where you need it?
>

Yes, something like this. Unfortunately, C-c copies the text into the
clipboard, and Emacs pastes the content of the primary selection. And
I'm afraid that Conkeror also uses the clipboard selection. I want to
try and play with xclipboard or xselection, but I'm a bit skeptical
about both of them.

-- 
With best regards,
Dmitri Minaev

Russian history blog: http://minaev.blogspot.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OT: remember'ing from other programs with stumpwm
  2007-07-05 20:49   ` Dmitri Minaev
@ 2007-07-06  6:17     ` Dmitri Minaev
  2007-07-06 11:24     ` Jason F. McBrayer
  1 sibling, 0 replies; 8+ messages in thread
From: Dmitri Minaev @ 2007-07-06  6:17 UTC (permalink / raw)
  To: emacs-orgmode

> Yes, something like this. Unfortunately, C-c copies the text into the
> clipboard, and Emacs pastes the content of the primary selection. And
> I'm afraid that Conkeror also uses the clipboard selection. I want to
> try and play with xclipboard or xselection, but I'm a bit skeptical
> about both of them.

I think I did it :). Instead of xselection (which might give suitable
results) I used elisp functions. First, I added two functions to
~/.emacs:
(defun get-clipboard-selection ()
  "Retrieve text from clipboard selection and strip all its properties"
  (interactive)
  (let ((str (x-get-selection 'CLIPBOARD)))
    (set-text-properties 0 (length str) nil str)
    (insert str)))
(defun get-primary-selection ()
  "Retrieve text from primary selection and strip all its properties"
  (interactive)
  (let ((str (x-get-selection 'PRIMARY)))
    (set-text-properties 0 (length str) nil str)
    (insert str)))

they should be one function, I know...

The remember template is:
(setq org-remember-templates '((?t "* TODO %?\n %i\n %a" "~/org/notes.org")
				(?f "%i\n %?" "~/org/notes.org")))

The function in ~/.stumpwmrc is now:
(define-stumpwm-command "emacs-remember" ()
  (let ((current-window-name (if (current-window) (window-title
(current-window)) "No current window"))
	(copy-from-firefox (equal (window-class (current-window)) "Firefox-bin")))
    (when copy-from-firefox
	(send-meta-key (current-screen) (kbd "C-l"))
	(send-meta-key (current-screen) (kbd "C-c")))
    (run-or-raise "emacs" :class "Emacs")
    (send-meta-key (current-screen) (kbd "M-x"))
    (window-send-string (current-window) "org-remember")
    (send-meta-key (current-screen) (kbd "RET"))
    (window-send-string (current-window) "f")
    (window-send-string (current-window) current-window-name)
    (send-meta-key (current-screen) (kbd "RET"))
    (send-meta-key (current-screen) (kbd "M-x"))
    (window-send-string (current-window) "get-primary-selection")
    (send-meta-key (current-screen) (kbd "RET"))
    (send-meta-key (current-screen) (kbd "RET"))
    (when copy-from-firefox
      (send-meta-key (current-screen) (kbd "M-x"))
      (window-send-string (current-window) "get-clipboard-selection")
      (send-meta-key (current-screen) (kbd "RET")))))
(define-key *top-map* (kbd "F12") "emacs-remember")

A bit awkward, but I like the result. Now, we can select the text in
any window using mouse (which is against stumpwm ideology :)), press
F12 and we get the Remember buffer. After C-u C-c C-c, the following
entries appear in the default notes file (the first entry is from
Firefox, the second is from kpdf and the third one is from
Thunderbird):
** Fri Jul  6 10:33:30 2007 ( The Epoch Times | Earliest Findings of
Wooden Figurines in )
    The Epoch Times | Earliest Findings of Wooden Figurines in China -
    Mozilla Firefox
   Recently, a Chinese archaeological team working in Hanchen City,
    Shaanxi Province, excavated an ancient tomb from the Zhou Dynasty
    ((1046-221 B.C.) and discovered many precious historical
    relics. Inside one chamber they found four wooden figurines with
    color painted design. To this day, these figurines are the earliest
    known in China. They have been dated 500 years older than the
    terracotta soldiers and horses of the Qin Dynasty (221-205 B.C.)
   http://en.epochtimes.com/news/7-6-25/56866.html
** Fri Jul  6 10:37:43 2007 ( elisp-intro.pdf - KPDF)
    elisp-intro.pdf - KPDF
      Most of the GNU Emacs integrated environment is written in the pro-
   gramming language called Emacs Lisp. The code written in this program-
   ming language is the software?the sets of instructions?that tell the com-
   puter what to do when you give it commands. Emacs is designed so that
   you can write new code in Emacs Lisp and easily install it as an extension
   to the editor.
** Fri Jul  6 10:40:04 2007 ( [CLASSICS-L] For users of TeX - Thunderbird)
    [CLASSICS-L] For users of TeX - Thunderbird
   Technica, a suite of LaTeX packages for	typesetting literary texts,
   is available on CTAN:

   http://www.ctan.org/tex-archive/macros/latex/contrib/technica/

   The `examples' directory holds nearly 100,000 lines of texts in
   seven languages, including Greek and Latin.

What I miss now is the ability to store links to the messages in the
Thunderbird folders, but I, probably, want too much :)

-- 
With best regards,
Dmitri Minaev

Russian history blog: http://minaev.blogspot.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OT: remember'ing from other programs with stumpwm
  2007-07-05 20:49   ` Dmitri Minaev
  2007-07-06  6:17     ` Dmitri Minaev
@ 2007-07-06 11:24     ` Jason F. McBrayer
  2007-07-06 12:28       ` Dmitri Minaev
  1 sibling, 1 reply; 8+ messages in thread
From: Jason F. McBrayer @ 2007-07-06 11:24 UTC (permalink / raw)
  To: Dmitri Minaev; +Cc: emacs-orgmode

"Dmitri Minaev" <minaev@gmail.com> writes:

> Yes, something like this. Unfortunately, C-c copies the text into the
> clipboard, and Emacs pastes the content of the primary selection. And
> I'm afraid that Conkeror also uses the clipboard selection. I want to
> try and play with xclipboard or xselection, but I'm a bit skeptical
> about both of them.

What about x-clipboard-yank?  Also, if x-select-enable-clipboard is
non-nil, shouldn't emacs paste the clipboard when available?

-- 
+-----------------------------------------------------------+
| Jason F. McBrayer                    jmcbray@carcosa.net  |
| If someone conquers a thousand times a thousand others in |
| battle, and someone else conquers himself, the latter one |
| is the greatest of all conquerors.  --- The Dhammapada    |

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OT: remember'ing from other programs with stumpwm
  2007-07-06 11:24     ` Jason F. McBrayer
@ 2007-07-06 12:28       ` Dmitri Minaev
  2007-07-06 13:12         ` Jason F. McBrayer
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitri Minaev @ 2007-07-06 12:28 UTC (permalink / raw)
  To: emacs-orgmode

On 7/6/07, Jason F. McBrayer <jmcbray@carcosa.net> wrote:
> What about x-clipboard-yank?  Also, if x-select-enable-clipboard is
> non-nil, shouldn't emacs paste the clipboard when available?

If I knew these words before, I would've used them :). Well, there are
more things in heaven and earth...

-- 
With best regards,
Dmitri Minaev

Russian history blog: http://minaev.blogspot.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: OT: remember'ing from other programs with stumpwm
  2007-07-06 12:28       ` Dmitri Minaev
@ 2007-07-06 13:12         ` Jason F. McBrayer
  0 siblings, 0 replies; 8+ messages in thread
From: Jason F. McBrayer @ 2007-07-06 13:12 UTC (permalink / raw)
  To: Dmitri Minaev; +Cc: emacs-orgmode

"Dmitri Minaev" <minaev@gmail.com> writes:

> On 7/6/07, Jason F. McBrayer <jmcbray@carcosa.net> wrote:
>> What about x-clipboard-yank?  Also, if x-select-enable-clipboard is
>> non-nil, shouldn't emacs paste the clipboard when available?
>
> If I knew these words before, I would've used them :). Well, there are
> more things in heaven and earth...
>

Yep, emacs is like that.  M-x apropos and M-x apropos-variable are
really helpful for finding things before you try to implement them
yourself.  Also, emacswiki.org is helpful.

IMO x-select-enable-clipboard should ALWAYS be t.  Setting it to nil
is saying "please break my clipboard handling.  I want it to not
work.  KTHXBYE."  Still seems to default to nil in order to behave the
same way as the emacs of yore, however.

-- 
+-----------------------------------------------------------+
| Jason F. McBrayer                    jmcbray@carcosa.net  |
| If someone conquers a thousand times a thousand others in |
| battle, and someone else conquers himself, the latter one |
| is the greatest of all conquerors.  --- The Dhammapada    |

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-07-06 13:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-05  5:39 OT: remember'ing from other programs with stumpwm Dmitri Minaev
2007-07-05 12:17 ` Nikos Apostolakis
2007-07-05 18:45 ` Scott Jaderholm
2007-07-05 20:49   ` Dmitri Minaev
2007-07-06  6:17     ` Dmitri Minaev
2007-07-06 11:24     ` Jason F. McBrayer
2007-07-06 12:28       ` Dmitri Minaev
2007-07-06 13:12         ` Jason F. McBrayer

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).