Archive for the ‘compknow’ Category
Using Gmail with mutt, the minimal way (IMAP update)
As Gmail has IMAP access, it is fairly trivial to get it working with mutt. First, if you’re on Ubuntu/Debian, run sudo apt-get install openssl mutt to get mutt if you don’t already have it. Then, just put the following lines into your ~/.muttrc:
set imap_user = "username@gmail.com" set imap_pass = "password" set smtp_url = "smtp://username@smtp.gmail.com:587/" set smtp_pass = "password" set from = "username@gmail.com" set realname = "Your Real Name" set folder = "imaps://imap.gmail.com:993" set spoolfile = "+INBOX" set postponed="+[Gmail]/Drafts" set header_cache=~/.mutt/cache/headers set message_cachedir=~/.mutt/cache/bodies set certificate_file=~/.mutt/certificates set move = no
Make sure your ~/.muttrc isn’t world-readable; it contains your password. (Alternatively, you can leave them out and mutt will prompt you for the password each time.) Also, if you copy-paste from the above, make sure that you have only “normal” quotes, not “smart quotes” which WordPress might have inserted here into this post.
[Other things I have:
set sort = 'threads' set sort_aux = 'last-date-received' set imap_check_subscribed ignore "Authentication-Results:" ignore "DomainKey-Signature:" ignore "DKIM-Signature:" hdr_order Date From To Cc
I did not include above to justify the "minimal" :)]
Things work perfectly as you would expect them.
One thing to note is that the full headers will still contain the hostname of the computer you send messages from. I have not figured a way of hiding this, and perhaps it shouldn’t be possible.
The End
If for some reason you want to use POP, read on. And tell me why you would want to use POP. The rest of the post is an old version, which i had written before Gmail supported IMAP.
Old Stuff
There is a guide here, which is the first Google result on searching for the keywords Gmail, mutt and Ubuntu in any order, but I would advise against it: it does too much unnecessary stuff using too many unnecessary programs (okay if you don’t care), and involves putting your username and password in a world-readable file (not okay).
There is a guide here, but that site seems down, and so I guess it’s likely to be down again (a DynDNS domain; could be someone’s house), so putting a (fuller) guide here:
First, run sudo apt-get install openssl mutt
Next, in /etc/ssmtp/ssmtp.conf, put
mailhub=smtp.gmail.com:465
UseTLS=YES
Everything else seems to be optional.
Next, create a shell script with the contents and put it somewhere in your path (~/bin/gmailout, say) and make it executable (chmod u+x ~/bin/gmailout, I mean) and make sure only you can read it! (chmod og-r ~/bin/gmailout).
#!/bin/sh
/usr/sbin/ssmtp -au "gmail-address" -ap "password" $@
Now in ~/.muttrc, put
set pop_host="pops://username:password@pop.gmail.com:995"
set pop_last
unset pop_delete #Just makes mutt not ask, GMail uses config option
set sendmail="~/bin/gmailout"
set write_bcc=no #Important; sSMTP makes bcc non-blind otherwise
and you’re set (remember to make this world-unreadable too: chmod og-rw ~/.muttrc)
You can start mutt, and hit “G” (uppercase G) whenever you want to fetch mail. Can also put exec fetch-mail in ~/.muttrc to have it happen whenever you start mutt, but I find that irritating.
Problems with POP: Not that everything is perfect. I can’t have other mail-transport-agents like sendmail or postfix installed alongside ssmtp. I can’t figure out how to get my crontab reports sent to root, but they do go into ~/dead.letter :D
Also, with mutt I had the habit of adding a my_hdr bcc: my-email-address so that the mail I send is threaded along with the mail I receive (yaay, like Gmail), but somehow there seems to be simply no way of getting Gmail to give me, through POP, those messages I send using an external client. It’s a quirk [bug!] in the way Gmail implements POP. This I’ve fixed by setting mutt’s fcc to /var/mail/my-username, my mail folder. (Of course, if I were in the habit of moving mail to my mbox, I could fcc to mbox too.)
Apart from that, it works fine!
“expr: syntax error” with acroread
I installed acroread (BTW it’s called “Adobe Reader”, not “Adobe Acrobat Reader”) on Ubuntu Gutsy from the Medibuntu repository, and running acroread gave lots of
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
in an apparent infinite loop.
Googling gave this link but it seemed to already have been fixed in the version I had.
Another link gave the clue:
The line that reads:
echo $mfile| sed ‘s/libgtk-x11-\([0-9]*\).0.so.0.\([0-9]\)00.\([0-9]*\)\|\(.*\)/\1\2\3/g’
should be
echo $mfile| sed ‘s/libgtk-x11-\([0-9]*\).0.so.0.\([0-9]\)000.\([0-9]*\)\|\(.*\)/\1\2\3/g’The number of 0′s following ’1′ should match what the real libgtk is: libgtk-x11-2.0.so.0.1000.8
Running locate libgtk-x11 gave
so I removed the 0 on line 421 (not 418) to make it
/usr/lib/libgtk-x11-2.0.so.0
/usr/lib/libgtk-x11-2.0.so
/usr/lib/libgtk-x11-2.0.la
/usr/lib/libgtk-x11-2.0.a
/usr/lib/libgtk-x11-2.0.so.0.1105.0
echo $mfile| sed 's/libgtk-x11-\([0-9]*\).0.so.0.\([0-9]*\).\([0-9]*\)\|\(.*\)/\1\2\3/g'
I still don’t understand exactly why it works (the above function would be returning 211050, but it does, and that’s all that matters.
Now to report it on Medibuntu…
Devil’s Pie
is one of the things that can make GNOME usable. It is the perfect example of what I always meant when I said “GNOME is for advanced users” — to get anything except some set of “basic” things done in GNOME, you need real technical skill, while in KDE you only need patience to look through preference dialogs. And gconf-editor is quite reminiscent of regedit ;-)
Anyway, Devil’s Pie is amazing!
The main page here, a short documentation here, and extensive documentation here. These specs might help.
Two files that I have in my ~/.devilspie contain to make my Pidgin conversation windows maximized, and
(if
(and (is (window_class) "Pidgin") (is (window_role) "conversation"))
(maximize)
)
to have my terminal windows maximised.
(if
(and (is (window_class) "Gnome-terminal") (contains (window_role) "gnome-terminal"))
(maximize)
)
To make Devilspie run at startup — go to System → Preferences → Sessions and Add it in the “Startup Programs” tab.
One hackish purpose I use Devilspie for is to get around GNOME’s lack of an equivalent of KDE’s “Activate window demanding attention” keybinding. (Ctrl-Alt-A by default)
Because I mainly need this for my Pidgin conversation windows, I have a file pidgin-conversation-focus.ds in ~/.devilspie/special (not in ~/.devilspie) which contains and also have a pcf.sh which contains
(if
(and
(is (window_class) "Pidgin")
(is (window_role) "conversation")
(contains (window_name) "(*)")
)
(focus))
in it and is bound to Ctrl-Alt-a (using the painful way GNOME has for assigning keys…)
#!/bin/bash
devilspie ~/.devilspie/special/pidgin-conversation-focus.ds & sleep 1
kill -SIGSTOP $!
It sometimes doesn’t work (rather, Pidgin’s message notification plugin doesn’t always insert “(*)” in the title), but I’m getting by.
If there was a way, from within Devilspie, of checking whether a particular window is demanding attention or not, it would be great. I sent a (badly worded) email to the author and haven’t got a reply…
BTW: While testing the above I used a lot.
purple-remote "jabber:goim?screenname=myusername@gmail.com&message=hi"
Online LaTeX
Someone has collected a useful bunch of links: Using LaTeX in WordPress » Online LaTeX
(Pasted from somewhere, to be cleaned up –)
For typesetting mathematics, there is LaTeX, of course. But what does one do next with the LaTeX file, if you intend the document to be viewable online? Using PDF files for online viewing is frowned upon. There is simply nothing better than HTML, and so one might consider using latex2html. This, however, usually uses images for almost everything leading to huge files and slow-loading pages. Much better in this regard TtH, which tries to make the mathematics display in plain HTML by hook or by crook, but this ends up looking ugly and defeats what was probably one of the major goals in using LaTeX in the first place. One could use MathML — writing a MathML document by hand is absurdly painful, but there is TtM which can convert LaTeX to MathML. But MathML creates XML (not HTML) files, and thus doesn’t plug into general text easily; it also requires the user to have some specific fonts installed, etc., and if a browser (like IE6) fails to display it correctly, the result is a mess. I just discovered that there is ASCIIMathML, which seems to handle everything very well. LaTeX-style formulas work (one can also use their simpler language, it appears). It still needs the fonts to be installed and everything, but when it fails (if JavaScript is disabled, for example), the user will simply see the “source code” of the mathematical text, which can still be readable.
Idea: Poor man’s conference
The Yahoo! Messenger protocol has “conferences” / “group chats” / “synchronous realtime multiuser text transfer” / “multiplayer notepad” / whatever you call it. Google Talk doesn’t (yet?). This is one of the things that (some) people sorely miss in Google Talk. So people who primarily use their Google accounts for IM are forced to use alternative protocols, such as YMSG or Skype, if they want to group chat…
In a “sudden flash of inspiration”, I realised how easy it would be to create a bot that would make it work even on one-to-one-only services like Google Talk. It could work like this:
- Suppose Alice Bob Carol and Dave want to have a conference.
- They each have the bot (“Trent”, say) on their buddy list (“contacts”).
- The bot is given the list of the four users
- Each person sends his/her messages to the bot (buddy Trent).
- The bot sends all messages from user X to all other users, prefixing X: to the messages.
Would work well, AFAICS.
Note that the way the above is constructed, all that the above bot is good for is for exactly Alice Bob Carol Dave to chat… (of course, we could reset this and give the bot new instructions). Having one account for every conference doesn’t seem a feasible idea :-)
Actually, it could easily support multiple conferences as long as they have disjoint sets of members — it would forward the messages of user X only to other users in the conference X is in.
We can also get around the disjointness restriction by making users who are in multiple conferences somehow specify which one they want the current message sent to, in each message…
Another annoyance is what names are displayed… what name the bot shows you a message as coming from might well be different from the alias you have for that person :)
There could be insane security problems, so not considering “rolling it out”, but maybe I can code up something for three-four of my friends (and I) to use…
Update: A few seconds of searching (and the many minutes of debugging/installing!) can save a few hours (or days?) of coding. And to think I was actually trying to write a Jabber client in Python :)
Here it is: Google Talk: Conference Bot.
Sigh. All the good ideas have already been thought of.
Adam was the only man who, when he said a good thing, knew that nobody had said it before him.
said Mark Twain.
Am having some problems installing it, though.
Things that needed fixing:
Update: Nvm, ignore this list below. Just remember to give not username@gmail.com, but just username, the first time it asks.
* Manually change confbot.ini so that the server is talk.google.com, not gmail.com
* Get the newer jabber.py libraries (and put them in this directory, because for some reason they won’t install)
* Try changing the port from 5223 to 5222 or something. Actually, no: get rid of the extra options in the second line
* Change debug=False to debug=[]
* In the confbot.py file from SVN, change the “13″ to “4″
This page also seems to be important.
Someone has made a plugin for Google Desktop… listed here too.
Come to think of it, considering that a bot for Google has already been written, what I should write is a sort-of cross-protocol bot… use libpurple and write it in C? :-)
Getting xchat to open Firefox instead of whatever
It’s covered in the XChat FAQ: What’s the deal with opening URLs in XChat on Unix/Linux?.
I manually added the “Open link in Firefox” option, and haven’t bothered figuring out how it works on Edgy’s Xchat (2.6.6), and decided to wait and see how things work in Feisty (Xchat 2.8.0), as the FAQ says everything’s changed in 2.8.0.
Update: I’m using Ubuntu Gutsy, which has XChat 2.8.4, and everything works fine by default, without having to tweak anything.
Debian/Ubuntu: Find out which packages are taking the most space
There is a package called debian-goodies (that’s what it’s called on Ubuntu as well :-)) which has this utility called dpigs — for telling you which packages are “pigging out” on your system. (So install it with sudo apt-get install debian-goodies, and then run dpigs). This and other utilities, from the description:
debget - Fetch a .deb for a package in APT's database
dpigs - Show which installed packages occupy the most space
debman - Easily view man pages from a binary .deb without extracting
checkrestart - Help to find and restart processes which are using old
versions of upgraded files (such as libraries)
popbugs - Display a customized release-critical bug list based on
packages you use (using popularity-contest data)
Nice.
Symbol’s function definition is void: outline-font-lock-level
Using Emacs and todoo-mode (the todoo library / todoo.el).
I got the message
Symbol’s function definition is void: outline-font-lock-level
whenever I tried to insert a new sub-item (using C-c M-i which is bound to todoo-insert-sub-item) in my TODO file. Searching Google gave someone’s old diary, from which (although it’s in Japanese ;-)) I found that it’s related to Debian bug 244681: emacs-goodies-el: todoo.el doesn’t work at XEmacs21. I’m using GNU Emacs 22.0.92.1 and not XEmacs, though.
Update: Before you try the “fixes” below (and in the comment), try just downloading the latest version from Debian. It appears that this got reported as bug 447760, and got fixed.
Anyway, the fix (I haven’t learnt Emacs lisp, so this may be far from the “best” way to do it):
- Open the todoo.el file (M-x find-library RET todoo RET) and find the todoo-insert-sub-item function. (Better, use C-h f todoo-insert-sub-item RET and follow the link.)
- Replace (outline-font-lock-level) with a value, like 3 or something. You might also want to do the same in the other place that (outline-font-lock-level) is used — in the function todoo-indent-line
Another solution, if you don’t want to / can’t edit the file (no permissions, for example), might be to define the function (outline-font-lock-level) — put (defun outline-font-lock-level nil 3) somewhere.
Another solution might be to redefine the function entirely. This requires knowledge that I don’t have, but, for example, making some local transformations, I replaced it with this:
(defun todoo-insert-sub-item ()
"Insert a new todoo-sub-item."
(interactive)
(goto-char (- (todoo-item-end) 1))
(insert (concat (make-string todoo-indent-column ? )
todoo-sub-item-marker " \n"))
(backward-char))
The space after the ? is important.
What to do with a Debian/Ubuntu source package
A Debian source package (something like this) often has files like xxxxx.orig.tar.gz, xxxxx-1.diff.gz and xxxxx-1.dsc. It wasn’t clear what to do with them, so I gathered courage and asked in #debian, and despite all the stories I’d heard about the channel, a couple of people were actually nice enough to answer: do dpkg-source -x xxxxx-1.dsc, which will extract the .tar.gz (don’t do it yourself) and apply the patch correctly. Then you have the source directory, where you can go and configure, make ….
The Firefox right-click bug
I was having a bug with Firefox where right-clicking in some places would bring up two context menus, a sort of double-menu with one on top of the other, and with both of them working (but clicking somewhere else outside dismisses only one of the menus).
I searched around on Google a bit and found no mention of it… Recently, one of my friends had the same bug, so we knew what to do — look in the list of extensions that we had both installed, and find which one was causing it. The culprit turned out to be Image Zoom. I uninstalled it, and now everything works fine.
Update: There is a video of this behaviour.
Update: It seems (seems) to be fixed: here.
Tabs in Emacs
Here is an incredibly detailed page on Tabs in Emacs, and I’m sure it doesn’t even explain the issues completely :-)
X Error: BadDevice, invalid or uninitialized input device
For errors like this:
X Error: BadDevice, invalid or uninitialized input device 168 Major opcode: 145 Minor opcode: 3 Resource id: 0x0 Failed to open device
(First, note that these are usually harmless. If you’re debugging something that has just gone wrong, almost always the problem is with something else, not these errors.) To make these messages/errors go away, edit /etc/X11/xorg.conf (don’t forget to backup, or else you may have no GUI when you reboot!), find the lines corresponding to the InputDevices you don’t have (Stylus, Cursor, Eraser), and get rid of them by commenting out everything from Section "InputDevice" to EndSection for each of them. Also, in Section "ServerLayout", comment out the corresponding lines. Changes will take effect the next time X is started (so reboot, or logout and hit Ctrl-Alt-Backspace).
Got it from the top Google search; it’s here. If you can imagine even more “step-by-step” instructions than what I wrote above, they’re here.
k3b verification “Could not find file”
Enable “Allow lowercase characters in ISO9660 file names”. Reported at https://launchpad.net/distros/ubuntu/+source/k3b/+bug/59089 and http://bugs.kde.org/show_bug.cgi?id=119544
Update: Probably fixed by now.
Other annoying k3b bugs:
- When it ejects and reloads the CD for verification, KDE pops up a “What do you want to do?” thing that comes when CDs are inserted.
- When it ejects and cannot reload the CD (it happens often with old drives) it aborts, instead of asking the user to put the CD in.
Editing TEXTAREAs in an external editor
For many people today, much more text editing happens in TEXTAREA forms than elsewhere, as observed here. But textareas have many problems — they don’t have all of the features your favourite editor has; it’s easy to lose text permanently (browser crash, or some confusion with undo operations, etc.); can’t save what you type for safekeeping, ….
The solution, of course, is to use your own external editor for entering text into textareas. Typing it somewhere and pasting it into the textarea is clumsy (and what happens when you decide to edit some more?). Fortunately, there are solutions which (promise to) work seamlessly:
- The ViewSourceWith firefox extension. This is what I
usewas using, and it works well. Despite its name (and all the things it can do), I suspect that this extension is primarily used for editing textareas :-) - The It’s all text firefox extension. Haven’t used this myself.
- The MozEx firefox extension. Actually, this works only with Firefox 0.7–0.9; try the one at its homepage. I had tried this a while ago, and I vaguely remember there were some problems. It may have been fixed now, though.
- The Editus Externus firefox extension. Never heard of it before today. Doesn’t work on Firefox 2.
- The EmbeddedEditor extension. Experimental, works with Linux only.
- There’s also the Xinha here firefox extension, which starts a particular editor (“Xinha”) each time, but I think it’s pointless to learn one more entirely new editor, with probably its own set of limitations.
To use Emacs with any of these, simply set the external editor to use Emacs as a server, i.e. EmacsClient. (You could also set it to use emacs instead of emacsclient, but that would start a new instance of Emacs each time.)
There’s also an amazingly clumsy clever hack, which might work far better than anything else if you’re on X: a script called external-edit. (The Windows version external.exe is here.) This promises much, much more: being able to call an external editor from anywhere, not just Firefox. It works by getting the ID of the window with focus, simulating keypresses that correspond to those for Select All and Copy (so that the contents of the textarea get pasted into clipboard), creating a file with the contents of the clipboard, invoking your editor on the file and waiting for it to exit, moving file’s contents to clipboard, and generating the keystroke for Paste. Clever. Hack.
I haven’t tried the Windows version of course, but the Linux version is buggy (at least, I couldn’t get it to work directly). After much effort and a long time (that’s because I’m an idiot, not because there was much to change), I think I’ve fixed it. I’ve tested it on {GNOME,KDE}×{Firefox,Konqueror,Opera}×{emacs,emacsclient,gvim -f,gedit,kate}. You can get it here.
Simply set up a keystroke to invoke (say) “external-edit emacsclient”, and no matter where you’re typing something, if you suddenly decide you want to do it in Emacs, just hit the key. Nothing could be better :-)
ssh through a proxy (Squid, etc)
If you are somewhere where the only way of connecting to the outside world is through a proxy, then to get ssh to work, here’s what to do:
Get connect.c.
Compile it (gcc connect.c -o connect), and put connect somewhere in your path. That page says /usr/local/bin, but you probably don’t have permissions to that, anyway. You can do mkdir -p ~/bin && mv connect ~/bin and add a line export PATH=$PATH:~/bin to ~/.bashrc or ~/.bash_profile (or both), and restart the terminal, or start a new one.
Edit the file ~/.ssh/config (create it if it doesn’t exist) and add the two lines
Host * ProxyCommand connect -H proxyusername@proxyname:3128 %h %p
Replace proxyusername by the username for the proxy, and proxyname by the location of the proxy, and 3128 by the port number (it’s usually 3128 for Squid).
If it is a low-security thing and the password is already well-known (guest account?), then might as well put the password in the above .bash… files, to save the hassle of typing it each time:
export HTTP_PROXY_PASSWORD=proxypassword
Then ssh should work as usual: ssh username@hostname , etc.
BSNL DataOne’s DNS
The manual I got asked me to use 61.1.96.69 and 61.1.96.71 as the domain-name servers, but it appears that this is not really optimal. I found other sources, and confirmed by looking at one particular DataOne manual.
Here are the first few lines of my /etc/resolv.conf now:
nameserver 218.248.255.145 #BSNL, primary for South, secondary for North nameserver 218.248.255.193 #BSNL, primary for North, secondary for South nameserver 61.1.96.69 #BSNL, primary for East nameserver 61.1.96.71 #BSNL, secondary for West nameserver 218.248.255.177 #BSNL, primary for West, secondary for East nameserver 208.67.222.222 #OpenDNS nameserver 208.67.220.220 #OpenDNS
The first one is really faster slightly (about 63 ms instead of 79 ms, or so), but I doubt if it matters…
[Update, asked in the comments: use this on Windows.]
The pefect (non-)markup solution
(This
I just found something that’s amazing in its simplicity, and yet neatly solves a problem. Maybe you’ve sometimes wondered how to markup your email (perhaps in cases where you want the same text to be reusable) and yet retain its readability. (I have a friend who sometimes writes email in TEX markup, which is just incredibly wrong and annoying.) There is a solution that is as close to perfect as imaginable: Markdown. Its Basics page was itself written in Markdown. The syntax is perfectly readable; it is available on Ubuntu and Debian, and can even be generated from HTML, in case one wants to go in the other direction. It even has a Wikipedia article, and (even without looking!) I’m sure it’s the best “lightweight markup language” there is. There seems to be a markdown mode for Vim, but no “standard” mode for Emacs yet. (But with such good and readable syntax, who needs an Emacs mode, anyway?) There is a comparison here. There are converters from MarkDown to other formats (such as LaTeX), see Pandoc (written in Haskell!) and MultiMarkdown.
Another thing that looks impressive (and even more useful, because it is well-integrated into Emacs) is Emacs Muse, can be published to a lot of formats, including DocBook and LaTeX. Documentation here, and someone’s personal notes here.
I haven’t tried either of them yet.
[Update] Emacs Muse is nice, but it’s really not polished enough yet. (Either that, or if it’s not going to change then I don’t like it.) There are no nested lists yet. (It does now.) Markdown says
The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions. While Markdown’s syntax has been influenced by several existing text-to-HTML filters, the single biggest source of inspiration for Markdown’s syntax is the format of plain text email.
That doesn’t seem to be Emacs Muse’s “overriding design goal” to me (I need to figure out why I feel so, but somehow the syntax feels kludgy and seems to have many bad corner cases).
As I see it, the most powerful and compelling features of Emacs Muse are
- The entire publishing system, where you can take a document and publish to multiple formats based on syntax translation rules, keeping a daily journal, etc. (planner-el depends on Emacs Muse for some of its functionality.)
- Its integration with Emacs
Frankly, IMHO, the actual markup language is not one of its greatest features, and it would be great if they used — or allowed plugging in — other existing languages.
(Update-update: This does seem to be the idea, or at least was at some point of time. See this thread, which contains a file that provides some MarkDown support in Muse.)
[End update.]
Linking to the New York Times
The New York Times have a policy whereby links to them from weblogs require no payment (nor registration, it appears).
Someone has put up a link generator here. Please use it when linking to the NYT from blogs.
Emacs copy/paste and X
Many people have problems getting copy-paste working in Emacs. Sometimes this can be ascribed to a misunderstanding of how the system works, but often it is a bug with Emacs itself.
First, a general word about how cut/copy/paste work in Linux and all applications:
Much of the confusion arises because there are actually two mechanisms for copying text between applications:
- Clipboard
- There is an explicit “clipboard”, just as in Windows. If you select some text, and explicitly click “copy” (or “cut”) somewhere (that is, either in the right-click menu or in the Edit menu, usually), it goes into the clipboard. You can paste it elsewhere by again explicitly clicking on “paste” (or Ctrl-V, often). This works perfectly well within itself, and just as in Windows, so there are no problems at all (except in Emacs sometimes, and we’ll come to that).
- Primary selection
- In addition, there is the “primary selection”. Consider it an additional feature which you can ignore if you like. It works like this: when you select some text (just select… highlight it, that’s all), it gets automatically “copied”, and you can paste it into another location simply by middle-clicking. This is intended for more temporary tasks, and shouldn’t be used for anything serious. A thing to watch out for is that unlike in the case of the clipboard, the text doesn’t really get copied anywhere. What actually happens when you middle-click to paste, is that the destination program asks the source program the text to be pasted. A consequence of this is that if you select some text and close the source program, you can’t paste that text anymore. In short, a good way to think of this is as “extended drag-and-drop“, in which you are allowed to let go of the mouse, change windows, and maybe even do a little bit of work (which does not require selecting) in some another window before finally “dropping” with the middle-mouse click.
- Others
- [There is also a "secondary selection" and another ancient mechanism involving "cut buffers", but neither of them is in use these days. Clipboard managers, like Klipper or the GNOME clipboard tool, can often be asked to use either the clipboard alone or the primary selection too.]
- This page claims to have a fix, which is essentially to add the lines
(setq x-select-enable-clipboard t) (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
to ~/.emacs. It didn’t help.
- There is mouse-sel-mode, which seems to affect pasting into emacs, whatever the name might say.
- The emacs manual says
To copy text to another X window, kill it or save it in the kill ring. Under X, this also sets the primary selection. Then use the “paste” or “yank” command of the program operating the other window to insert the text from the selection.
, but it didn’t help me either.
- I’ve discovered that the situation is better when Klipper is running — selecting (or copying) text in Emacs results in it being copied (imperfectly) to Klipper, and I can then paste in other apps, provided I first click on Klipper and choose that text. Weird.
- I can select in Emacs, and middle-click it onto konsole. It works. I can then select that and paste it into Firefox. That works too. So maybe Emacs and Firefox don’t have a good way of talking to each other. (The same seems to be true of any GNOME app, not just Firefox.)
This general picture is explained at jwz’s page and in this spec.
Second, the problem: Somehow, Emacs has problems with this. It is very inconsistent, so it’s hard to pin down the exact nature of the problem, but in general copying text between other applications and Emacs seems to just not work sometimes. With me, pasting into emacs works (almost always) by default; copying from emacs doesn’t, no matter what I try. Others have had the opposite problem.
Some possible solutions/ideas:
The bug is clearly somewhere under x-set-selection, because invoking it directly doesn’t work either.
And, trying to set the Emacs font today, I discovered another bug: I couldn’t paste from the xfontsel selection to any KDE app. I could do the thing of pasting into Firefox and then pasting into Emacs, though. There is also this discussion about what happens (or should happen) when something is “copied” without being selected first.
There are some other discussions at http://natalian.org/archives/2006/04/02/copy-and-paste/ , http://berserk.org/2006/04/04/copy-or-cut-and-paste-firefox-bug/ , and this Slashdot article about copy-paste, although none of it has been useful.
Please leave comments here if you have something to say; I still haven’t managed to find a workaround.
Updates: I found that M-x clipboard-kill-ring-save and M-x clipboard-yank seem to work for copying from Emacs to the clipboard and pasting from the clipboard into Emacs. In some of the comments below, Richard Lewis had the idea of using xsel, and Hugo Heden completed it further.