emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Dmitri Minaev" <minaev@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: OT: remember'ing from other programs with stumpwm
Date: Fri, 6 Jul 2007 11:17:05 +0500	[thread overview]
Message-ID: <b6c377310707052317i3f1a764dg1bc5e96676767e9@mail.gmail.com> (raw)
In-Reply-To: <b6c377310707051349q72540843u4154e3410322a7f3@mail.gmail.com>

> 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

  reply	other threads:[~2007-07-06  6:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2007-07-06 11:24     ` Jason F. McBrayer
2007-07-06 12:28       ` Dmitri Minaev
2007-07-06 13:12         ` Jason F. McBrayer

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=b6c377310707052317i3f1a764dg1bc5e96676767e9@mail.gmail.com \
    --to=minaev@gmail.com \
    --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).