Today I stumbled upon this very useful emacs hackery:
http://andy.wordpress.com/2013/01/03/automatic-emacsclient/
I think I fell in love with this solution
Today I stumbled upon this very useful emacs hackery:
http://andy.wordpress.com/2013/01/03/automatic-emacsclient/
I think I fell in love with this solution
I receive a fair amount of VCALENDAR requests on my regular payjob. Unfortunately these mail messages do not display correctly on Gnus as there is no inline display support for text/vcalendar mime types yet. These messages are not intended to be read by human being of course, so I created the following little snippet in order to get them displayed inline in the Article buffer of Gnus.
(require 'icalendar) (setq display-calendar-debug t) (defun mm-inline-text-calendar (handle) (let (text) (with-temp-buffer (mm-insert-part handle) (save-window-excursion (setq text (parse-vevent (icalendar--read-element nil nil))))) (boxquote-text text) (if display-calendar-debug (mm-insert-part handle) nil) (mm-insert-inline handle ""))) (defun parse-vevent (temp) (setq elems '(ORGANIZER ATTENDEE SUMMARY LOCATION DESCRIPTION)) (setq result (icalendar--all-events temp)) (setq e (car result)) (setq result (cdr result)) (let (value) (dolist (el elems) (setq value (format (concat "%s:%s\n" value) el (icalendar--get-event-property e el)))) value))
I have a long list of TODO with regards to the above snippet:
I hope to complete at least 2 of the above before 2012 kicks in!
Enjoy!
While developing a python script that interacts with a database through Django’s ORM, I noticed that my process’s RSS was constantly growing reaching 1.2GB upon the task’s completion.
After googling this around, the problem to this was that the “DEBUG” configuration option in settings was set to ‘True’. Obviously the workaround to this was to either turn it to False OR issue a ‘db.reset_queries()’.
The reason this is not observed in a web environment is that Django does the db.reset_queries() after an HTTP request.
Link: http://stackoverflow.com/questions/1339293/python-memory-leak-debugging
I’ve used several MUAs in the last 9 years, from Mutt and Pine to Thunderbird, Evolution and Kmail. But there is one MUA that helped me manage and use email efficiently. I won’t go into the discussion into why I dumped the other mail clients I used. I just know that I ended up using Gnus. And I’m happy with that (most of the time). Now, I’ve stayed with gnus for quite some time now that I consider myself ready to BLOoaagh about tips and tricks that help me survive!
While this article was still a draft (a 6 month draft that is), I had written 3-4 paragraphs with some introductory stuff about Gnus. I decided not to include them in this post, for chances are that if you arrived here you already know what Emacs and Gnus is! (OK, maybe not, but I want an excuse for me being lazy).
In the meantime, the guy over at www.mostlymaths.net published a couple of posts which adequately sum up a good part of my Emacs/Gnus configuration. You can find the two links here: http://www.mostlymaths.net/2010/12/emacs-30-day-challenge-using-gnus-to.html and http://www.mostlymaths.net/2010/12/emacs-30-day-challenge-get-latest-gnus.html.
Although, I do not recommend using the latest Gnus yet if you are not the bleeding edge-git-pull guy, you might find the reworked nnimap backend better suited to your needs.
Now in this blog post I want to show you how to configure and use EUDC along with your BBDB and LDAP directories. Why would I want something like that? Well, in my workplace our Exchange server has an LDAP directory which contains all the email addresses etc of colleagues. Since I send emails using Gnus for both personal and work related issues, it would be nice if I could query and obtain email addresses both from BBDB and LDAP in a somewhat ‘integrated’ way.
The initial target was to get TAB do email/name completion/cycling on the To/CC/Bcc headers in the message-mode using the BBDB as it’s primary query ‘server’. If the name could not be completed by any of the BBDB entries, then the EUDC should query the next server in it’s hotlist.
First thing I do towards this end is to configure the BBDB. Just a side note, I’m using BBDB version 2.35 however it should not matter since this version is already 3 years old and most distributions should have catched up by now:
(require 'bbdb) ;; We initialize BBDB for GNUS and message-mode (which is used by Gnus to compose mail) (bbdb-initialize 'gnus 'message) (add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus) (setq bbdb-use-pop-up nil bbdb-notice-auto-save-file t bbdb-pop-up-target-lines 10 bbdb-send-mail-style 'message)
and here is the relevant EUDC/LDAP configuration:
;; ;; EUDC/LDAP/BBDB integration black magic ;; (setq ldap-host-parameters-alist (quote (("ip-address-of-server" base "dc=KOMPANY,dc=com" binddn "KOMPANY\\ltsampros" passwd "PASSWORD")))) (require 'eudc) (setq eudc-default-return-attributes nil eudc-strict-return-matches nil) (setq ldap-ldapsearch-args (quote ("-tt" "-LLL" "-x"))) (eudc-protocol-set 'eudc-inline-expansion-format '("%s < %s>" displayName email) 'ldap) (eudc-protocol-set 'eudc-inline-query-format '((cn) (mail) (cn cn) (cn cn cn) (sn) (uid) (givenName) (givenName name) (name)) 'ldap) (eudc-protocol-set 'eudc-inline-expansion-format '("%s %s < %s>" firstname lastname net) 'bbdb) (eudc-protocol-set 'eudc-inline-query-format '((name) (firstname) (lastname) (firstname lastname) (net)) 'bbdb) (eudc-set-server "localhost" 'bbdb t) (setq eudc-server-hotlist '(("localhost" . bbdb) ("ip-address-of-server" . ldap) ) ) (setq eudc-inline-expansion-servers 'hotlist) (defun enz-eudc-expand-inline() (interactive) (if (eq eudc-protocol 'ldap) (progn (move-end-of-line 1) (insert "*") (unless (condition-case nil (eudc-expand-inline) (error nil)) (backward-delete-char-untabify 1) )) (eudc-expand-inline)) ) ;; Adds some hooks (eval-after-load "message" '(define-key message-mode-map (kbd "TAB") 'enz-eudc-expand-inline))
In the above snippet, the first thing I do is to setup myldap-host-parameters-alist. Please notice, that we do this before we pull in the actual ‘eudc library. For some reason that I didn’t manage to investigate, having these statements in reverse order will give you a ‘No search base defined. Configure it now?’ yes-or-no prompt.
The rest of the settings are pretty common: query and expansion formats per protocol, then we setup our default server for doing queries and finally our server hotlist and how the inline expansion should work.
At the end of the configuration we setup enz-eudc-expand-inline (note: this function is not mine but I found it on the emacswiki. See the end of the article for attributions) which is a handy function I use all the time because originally and in order for the ldap inline expansion to work correctly one has to enter the wildcard character * manually and then do eudc-expand-inline which is cumbersome. For example, this is what you had to do:
To: ExampleNameNotInBBDB1 ExampleSurName* TAB
and then select from the competion buffer the matching names. The original enz-eudc-expand-inline function found here addresses the issue by entering the char ‘*’ automatically and then call the original ‘eudc-expand-inline’ one.
However, I discovered that this didn’t work with bbdb completion so I expanded it by checking if the current eudc-protocol is ldap (for which case we use the nifty asterick trick) or else it simply calls eudc-expand-inline.
Finally, we bound this func to TAB on the message-mode.
Now completion works like this:
Case 1:
To: MatchInBBDB TAB (expands directly or asks if multiple matches in BBDB)
Case 2:
To: NotAMatchInBBDB TAB (miniprompt with LDAP results)
I should note that this configuration is not actually my work/inspiration but it’s derived from this guy here and the EmacsWiki/EUDC article. So, I have to thank them both!
Final note: I had to apply this patch here as I was getting in the LDAP results a strange ” <>” result that was getting on my nerves. A hack, but it works for now:
diff -u -L /usr/share/emacs/23.1/lisp/net/eudc.el.gz -L /tmp/buffer-content-10175gkO /tmp/jka-com10175tuU /tmp/buffer-content-10175gkO --- /usr/share/emacs/23.1/lisp/net/eudc.el.gz +++ /tmp/buffer-content-10175gkO @@ -382,7 +382,7 @@ (let ((replacement)) (setq replacement (completing-read "Multiple matches found; choose one: " - (mapcar 'list choices))) + (mapcar 'list (delete " <>" choices)))) (delete-region beg end) (insert replacement))) Diff finished. Fri Jan 14 19:58:01 2011