May 30, 2013

fvwm-mode now on GitHub

Posted in Emacs, FVWM at 02:15 by theBlackDragon

This is just a short update to announce that fvwm-mode has moved from my internal Subversion repository to GitHub after a request to update the headers to conform to Emacs standards for the EmacsmirrorĀ , the net result of this are two things:

  • I was reminded of a bunch of stuff I still wanted to do/fix in fvwm-mode, so it might even get done (I’ve already fixed some deprecation warnings, properly supporting lexical binding is next on my list)
  • fvwm-mode ended up on GitHub as that’s easier for the Emacsmirror to, well, mirror compared to some file on some webserver that I sometimes update.

I didn’t bother retaining the original version history as the interesting bits are in the NEWS file anyway.

The fvwm-mode repository resides here.

Advertisements

November 2, 2011

Making Gnus archive sent mail to an IMAP folder

Posted in Emacs, Gnus, Linux at 17:30 by theBlackDragon

Earlier searches lead me to believe that storing sent mail on an IMAP folder was not feasible with Gnus.

So I was pleasantly surprised that setting:

; Store sent mail in a server IMAP folder on a per year basis
(setq gnus-message-archive-group
      (format-time-string "nnimap+superbia:INBOX.Sent.%Y"))

just worked(tm)

Where “superbia” is the name of my IMAP server in my Gnus config.

Performance seems OK so far, so we’ll see how it turns out in the long run.

July 5, 2011

Move line to end of file and comment

Posted in Emacs, Java at 15:40 by theBlackDragon

I had to work on a bunch of translation Java property files in an ancient J2EE project that had old translations in between the new ones resulting in a hardly readable mess that confused the hell out of Netbeans’ property file editor plugin, so I decided to just move all those old lines to the bottom of the file and comment them out.
For this I quickly hacked up two elisp functions

(defun move-line-to-end-of-file ()
  "Move the current line to the end of the file."
  (interactive)
  (save-excursion
    (beginning-of-line)
    (kill-whole-line)
    (end-of-buffer)
    (yank-as-comment)))

(defun yank-as-comment ()
  "Yank the last killed selection as a comment, but leave text 
  alone that is already a comment according to the current mode."
  (interactive)
  (save-excursion
    (yank)
    (if (not (comment-only-p (mark) (point)))
        (comment-region (mark) (point)))))

There probably is a much more idiomatic way to do this (which I’d love to hear about), but this seems to work just fine for my use. Note however that move-line-to-end-of-file will just append to the last line if the file doesn’t end with a newline (which isn’t an issue in my case).

June 3, 2007

GNU Emacs 22.1 released!

Posted in Emacs, Linux, Techie stuff at 11:26 by theBlackDragon

This morning I check in on #fvwm and the first thing I notice is the following:

03/06|01:03:06 < Hun> theBlackDragon: aaaaaaaaaaah!
03/06|01:03:13 < Hun> e22 has been released!

So I run off to the Emacs homepage, but nothing to be found about a new release. Hmm.
So what can you do? Check usenet of course, and sure enough on gnu.emacs.devel (e-mail addresses removed for obvious reasons):

From: David Kastrup <*@*>
 Subject: Re: Cygwin binaries for Emacs-22.1 released!
 Newsgroups: gmane.emacs.devel
 To: Angelo Graziosi <*@*>
 Cc: emacs-devel@gnu.org
 Date: Sat, 02 Jun 2007 21:18:05 +0200
Angelo Graziosi <*@*> writes:
> Cygwin binaries for 22.1 release here:
 >
 >    http://www.webalice.it/angelo.graziosi/Emacs.html
I was going to mouth off about premature announcements and being
 careless about release numbers, but checking on the ftp server have
 found that the tarball for Emacs 22.1 has been uploaded.
Did I miss the announcement on this list?
--
 David Kastrup

And sure enough, there it was, on the GNU FTP server, all shiny and new: an Emacs 22.1 tarball, the changes from 21.x are a little bit too numerous to sum up here, I’d say just upgrade or read the ChangeLog.

January 21, 2007

Emacs tips #4: the Emacs Lisp REPL

Posted in Emacs at 16:40 by theBlackDragon

Everybody knows you can evaluate elisp expressions in the scratch buffer, but a lot less people seem to be aware of ielm the interactive Emacs Lisp mode, this mode opens a sort of Emacs REPL that allows you to work with Emacs Lisp much in the same way you’d do at a Common Lisp REPL.

Another little known fact is that you can evaluate elisp expressions at the eshell prompt, just try typing (+ 12 9) and hitting return. Spiffy eh? But you’ll quickly run into eshell’s elisp limitations: it doesn’t correctly indent code so it’s not really useful for ‘real’ elisp hacking, ielm is much better suited for that purpose as it does corretly indent elisp code.

December 29, 2006

Emacs tips #3 : automatically making scripts executable

Posted in Emacs at 15:01 by theBlackDragon

I don’t remember where I found this snippet (maybe comp.emacs) but it’s mighty useful so I thought I’d share it with you:

; Sets +x on scripts stating with a shebang
(if (< emacs-major-version 22)
       (add-hook 'after-save-hook
                 '(lambda ()
                    (progn
                      (and (save-excursion
                             (save-restriction
                               (widen)
                               (goto-char (point-min))
                               (save-match-data
                         (looking-at "^#!"))))
                           (shell-command (concat "chmod u+x "
                             buffer-file-name))
                           (message (concat "Saved as script: "
                             buffer-file-name))))))
       (add-hook 'after-save-hook
         'executable-make-buffer-file-executable-if-script-p))

Emacs versions below 22 need the former, longer method while Emacs 22 can use the oneliner in the last line.

September 3, 2006

Antialiased Emacs (using XFT)

Posted in Emacs at 16:57 by theBlackDragon

There are a couple of resources describing how to get Emacs 23 (aka “the unicode branch”) display antialiased fonts (see here for starters).

So building on my previous post on installing Emacs 23 from CVS you need to use this configure command:

./configure --prefix=/home/theBlackDragon/local --program-suffix=.emacs-23 --with-gtk --enable-font-backend --with-xft --with-freetype

You’ll need to start it like this for example:

emacs-23 --enable-font-backend --font "Bitstream Vera Sans Mono-12"

You can use an Xresource for the font if you like, but the –enable-font-backend switch is mandatory.

May 12, 2006

Portable Emacs

Posted in Emacs at 13:07 by theBlackDragon

While reading gmane.emacs.help I came accross this post where somebody asked how he could make a portable app out of Emacs' Windows version.

So since I'm still at my internship (where they use Windows) and just recently obtained an iAudio X5L portable media player which behaves like an USB2 harddisk to the OS I wondered if I could manage to make Emacs portable.

Short version: I could, the "hardest" part was in fact not even Emacs related, but my sheer lack of knowledge about Windows batch script.

I started by creating a "SOFT" folder on my external drive (named E: by Windows on this box) and extracted the altest Emacs build from the ntemacs project in this directory, thus creating "E:\SOFT\emacs" with all the usual subfolders.

Next I created a site-lisp/site-start.el file and added the following as suggested on usenet:

(let ((home (concat (substring (car command-line-args) 0 2) "/SOFT")))
  (setq user-init-file (concat home "/config/.emacs"))
  (setq auto-save-list-file-prefix (concat home "/config/.emacs.d/auto-save-list/.saves-")))

You'll need to adapt this to your particular environment of course.

This makes Emacs load my user-init-file (aka ".emacs") from "E:/SOFT/config/.emacs" and moves the auto-save-list to the external device as well, this should be superfluous though as I change the location of HOME as described later, but it accounts for the cases that you don't want to change your HOME.

This is in fact the entire Emacs side of the story, though you will probably have some work making your elisp packages work with relative paths if you didn't take that into account before.

Now you need to redefine HOME in Windows (well, you don't need to but I find it useful), you can either do that globally with the System Properties or autoexec.bat in DOS based Windows versions, but I preferred to make it dynamic by writing a wrapper batfile that sets this variable and then launches Emacs. I named it runemacs.bat (how appropriate;)) and put it in Emacs' bin directory, the content looks like this:

set HOME=%CD%\..\..\config
runemacs

That's it! You can now run Emacs entirely from your external drive!

May 11, 2006

Emacs tips #2 : linenumbers

Posted in Emacs at 11:25 by theBlackDragon

A question that pops up pretty often is how you can add line numbers in the margin of your files the way most other editors do.

There are actually two ways of doing this:

  • adding the numbers in the margin
  • adding the numbers to your files, so that they get saved with your file, might be useful in certain cases (COBOL source?)

Unfortunately Emacs doesn't support either out of the box, but fortunately people have written modes that do exactly this. Modes for both the former as the latter can be found on the EmacsWiki.

Personally I (occasionaly) use setnu.el which works extremely well for my purposes.

May 4, 2006

Emacs tips #1

Posted in Emacs at 14:57 by theBlackDragon

I've been using Emacs for some time now but have only recently started to heavily customize it. With this I've also started tracking (or more actively tracking) various Emacs related resources, picking up useful bits of information along the way. I'll try to share the most useful ones here with you on a (hopefully somewhat) regular basis.

I'll kick off with a very short one, the next line enables "focus follows mouse" on Emacs windows (not frames, frames are handled by the window manager).

(setq mouse-autoselect-window t)

So what is "focus follows mouse" anyway? Basically it means that the window your mouse pointer is over receives focus (input) so you don't need to click on it to give it focus (as you have to in, say, Windows). Some people find this confusing, most people can't live without it once they get used to it.

For more information on "focus follows mouse" see here.

Next page