Month: October 2016

Copy and paste files with dired-ranger

I’ve written before about managing files in Emacs using dired. The package dired-ranger provides a useful extension to dired, allowing you to copy and paste files much like you can do in traditional GUI file explorers.

First, install dired-ranger with something like the following

(use-package dired-ranger
  :ensure t
  :bind (:map dired-mode-map
              ("W" . dired-ranger-copy)
              ("X" . dired-ranger-move)
              ("Y" . dired-ranger-paste)))

This also sets up some useful keybindings. Now in a dired buffer, you can mark multiple files and then hit W to copy them (really they are added to a copy ring). You could then optionally go to another directory and mark more files and hit C-u W to add those to the same entry in the copy ring as the previous files. This builds up a virtual collection of files that you can then copy or move. Now go to the target directory and hit X to move the copied files to that directory (i.e. they are deleted from their original location) or Y to copy the files to the target directory (the originals remain where they were).

You can achieve similar results using dired-dwim-target or Sunrise Commander, but this method clicks with me and is the one that I use.

Fun with fonts

I’ve been playing around with some different fonts to see how they look in Emacs. For a long time I’ve been using DejaVu Sans Mono, but I felt like a change. It’s easy to switch the font for the current frame, just use M-x set-frame-font and enter the name of an installed font, or put a line like this

(set-frame-font "DejaVu Sans Mono-14" nil t)

in your scratch buffer and put the cursor at the end of the line, and use C-x C-e to run eval-last-sexp which evaluates that bit of code. This will instantly change the appearance of the current frame.

Here are some of the fonts I’ve been trying out (I installed them using the Font Book on my Mac):

(set-frame-font "DejaVu Sans Mono-14" nil t)
(set-frame-font "Fantasque Sans Mono-16" nil t)
(set-frame-font "Source Code Pro-14" nil t)
(set-frame-font "Monaco-14" nil t)
(set-frame-font "Cousine-14" nil t)

I’ve decided to go with Google’s Cousine font at the moment, so I add the following to my emacs config file to make the choice permanent:

(setq default-frame-alist '((font . "Cousine-14")))

mu4e-delay is dead, long live mu4e-send-delay

A while ago I wrote mu4e-delay, a package (based heavily on gnus-delay), to add a customisable delay to outgoing mail so that a sent email could be “undone” before the delay period had passed. This was spectacularly useful for me, but now Benny Andresen has put together the superior mu4e-send-delay, which improves on my package in several ways.

The key features of mu4e-send-delay are (from the github page):

  • mu4e context support
  • Saves scheduled mails to mu4e-drafts-folder
  • Uses an emacs timer to check Drafts if a mail is scheduled to be sent now
  • Allows easy edit of the X-Delay header in mu4e-compose-mode
  • Displays scheduled time in mu4e-view
  • Doesn’t send if mail is currently being edited
  • Works with attachments

The last four points are all improvements over the original mu4e-delay, with the last two being the most important. I’d encourage any mu4e-delay users to switch over to mu4e-send-delay. I have, and I’ve not looked back!

Transpose a table in org-mode

I recently needed to transpose a table in org-mode and spent a few minutes trying to come up with a keyboard macro to do it before it occurred to me that there might be a command to do this already. And of course there was: M-x org-table-transpose-table-at-point. Here it is in action:

transpose-table.gif

It’s great when there’s a command that does exactly what you want!

Open files with the system default application

I’ve mentioned crux before; it’s a package providing a set of general-purpose useful commands. One that I use all the time is crux-open-with, which opens the file currently being visited (or the file at the point in a dired buffer) using the system default application for that filetype. It works on Mac or Linux, by using the open or xdg-open commands respectively.

I bind the command to C-c o, using the following code (which also binds the previously mentioned crux-move-beginning-of-line)

(use-package crux
  :bind (("C-c o" . crux-open-with)
         ("C-a" . crux-move-beginning-of-line)))