Got Emacs?: New Org-mode talk from Carsten Dominik
-1:-- New Org-mode talk from Carsten Dominik (Post sivaram (noreply@blogger.com))--L0--C0--March 09, 2010 05:55 PM
-1:-- New Org-mode talk from Carsten Dominik (Post sivaram (noreply@blogger.com))--L0--C0--March 09, 2010 05:55 PM
Recently, I discussed some ways to deal with large numbers of buffers. Maybe we can also take a step back and ask why we have so many buffers in the first place - do we really need all of them?
Well, the obvious answer is: probably not. After a few days of
(emacs-uptime) there are all kinds of temporary output buffers, man pages
and unchanged buffers you haven't touched in a long time. Let's get rid of
those!
For this very purpose, emacs provides midnight-mode (as has done so for more
than a decade). At midnight, it looks at all the buffers, and determines which
of the buffers are no longer in use, and closes ('kills') them. Regardless of
its name, this cleanup does not necessarily have to take place at midnight,
but could be invoked at any time.
Setup is easy, just put the following in your .emacs:
(require 'midnight)
Clearly, the package was designed for emacs instances that are running for
long times – for example, by default it clears buffers after having been
inactive for 3 days. I'm not sure if that use case is very common today.
Anyway, you can change it by setting clean-buffer-list-delay-general (which
takes the number of days before a buffer becomes eligible for killing).
You can ask midnight-mode to clean-up unused buffers right now with M-x clean-buffer-list. Also, you can use some variables to control which buffers
are to be killed, and which ones specifically not:
clean-buffer-list-kill-buffer-names clean-buffer-list-kill-never-buffer-names clean-buffer-list-kill-regexps clean-buffer-list-kill-never-regexps
To run clean-buffer-list every n minutes or so, you could use
run-at-time, left as an exercise to the reader.
Another way to accomplish roughly the same is TempbufMode.
It seems a bit better equipped for shorter cleanup interval, and you have some killed. However, that requires you to add it to the modes where you'd like to more influence on the algorithm it uses to decide whether a buffer may be use it, something like:
;; download tempbuf: http://www.emacswiki.org/emacs/tempbuf.el (when (require 'tempbuf nil 'noerror) (add-hook 'custom-mode-hook 'turn-on-tempbuf-mode) (add-hook 'w3-mode-hook 'turn-on-tempbuf-mode) (add-hook 'Man-mode-hook 'turn-on-tempbuf-mode) (add-hook 'view-mode-hook 'turn-on-tempbuf-mode))
Side-note: I'm using the (when (require 'tempbuf nil 'noerror) ... ) pattern
here to make sure that my .emacs also works when tempbuf is not available.
Added: for cleaning-up your buffer list non-automatically, you can simply
use M-x kill-some-buffers. (Thanks Susan!). Or you can use C-x C-b.
-1:-- cleaning up buffers automatically (Post djcb (noreply@blogger.com))--L0--C0--March 08, 2010 08:32 PM
-1:-- Another GNU/Emacs command that I've just discovered (Post)--L0--C0--March 08, 2010 11:15 AM
Rodrigo Alves Vieira posted a photo:
-1:-- Linux, Python and Emacs.. What a combination! (Post Rodrigo Alves Vieira (nobody@flickr.com))--L0--C0--March 06, 2010 09:06 PM
I stumbled onto a new build tool today: fabricate. I can't believe how cool it is, and that nobody has thought of it before (OK, actually, one person did, but still!). You give it a command, and it runs the command with strace and looks for all the files the command reads and produces and uses those as the command's dependencies and outputs, respectively. The next time you run the command with fabricate, if the outputs don't exist or the dependencies have changed it re-runs the command, otherwise, it doesn't. In other words, it does all the work that you normally would try and do with make, automatically.
Another cool thing about this is that it will work with anything. You don't have to write builders for it like you would for scons (another tool I looked at for a bit). I spent some time trying to get scons to run modelsim compiles and simulations for me, and it was way too hard to make it work. I just tried fabricate with a small modelsim job and it worked perfectly. I'm excited to play with fabricate some more.
-1:-- New Build Tool: fabricate.py (Post Bryan (noreply@blogger.com))--L0--C0--March 05, 2010 04:53 AM
emacs --batch --eval '(byte-compile-file "js2-20080616a.el")'
-1:-- js2-mode (Post sness (noreply@blogger.com))--L0--C0--March 04, 2010 05:48 PM
Rodrigo Alves Vieira posted a photo:
This is my Emacs running on my Ubuntu, I'm using my kit (http://github.com/rodrigo3n/emacsdelic/), the theme is "Twilight".
-1:-- My Emacs! (Post Rodrigo Alves Vieira (nobody@flickr.com))--L0--C0--March 03, 2010 05:36 PM
-1:-- Oops, I did it again! (Post)--L0--C0--March 02, 2010 10:12 PM
Since my family and I just moved to a new state for this new job, we took the opportunity to look at different options for home phone. Some friends had switched to ooma and liked it, and after a little research, we decided to go with ooma too, specifically the ooma telo.
We got it at best buy on sale for about $225, and that's all you pay. Apparently we'll eventually have to start paying about $11 a year for some sort of telecom tax. Other than that, nothing. You might be able to find the telo for cheaper on ebay or something too, I didn't look into that too much.
I connect my cable modem directly to the telo, and then the telo to my router, and then my computers to my router. You plug your normal land-line phone into telo too, and then it works like it always has. With everything going through the telo, it does QOS to make sure your voice traffic always has enough bandwidth, and it can do port forwarding so web and ssh requests still get to my linux machine. It supposedly does the right thing with 911 if you register your address with them (if I remember the setup process right). Setting it up wasn't too tricky (and would have been easier without the port forwarding and my comcast connection coincidently going down right in the middle of it all).
You get voicemail for free and the telo box gives you a convenient answering machine interface to it. It has a speaker and you can hear when someone calls and leaves a message. You can pick up the phone while they are leaving their message and start talking with them. You can play, rewind, save message and all that answering machine stuff by using the big buttons on the telo box. A red light flashes when you have a new message waiting. My wife likes that (and I'll admit, I really like it too). There is also a web interface to voicemail where you can listen to the messages as sound files, and you can have it send you a text message and/or an email whenever someone leaves a voicemail (not transcribed or anything, but google voice can do that if you really want).
You also get caller id that displays phone numbers only. If you want names you can pay ooma for their premium service. Our home phone has a phone book and if you save a number in there it knows how to display the name we saved, so we numbers only is fine for us.
Voice quality seems fine. Occasionally we've had some minor little weirdness where it seems like it was slow to notice that you picked up the phone, and once (only once) I unplugged the telo and plugged it back in to fix where it didn't notice we had hung up. It plays a little chime when you pick up the phone that's a little obnoxious, but other than that it's been fine and you hardly notice that it's VOIP.
I like that it's standalone hardware and not software based like MagicJack (which is windoze only, another sticking point for me). It is more expensive, and won't give you a big immediate savings. After 6 months of not paying $40 a month for regular phone service though, it's paid for.
-1:-- Our New Home Phone: Ooma (Post Bryan (noreply@blogger.com))--L0--C0--March 02, 2010 03:41 PM

-1:-- Fourth Emacs 23.2 Pretest Released (Post sivaram (noreply@blogger.com))--L0--C0--February 27, 2010 05:48 PM
Today I added (add-to-list 'gnus-buttonized-mime-types "multipart/alternative") to my Gnus configuration. The effect of this is to put a nice button at the top of each message I can click to view any HTML part, while keeping the default as plain text. I don't often directly read or write HTML mail, but at work I do sometimes need to proofread HTML mails.
-1:-- Showing HTML mail in Gnus (Post)--L0--C0--February 26, 2010 05:24 PM
-1:-- New version of CEDET released! (Post Alex Ott (alexott@gmail.com))--L0--C0--February 26, 2010 08:51 AM
Here's a rambling post mortem of PyCON. PyCON is a community run conference, that appears to be outdoing itself every year. It consists of 2 days of Tutorials, 3 days of Session and for those who want to stick around, sprinting. The sprints are still going on.
This was my first time in Atlanta (other than passing through the airport) and it seemed to be a pretty nice city (at least the downtown and Georgia Tech parts that I saw). PyCON will be in Atlanta next year, so here's some advice. If your hotel only say's "shuttle available", that means they don't actually have shuttles, but since there are shuttles at the airport, you can pay and take them. Come to find out that the train has a stop a block away from the conference hotel (our hotel was a block away from that). And the train is pretty nice, so there's a hint for next year.
The food was pretty good in Atlanta. We had BBQ one night, and mexican another. I got "brisket" quesadillas that were a pretty good fusion of southern/mexican. Pizza at the TiP Bof was good (thanks again Disney!). The lunches were quite good too. Steak, chicken and pork for the omnivores. The triangular grits(?) were pretty good and the mashed yams were yummy. Being an amateur gardener, I found the salads a little lacking, but hey, it's not really fresh veggie season and at least they weren't iceberg. The breakfasts and in between snacks were a little sparse.
I taught a tutorial that I called "The Meaty Parts of Python". Perhaps the name was a misnomer, as there have previously been "Python 101" tutorials. I put (what I thought) was a pretty good description of what I would cover in the material. The main idea being that I think one can get by in Python by knowing only the basic constructs. Eventually though, one should at least learn about closures, decorators, list comprehensions and generators (as well as how to test them). Even if one is not going to write such code, they will likely come across it. The tutorial was labeled as Python 301 to fit into a track on learning Python.
The tutorial, filled up quickly, and again filled up after the room size was expanded. The session went well and I got some good feedback. People who came in never writing generators or decorators, were leaving being able to write them.
I participated in the bag stuffing party later that evening, but was thinking it would be cool to have some sprints running during the Tutorials. That way if you were only interested in (or were only teaching) the 1st tutorial on the first day, you could do something else rather than sit in on (or sneak into) tutorials you may or may not be interested in.
GvR gave a Q&A session, based on twitter streams. Nothing really new there. Perhaps the quote "Nothing is Python is especially suited towards boys, so it should be good for girls too." (my paraphrase).
I went the WSGI Composition session first by Max Ischenko. The takeaway is that wsgi apps don't necessarily refactor cleanly along the wsgi line, though refactoring might help with maintenance. After that I jumped in the Pinax session, but left after the presenter has A/V issues and hopped in to the last part of VisTrails, which actually looked pretty cool, a sort of Turtle Art for workflow. After that it was off to Grig's talk of REST. If you are interested in REST, check out the video and slides for a good intro to REST and tips on getting started in general and in Python.
In the afternoon, I went to Jonathon Ellis' talk on Database Scalability. I've seen most of this talk previously at OSCON, but he's put a lot of work into it, and it's really good. It's language agnostic, so check out the video if you deal with large db's.
I've read Mertz's wonderful articles on Python, so I wanted to hear him speak on "laziness". If you find yourself heading done a functional path (which I feel like many times), check it out. When you start doing a lot of iteration, you start thinking about stuff like this. (Even GvR admitted that he is fascinated by functional languages, which seems to be new since he's been against functional constructs in the language.)
The form on panel generators turned out to be a wash. I guess with 4 or 5 frameworks, you can't expect much other than good jabs. My experience is that for complicated stuff generators don't work, and for simple stuff, it takes more time to learn, than just writing it.
The finance presentation was pretty cool. Pandas is a library for dealing with time series data, written as a numpy wrapper.
The talk on scaling with ec2 was done by reddit folks. It was quite fascinating, and Jeremy Edberg was quite willing to share details about reddit, their infrastructure, traffic and costs.
Spent the morning in the "hallway track", which was quite enlightening. Made it into the Unladen Swallow session (if only to get seats for Beazley's GIL talk which followed). Collin seemed confident that US could get to the goal of 5X speed improvement if not 10X. Seeing as how they are at 1.2X (with a big boost in memory usage), I'm a little more skeptical. It seems like I'd prefer the psyco route, where you can gain speed/sacrifice mem at your choice. (Yes, I understand the drawbacks to psyco and the unmaintainable code, yes, I know they are working on the memory issues). For all my pessimism, I really do hope the project advances well. And I hope that some friendly competition from PyPy can spur them both to improve. I know there are areas were we use 32bit OS's just so we can use psyco.
Beazley's GIL talk was very well prepared and delivered. Though I understand the benefits of the GIL wrt making c extension coding easy, it is sad that as concurrency and parallelism become more important, Python remains focused on the use case of running one thing at a time.
Raymond Hettinger's presentation on composing datastructures was also well done. His examples and graphics were nice as was his clarity. He also apparently read the (somewhat new age style) presentation book, that the organizers were giving to presenters, since he gave himself and the audience time to breathe! Being able to tell someone what they want to do, why they are doing it wrong, and what is the right way is a great skill.
The presentation on NLTK was a good overview of natural language processing and scaling to cloud size. Having worked in search, it is great to see such tools available in Python.
Titus' talk delivered in classic Titus style. To the point and filled with witty remarks and anti-djangoisms thrown in here and there. Hopefully he is a little gentler to his students ;)
Ned's talk on Testability was another nice presentation. He laid out the benefits and went over a few examples. As someone who talked about testable scripting last year, it was interesting to see similar ideas presented with a different spin.
The subsection of Python folks interested in testing got together again. It was both enlightening and fun. I think that most of these folks aren't "testers", but actually hackers who are interested and see the value in testing.
I presented a lightning talk on Emacs code coverage support. Apparently the intersection of emacs, python, code coverage and interest is quite small. I still think editor feedback on lack of tests (especially branch coverage) will indeed be useful. The other BoF presos were generally wonderful. If somehow this sort of energy could be channeled into panel sessions or 45 minute (or even 90 minute) lightning talk sessions on specific subjects (asynchronous, web, scientific, etc) I think it would be awesome.
Antonio Rodriguez' keynote on how Python aids a startup was well done. His main idea seemed to be, most of your people should be technical and able to wear many hats (though I don't think he phrased it that way at all).
Went to Justin Lilly's talk on customizing editors. He has also forked emacs starter kit to add Python support. Perhaps we should collaborate. I wrapped up the sessions with DJing in Python (which was a good intro to audio processing, but somewhat light on djing) and Git.
If you saw me walking around you might have wondered what was the deal with my feet. (Many people asked me, I assume others wanted to). I was wearing shoes that are supposed to emulate barefoot walking, which are called Vibram Five Fingers. Yeah, they look like monkey feet, since you have individual toes.
The premise of such shoes are that they are supposed to strengthen your feet, while normal, padded, supportive shoes weaken your feet. Yes they look weird, but they are fun to walk and run around in. Sadly when I went running in them, I didn't heed the advice to run only .25 miles at first. Since you can't comfortably heel strike while running, you use different muscles. Needless to say I was sore for a few days. (Interestingly enough, you can lightly heel strike in them while walking, which is supposed to be more efficient for the walking motion, while the opposite is true for running.) I'm somewhat rambling, but I assume others might be interested since there were at least 2-3 other folks also wearing VFFs. If you want to read more about this, check out the book Born to Run.
-1:-- [pycon] Experiences at PyCON 2010 (Post Matt)--L0--C0--February 23, 2010 10:24 PM
I have been using the Wanderlust E-mail client for almost a year now, and I am very happy with it. In previous postings I already discussed setup and some tips and tricks; and I also had somewhat related posts on bbdb (the address book) and warning you about new mail. But I think it's time for an update.
One question that I have received quite a few times was about the maintenance of Wanderlust; it's may be a nice e-mail client, but little seems to have happened in the last few years. It's reasonable concern.
Fortunately, it seems the situation has improved significantly. There's more traffic on the mailing lists, both from old and new users. Various improvements are circulating; the place to get the latest stuff is in David Abrahams' git-repository: semi, flim, apel and wanderlust. The plan is to gradually apply the changes to the upstream (CVS) repository.
Although I have been quite happy with Wanderlust, there was one bug #5534 that has bitten me a few times, causing occasional hangs when saving (draft) messages with non-ascii characters. It seemed finally to be a bug in emacs itself, which is triggered by something in Wanderlust. A fix will probably be available for the next emacs version; until then, you can work around this by using an external MIME-encoder. To do this, add the following to your WL initialization code (thanks to various helpful people on the WL mailing list):
(setq mel-b-ccl-module nil) (setq mel-q-ccl-module nil) (setq base64-external-encoder '("mimencode")) (setq base64-external-decoder '("mimencode" "-u")) (setq base64-external-decoder-option-to-specify-file '("-o")) (setq quoted-printable-external-encoder '("mimencode" "-q")) (setq quoted-printable-external-decoder '("mimencode" "-q" "-u")) (setq quoted-printable-external-decoder-option-to-specify-file '("-o")) (setq base64-internal-decoding-limit 0) (setq base64-internal-encoding-limit 0) (setq quoted-printable-internal-decoding-limit 0) (setq quoted-printable-internal-encoding-limit 0) (setq-default mime-transfer-level 8) (setq mime-header-accept-quoted-encoded-words t)
This requires the mimencode-program, which is part of the
metamail-package. For the time being, this seems to be the best solution
when using Wanderlust with Emacs 23.
Let's finish with one more trick. Sometimes, incoming mail is formatted quite badly; in particular, the new lines are too long for comfortable reading. From the WL-mailing list, here's a trick to deal with that:
(require 'filladapt) ;; from a WL mailing list post by Per b. Sederber ;; Re-fill messages that arrive poorly formatted (defun wl-summary-refill-message (all) (interactive "P") (if (and wl-message-buffer (get-buffer-window wl-message-buffer)) (progn (wl-summary-toggle-disp-msg 'on) (save-excursion (set-buffer wl-message-buffer) (goto-char (point-min)) (re-search-forward "^$") (while (or (looking-at "^\\[[1-9]") (looking-at "^$")) (forward-line 1)) (let* ((buffer-read-only nil) (find (lambda (regexp) (save-excursion (if (re-search-forward regexp nil t) (match-beginning 0) (point-max))))) (start (point)) (end (if all (point-max) (min (funcall find "^[^>\n]* wrote:[ \n]+") (funcall find "^>>>>>") (funcall find "^ *>.*\n *>") (funcall find "^-----Original Message-----"))))) (save-restriction (narrow-to-region start end) (filladapt-mode 1) (fill-region (point-min) (point-max))))) (message "Message re-filled")) (message "No message to re-fill"))) (define-key wl-summary-mode-map "\M-q" 'wl-summary-refill-message)
Now, you can refill your messages with M-q when in the Summary.
If you have any other nifty WL-tricks that could be useful for others, please share them in the comments, thanks!
-1:-- wanderlust iii (Post djcb (noreply@blogger.com))--L0--C0--February 23, 2010 06:12 PM
This is really something -- arguing that countries whose governments have pro-FLOSS policies should go on the USTR's Special 301 list because such policies are bad for the software industry and its intellectual property.
Yes, the same "property" that exists only by virtue of artificial government subsidy via temporary monopolies granted through patents and copyright.
But don't you dare give a "subsidy" for a different model of software development; certainly not one that is pro-sharing, obviating the need for these ridiculous bureaucratic processes, and is actually consistent with democratic ideals, public interest, and government autonomy.
Oh, and right, FLOSS doesn't do anything for the software industry -- that's why nearly every (perhaps every) electronic thing that people have been excited about in the last 10+ years is built on a core of free software -- TiVo, your television, the Kindle, the iPad/iPhone/iEtc, Android phones, netbooks, this company called Google, this thing called Firefox, this web site called Wikipedia, this operating system called GNU/Linux. Not like whatever makes certain people the most money should determine international policy anyway, but you get my point -- leaving aside the obvious contributions of FLOSS, even things which appear proprietary depend on or were bootstrapped by FLOSS.
Countries with pro-FLOSS public policy should go on an honor roll, not a bully hit list.
Encouraging open source could land you in trouble « TechnoLlama
As an antidote, you might like to read the FSF's comment, which I helped a bit with, and also the one submitted by EFF and Public Knowledge.
Update 2010-02-26: A recent article in the Guardian about this has been getting a lot of attention.
-1:-- Encouraging FLOSS gets you blacklisted by the USTR? (Post)--L0--C0--February 23, 2010 07:24 AM
I hang out on the EmacsChannel and other channels practically every working day. The current Give £7 for seven program gives me a T-shirt for £21. That’s a lot of money, but then again, I love IRC. 
-1:-- Support Freenode (Post)--L0--C0--February 22, 2010 01:29 PM
Ned, hooked me up with Brian Warner of Tahoe and Twisted fame. He's also got some code for highlighting coverage in emacs. Interesting to note that we both get coverage data in different ways. (Note to coverage framework writers, please implement __iter__). He was interested in my use of linum, though his use of overlay might be easier to indicate branching issues.
Non emacs (read vim) might still be interested, since they should be able to use my python code to implement similar effects in their editors. (I output to csv, brian outputs to elisp.)
-1:-- More python code coverage support for emacs (Post Matt)--L0--C0--February 21, 2010 07:46 PM
As I mentioned in my last post, I'm in the process of switching from moc to EMMS. One of the reasons for switching was that I wanted to use the Music Player Daemon (mpd), and EMMS can act as a mpd client. The prime advantage of mpd is that you can use it remotely, but it also supports gapless playback, deals with ogg and flac, and is pretty fast in extracting metadata from the music files.
The last point is really useful, because extracting metadata is something where EMMS is pretty slow. While you can drastically speed that up by using the included 'emms-print-metadata' tool, using mpd for this task is still much faster. Fortunately, EMMS can use the parsed metadata from mpd for filling its own cache.
I won't go into the details of setting up mpd. It's pretty easy anyway, I only had a few problems with getting mpd to use my ALSA dmix setup, but this was really due to my own stupidity (OK, full disclosure: dmix was set up through a .asoundrc file in my home directory, but that doesn't affect the 'mpd' user, of course. Copying .asoundrc to /etc/asound.conf or changing the user running mpd fixes this.)
So, here's my basic setup, using EMMS from the git repo:
(require 'emms-setup) (emms-devel) (emms-default-players) (require 'emms-player-mpd) (setq emms-player-mpd-server-name "localhost") (setq emms-player-mpd-server-port "6600") (setq emms-player-mpd-music-directory "YOUR MUSIC DIR") (add-to-list 'emms-player-list 'emms-player-mpd) (setq emms-source-file-default-directory "YOUR MUSIC DIR") (setq emms-volume-amixer-control "Front") (add-to-list 'emms-info-functions 'emms-info-mpd)
The only critical point is to set emms-player-mpd-music-directory to the directory you specified in mpd.conf as your music directory. The variable emms-volume-amixer-control controls which mixer channel should be used for controlling the volume; the default is to use 'Master'. Running 'alsamixer' should give you a nice overview of the available channels you can use.
When you start mpd for the first time, it should start parsing the metadata of your files. When it is finished with that, you can simply call 'emms-cache-set-from-mpd-all' to let EMMS get all the metadata it needs from mpd. This is much faster then letting EMMS do the parsing again. Whenever you add new files, just call 'emms-player-mpd-update-all' to let mpd do an update, and then dump the data into EMMS again. However, EMMS will not clear the cache beforehand, so if you delete/change files, old data will probably remain in the cache. Look here for some functions which will help you with that problem.
As usual for something running in Emacs, you can customize EMMS in every detail. Here are a few examples from my setup:
(setq emms-browser-info-album-format
'DE-emms-browser-year-and-album-fmt)
(setq emms-browser-playlist-info-album-format
'DE-emms-browser-year-and-album-fmt)
(byte-compile
(defun DE-emms-browser-year-and-album-fmt (bdata fmt)
(concat
"%i"
(let ((year (emms-browser-format-elem fmt "y"))
(artist (emms-browser-format-elem fmt "a")))
(concat
(if artist
"%cS %a - %n "
" %n ")
(if (and year (not (string= year "0")))
"(%y) "
"")))))
)
(setq emms-tag-editor-tagfile-functions
'(("mp3" "id3v2"
((info-artist . "a")
(info-title . "t")
(info-album . "A")
(info-tracknumber . "T")
(info-year . "y")
(info-genre . "g")
(info-note . "c")))
("ogg" . emms-tag-editor-tag-ogg)
("flac" . emms-tag-editor-tag-flac))))
I like to always browse albums by artist, that's why I put the artist's name in front of the album title. I also modified 'emms-tag-editor-tagfile-functions' to use id3v2, because I have tagged all my music using id3v2 instead of the older id3v1, and mpd by default also prefers id3v2 and only reverts to id3v1 if it cannot find a v2 tag. (Since the format function will be called often when building the browser buffer, it makes sense to byte compile it.)
Another reason for switching to EMMS was the support for cue sheets (I still have some cue sheets lying around before I switched to ogg/flac, which do not have any problems with gapless playback). Since I like to have the same keys to play the previous/next track, regardless whether I'm playing with a cue sheet or not, I made the following customizations:
(require 'emms-cue) (defun DE-emms-have-cue-sheet () ;; Taken from emms-cue.el (let* ((track (emms-playlist-current-selected-track)) (name (emms-track-get track 'name)) (cue (concat (file-name-sans-extension name)".cue"))) (file-exists-p cue))) (defun DE-emms-next-track-in-album () (interactive) (if (DE-emms-have-cue-sheet) (emms-cue-next) (emms-next))) (defun DE-emms-previous-track-in-album () (interactive) (if (DE-emms-have-cue-sheet) (emms-cue-previous) (emms-previous))) (global-set-key (kbd "C-c e n") 'DE-emms-next-track-in-album) (global-set-key (kbd "C-c e p") 'DE-emms-previous-track-in-album)
-1:-- Setting up EMMS with mpd (Post randomsample)--L0--C0--February 21, 2010 01:43 PM
-1:-- Emacs Tip #35: framemove (Post BFW (noreply@blogger.com))--L0--C0--February 20, 2010 08:54 AM
In my previous post I've explained how to generate a SOAP service from a WSDL file, and how to implement the required methods properly. A solution to run such a service is to use the Twisted Daemon, aka twistd.
Though not needed, strictly speaking, it provides a nice set of features aimed at easing complex applications development.
In particular, it allows to write so-called plugins that make it possible to just launch services in the following way:
$ twistd echo
To achieve that, one has to create a file twisted/plugins/echo.py accessible somewhere from the python path (that is, the twisted directory should be a subdir of an element of the path).
Twisted offers a nice service, that can be used to provide an inspection/debug interface for your main application. This is called manhole and provides a python interpreter interface. This way you can just telnet/ssh the manhole, and execute appropriate commands to introspect the current state of the application, or put it in the desired state.
A nice example of a really useful function to run from the manhole service is the rebuild one. It tries very hard to provide in-place reloading of code (and corresponding objects). Don't expect any wonder here, it will fail in some corner cases. Still, it proves really useful most of the time, and helps a lot not restarting the server every now and then.
Here is a fully working example of a twistd plugin for the Echo service, with a functional manhole service in addition.
from zope.interface import implements from twisted.python import usage from twisted.python.rebuild import rebuild from twisted.plugin import IPlugin from twisted.application.service import IServiceMaker, MultiService from twisted.application.internet import TCPServer from twisted.web.server import Site from twisted.web.resource import Resource from twisted.conch.manhole_tap import makeService as makeConsoleService from EchoImpl import EchoService class EchoOptions(usage.Options): optParameters = [["port", "p", 8080, "main port", int], ["service-port", "s", 8081, "service port", int], ["service-users", "u", "/etc/passwd", "The path to a passwd-like authentication file"]] class EchoServiceMaker(object): implements(IServiceMaker, IPlugin) tapname = "echo" description = "Sample Echo service" options = EchoOptions def makeService(self, options): # Create Service srv = EchoService() root = Resource() # we'll serve Echo at http://<ip>:<port>/echo root.putChild('echo', srv) siteFactory = Site(root) echo_service = TCPServer(options['port'], siteFactory) console_service = makeConsoleService( {"telnetPort": str(options['service-port']), "sshPort": None, "namespace": {"service": srv, "rebuild": rebuild}, "passwd": options['service-users']}) svc = MultiService() echo_service.setServiceParent(svc) console_service.setServiceParent(svc) return svc serviceMaker = EchoServiceMaker()
The code is hopefully rather straightforward. It should be noted that the manhole service (created by the makeConsoleService() call) needs to know about a set of objects (the “namespace” key). Those objects are the roots for everything accessible from the service. Here, the main service object (the srv object) is available to the manhole under the name service. Here is how it can be used:
$ telnet localhost 8081 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Username: yann Password: x >>> print service <EchoImpl.EchoService object at 0x2fc8c10> >>>
Hint: the password is really 'x', as I'm using /etc/passwd by default, which contains 'x' for every “password” field, since the real passwords are in /etc/shadow. Convenient for a dev deployment ;)
-1:-- Python Webservice, part 2 : a twistd integration (Post Yann Hodique)--L0--C0--February 18, 2010 11:01 PM
(defun jabber-presence-yrk-message (who oldstatus newstatus statustext)
"Slightly shorter replacement for
`jabber-presence-default-message' which doesn't display
STATUSTEXT."
(cond
((equal oldstatus newstatus)
nil)
(t
(let ((formattedname
(if (> (length (get who 'name)) 0)
(get who 'name)
(symbol-name who)))
(formattedstatus
(or
(cdr (assoc newstatus
'(("subscribe" . " requests subscription to your presence")
("subscribed" . " has granted presence subscription to you")
("unsubscribe" . " no longer subscribes to your presence")
("unsubscribed" . " cancels your presence subscription"))))
(concat " is now "
(or
(cdr (assoc newstatus jabber-presence-strings))
newstatus)))))
(concat formattedname formattedstatus)))))
(setq jabber-alert-presence-message-function
'jabber-presence-yrk-message)
-1:-- More emacs-jabber.el tweaks (Post)--L0--C0--February 18, 2010 07:37 AM
As mentioned previously I've been spending some time recently working on a SOAP server mock. For this I've used Python Twisted and ZSI. Since the interaction between the 2 seems rather poorly documented (even Google doesn't know much about it), I thought I'd share what I've investigated and done.
Disclaimer: you should be familiar with SOAP and Python Twisted. I'll not cover anything in these areas.
For the sake of simplicity, I'll take a classical minimal server: an Echo service.
Let's start from the definition of such a service, as a WSDL. This one was randomly picked from there Anyway the implementation details are not so important here.
<?xml version="1.0" encoding="UTF-8"?> <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:ZSI" targetNamespace="urn:ZSI" > <types> <xsd:schema elementFormDefault="qualified" targetNamespace="urn:ZSI"> <xsd:element name="Echo"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:anyType"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> </types> <message name="EchoRequest"> <part name="parameters" element="tns:Echo" /> </message> <message name="EchoResponse"> <part name="parameters" element="tns:Echo"/> </message> <portType name="EchoServer"> <operation name="Echo"> <input message="tns:EchoRequest"/> <output message="tns:EchoResponse"/> </operation> </portType> <binding name="EchoServer" type="tns:EchoServer"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="Echo"> <soap:operation soapAction="Echo"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </binding> <service name="EchoServer"> <port name="EchoServer" binding="tns:EchoServer"> <soap:address location="http://localhost:8080/echo"/> </port> </service> </definitions>
So really nothing fancy here. Just the definitions and shape of the messages/operations (only trivial ones).
ZSI offers the wsdl2py tool, that can process such WSDL files, and produce client bindings and server stub. In this article, the server part is what we want. (note the -w flag will trigger Twisted code generation)
$ wsdl2py -w echo.wsdl
EchoServer_server.py now contains the code for the service stub. Not much in there, the main part being the following method:
def soap_Echo(self, ps, **kw): request = ps.Parse(EchoRequest.typecode) return request,EchoResponse()
This is the one we should implement to make the service concrete. Here is a first attempt:
class EchoService(EchoServer): def __init__(self): EchoServer.__init__(self) def soap_Echo(self, ps, **kw): request, _ = EchoServer.soap_Echo(self, ps, **kw) return request, request
That will work. If you register this Service as a Twisted Resource, it will provide a functional SOAP Echo service, on which you can execute the following.
$ POST http://localhost:8080/echo Please enter content (application/x-www-form-urlencoded) to be POSTed: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body xmlns:ns1="urn:ZSI"> <ns1:Echo> <ns1:value xsi:type="xsd:string">plop</ns1:value> </ns1:Echo> </soapenv:Body> </soapenv:Envelope> ^D <soapenv:Envelope xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header></soapenv:Header><soapenv:Body xmlns:ns1="urn:ZSI"><ns1:Echo><ns1:value xsi:type="xsd:string">plop</ns1:value></ns1:Echo></soapenv:Body></soapenv:Envelope>
Still, this is not very Twisted… I mean we don't take advantage of the asynchronous framework here, as the only method we wrote is definitely synchronous and we treat each call after one another. Would the soap_Echo() take time for whatever reason, that would introduce unacceptable delays for the user.
Of course, there is no magic in the Deferred objects, which means than simply returning a Deferred in soap_Echo() will absolutely not work.
Digging a bit more in the ZSI Twisted glue, one can find a promising piece of code, appropriately named DeferHandlerChain. This is an alternative to the DefaultHandlerChain that's used (by default) by WSresource objects (hence EchoServer ones). The nice property of this handler chain is to put in place a callback chain from processRequest() to processResponse(), actually supporting Deferred objects returned by soap methods. In a word, what we need…
The code can become something like:
class EchoDeferHandlerChainFactory: protocol = DeferHandlerChain @classmethod def newInstance(cls): return cls.protocol(DefaultCallbackHandler, DataHandler) class EchoService(EchoServer): def __init__(self): EchoServer.__init__(self) EchoServer.factory = EchoDeferHandlerChainFactory def soap_Echo(self, ps, **kw): request, _ = EchoServer.soap_Echo(self, ps, **kw) def _answer(): return request # yeah, we have a very busy echo service... 5 seconds delay ! d = deferLater(reactor, 5, _answer) return request, d
You can now try triggering several parallel Echo calls, and see that they will not be treated in sequence !
-1:-- Python Webservice, part 1 : a Twisted solution (Post Yann Hodique)--L0--C0--February 17, 2010 07:20 PM
-1:-- better as3 (Post sness (noreply@blogger.com))--L0--C0--February 15, 2010 06:17 PM
(Maybe the following already exists - if so, please let me know in the comments.)
I'm in the process of switching from moc to EMMS, and so far I'm pretty happy with it. However, there's one feature in moc which I'm missing, and that is a special type of interactive search: While you type a search string in moc, you do not just jump to the first matching title, but the list of titles is reduced to those matching the current search. In Emacs-speak, you might name this an "interactive occur".
While I couldn't exactly find this kind of search, I stumbled upon loccur; while the the normal occur-mode opens a new buffer with the matching lines, loccur-mode works directly in the buffer you're currently working with. So, the only task remaining is to hook loccur into isearch. This is what I came up with:
(require 'loccur) (defadvice isearch-update (after DE-call-loccur ()) (let ((loccur-mode nil)) (loccur-mode (regexp-quote isearch-string)))) (ad-activate 'isearch-update) (add-hook 'isearch-mode-end-hook (lambda () (loccur-mode nil)))
I had to use 'defadvice' since there's no hook in isearch-update I could use instead.
Now, you only have to put loccur.el into your load-path and evaluate the above code snippet. When you now call up isearch, all lines which do not currently match your search string will be hidden. To deactivate this feature, just do
(ad-deactivate 'isearch-update)
-1:-- Combining isearch with loccur ("interactive occur") (Post randomsample)--L0--C0--February 14, 2010 06:07 PM
I’m glad to announce this new release of identica-mode after a longer than normal. I’ve been constantly directing people to the git repository version instead of doing an official release since there are lots of improvements since the last version.
Some of these improvements include:
You can now do url shortening while typing your update by pressing <f4> key with the cursor at any point of the url text. I’ve wanted to implement this feature using any free url shortening services, but unfortunately the only two I know (ur1.ca and tighturl) don’t have APIs to easily do this. So for now, I’ve implemented it with tinyurl.
In an effort to make identica-mode more keyboard only friendly, we’ve done a couple of changes:
You will notice that now when pressing <enter> on any link in the timeline will take you to either the user’s page, the notice’s page, the url at point, and lastly if there’s no url at point, will do a reply to that notice.
The other thing you will notice is that by pressing <tab> you can now jump the cursor to the next link on the timeline.
The methods to follow and unfollow users in the timeline has been added. You can easily access them through the menu or execute M-x identica-follow, M-x identica-unfollow.
To prevent spamming groups with repetitive messages, all group tags are replaced with hastags on redents.
Now by pressing “F” key you can favorite the dent under the cursor. It has been improved by adding a visual confirmation question so you don’t end up adding dents as favorites without noticing.
I’m very happy to recieve code contributions and this version has recieved the most so far. Lots of little enhancements and code cleanup has been done, removing several of the little annoyances and error messages that were appearing every now and then. I’d like to thank Sean Neakums, Jason McBrayer and Shyam Karanatt for their contributions.
</tab></enter></f4>
Get the lastest version of Emacs Identica-mode
And as always, code contributions and bug reports are welcome on our bug reporting page.
Also, if you like the project you can also support it with a small donation.
Related posts:
-1:-- Emacs Identica-mode v0.9 release (Post Gabriel Saldaña)--L0--C0--February 13, 2010 11:58 PM
I do a lot of hacking on Python these days, and of course, I use Emacs. The built-in python-mode has the ability to run pychecker on your source, but doesn’t integrate other tools. I like to run pep8.py & pylint regularly to keep my code clean, so I hacked together compilation-derived modes to drive them.
Compile.el is really great for this kind of thing, since it lets you quickly navigate over the lines mentioned in the program’s output. It’s quite efficient, and I enjoy it immensely. One note of interest: pep8.py doesn’t output line numbers in order, which confuses compile-mode. I just pipe the output through sort to work around this.
The code is on GitHub: python-pep8.el and python-pylint.el.
-1:-- pep8 & pylint in Emacs (Post Ian)--L0--C0--February 12, 2010 07:02 PM
I sometimes kick people from the Emacs channel on IRC. Often I am dragged into long discussions of whether I abused my power or not.
Then I get stuff like this:
16:59 !!! consolers sent unsupported ctcp: FUCKOFFANDDIE 14:57 !!! consolers sent unsupported ctcp: EATSHITANDDIE
/
?
-1:-- Lunatics on the Emacs Channel (Post)--L0--C0--February 12, 2010 02:13 PM
I’ve been spending the last week hacking around in Java. One of the components of the product I develop is the open source OpenNMS. As I’ve mentioned before it’s been lightly modified by myself to blend in better with our code mainly in the JSP department for it’s web interface. Last week I discovered I needed to make a slightly deeper change to the code to export some more data to it’s scripting interface.
While I was exploring the code base and scratching my head at some of the exceptions being thrown I thought I’d have yet another go at making my Java development environment a little more integrated than binding the build script to “C-c c”.
So far I have a couple of observations about Java code. The first is that it never seems to do very much. As you navigate the code base you tend to find a lot of simple skeleton classes, usually working as simple adaptors between one framework and the next. Thanks to Java’s strong support for generics and interfaces you often find yourself looking at a class wondering what else it might do. None of this is helped by Java’s standard/deep/directory/naming/strategy/of/doom. My usual tools of a decent programmers editor and grep start to show their limitations. Java is a language that is designed to be serviced by a full IDE to help you make sense of the whole system.
Having previously tried and failed to get JDEE working I thought I would capitulate and try Eclipse. I blithely thought that given the fact it’s the standard Java developers tool with a long development history it would Just Work ™. I was to be sorely disappointed.
I tried several different versions on both my home Gentoo machine as well as various PPA based versions on my work Ubuntu setup. A lot of times it failed to start up due to some Mozilla dependency issues and when I did finally get it started I couldn’t get any of the plugins to install. The entire Eclipse stack is designed around the concept of plugins and it seems every Java framework comes with it’s own additional plugin for Eclipse. Without the plugins I wasn’t able to get a working build or any sort of source level debugging. Eventually I had to concede defeat and bin the IDE approach and return to some tedious grep work and piece together the structure of the software by hand so I could finally crank out what in the end was a fairly simple patch. I doubt I shall return to Eclipse.
I did have a brief tinker with JDEE which at least installed better from it’s SVN repo (needing a one line patch). However the documentation is a little sparse on how to import an existing large project into it’s view of the world. Annoyingly potentially useful links like the FAQ referenced on the main site lead to dead ends. I never got to the point of seeing if I had a working Java GUD integration. I hope to revisit JDEE in the future when I’m a little less pressed for time at work. It’s hard to work up the enthusiasm for plumbing in support for a language you never intend to use for fun in your own time.
-1:-- Thoughts on Java (Post Alex)--L0--C0--February 12, 2010 11:18 AM
-1:-- Emacs Tip #34: line-beginning-position, line-end-position (Post BFW (noreply@blogger.com))--L0--C0--February 12, 2010 01:26 AM
Version 1.3.1 of mk-project.el is available from github or the Emacs Wiki. David Findlay reported that project-grep and project-ack where running from the project basedir's parent directory, not the project basedir. This behavior was possible on certain versions of Emacs if the project's basedir didn't include a trailing slash -- like this:
(project-def "test-project" ((basedir "/home/me/test-project") ; no trailing slash ... ))
The new version ensures that the trailing slash is appended to basedir when it is used as the default-directory value.
Thanks much to David for the bug report and helping me test potential solutions!
-1:-- Announce: mk-project 1.3.1 (Post)--L0--C0--February 10, 2010 06:59 AM