… and I thought I would never jump on that bandwagon, but here I am. I get a significant amount of my traffic from people twittering — so why not?
Follow me here:
Seems there’s a new kid in town.
Fabián Ezequiel Gallina has announced a new Emacs mode to, I hope, merge with the existing GNU Emacs mode (referred to as
python.el) and possibly merge with the other Emacs mode out there (referred to as
python-mode.el) and bring balance to the force.
This is great news. I have been meaning to write an article covering All Things Python in Emacs and if I can do that and only cover one mode that’ll make my life a whole lot easier. Currently the Emacs-Python community is way too fragmented due to license issues with
python.el not keeping up with the times.
Altering the key bindings in Emacs should not, on the face of it, be a difficult task. But there’s a reason why the Emacs manual has dedicated 30-odd pages to describing, in great detail, all the subtleties and nuances of how to bind keys.
To save you the time of reading all of that, I’ve written a guide that covers what you need to know to bind keys to even complex commands, and a set of templates you can use in your own code.
I bet the majority of files you edit on a day-to-day basis are the same ones over, and over again. For that reason I recommend you use Emacs’s
recentf package, it is a great — and very sophisticated, like all things Emacs — utility that keeps track of recently used files.
recentf by adding Ido mode support (if you don’t know what Ido is, read Introduction to Ido Mode); and by overriding
C-x C-r, bound to
find-file-read-only, a useless feature I never use. Note: the Ido supercharging only works if you have ido-mode enabled in the first place!
Note that unlike
find-file I’ve opted to display the entire filepath in Ido’s completion engine as I often find that a directory or remote host is the only disambiguator if there are multiple files with the same name. I’ve thought about filtering the list of recent files through the
uniquify module for buffers but that’s for another time.
Here’s what you need to add to your .emacs:
(require 'recentf) ;; get rid of `find-file-read-only' and replace it with something ;; more useful. (global-set-key (kbd "C-x C-r") 'ido-recentf-open) ;; enable recent files mode. (recentf-mode t) ; 50 files ought to be enough. (setq recentf-max-saved-items 50) (defun ido-recentf-open () "Use `ido-completing-read' to \\[find-file] a recent file" (interactive) (if (find-file (ido-completing-read "Find recent file: " recentf-list)) (message "Opening file...") (message "Aborting")))
You can force Emacs to make a file executable (respecting your
umask settings) if Emacs considers it a script. To determine if it is a script, Emacs will look for the hash-bang notation in the file and treat it as a script if it finds it.
Add this to your .emacs and Emacs will then make the file executable if it is a script.
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
In Emacs 23.1 support for your operating system’s trash can (or recycle bin, or whatever) was added. File deletions in Emacs now uses your system’s trash can and the deleted files will be put there instead. The feature must be enabled manually by adding this to your .emacs:
(setq delete-by-moving-to-trash t)
The delete to trash functionality will obviously behave differently depending on your operating system. On Windows the special function
system-move-file-to-trash is defined because Windows exposes its own API for handling files sent to the recycle bin. On other operating systems that function will be nil, and the default behavior provided by
move-file-to-trash is used instead.
In Emacs 23.2 new functionality was added to ensure Emacs conforms to the freedesktop.org specification used by all major, free desktop environments. The new variable is
trash-directory and determines where Emacs will put the deleted files. If the variable is
nil the freedesktop.org trash can default is used, otherwise the variable must contain a path string to where the files are to be put.
There are several shells for Emacs, but none can match the versatility and integration with Emacs like Eshell. Eshell is a shell written entirely in Emacs-Lisp, and it replicates most of the features and commands from GNU CoreUtils and the Bourne-like shells. So by re-writing common commands like
cp in Emacs-Lisp, Eshell will function identically on any environment Emacs itself runs on.
Unfortunately, there is a problem: Eshell is woefully underdocumented — a rare sight in GNU Emacs — so I’ve compiled this guide to help people make full use of what Eshell has to offer.