5 elisp snippets
Change font size in emacs
To change the font size in the current buffer:
C-x C-+- increase font size
C-x C--- decrease font size
Follow either with
0 for continued adjustment.
To change the font size in all buffers:
(set-face-attribute 'default nil :height 120) ;; where `height` is 10x point size
Working with R in emacs
1) Install R.
2) Install ESS:
sudo aptitude install ess=12.09-1
(add-to-list 'load-path "/usr/share/emacs/site-lisp/") (require 'ess-site)
4) Load R within emacs via
Default fonts with emacsclient/emacs --daemon
I've been using
set-default-font in my
.emacs file to configure emacs to use my favorite programming font.
(set-default-font "Droid Sans Mono Slashed-10") ;;; set default font
emacs --daemon to keep an instance of emacs running as a background process on my development machine so that I can run
emacsclient to call up an emacs window (frame) instantaneously (and keep the same session running even after a close the emacs frame).
Suddenly (after an
aptitude safe-upgrade, I think, but I'm not sure what triggered this change), emacs frames that are created by
emacsclient connecting to the
emacs --daemon instance no longer used my default font when initially opened. The default font worked properly for stand-alone emacs instances (opened with
emacs), and for
(set-default-font) after startup worked fine, but it no longer worked automatically.
To fix this, I had to set up a
default-frame-alist, which I believe defines commands to execute whenever a new frame is opened.
(set-default-font "Droid Sans Mono Slashed-10") ;;; set default font (setq default-frame-alist '((font . "Droid Sans Mono Slashed-10"))) ;;; set default font for emacs --daemon / emacsclient
By the way, I also discovered the
describe-font elisp function while trying to diagnose this issue.
(describe-font "Droid Sans Mono Slashed-10") ;; or M-x describe-font <RETURN> Droid Sans Mono Slashed-10 <RETURN>
which opens a
*Help* buffer containing:
name (opened by): -unknown-Droid Sans Mono Slashed-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1 full name: Droid Sans Mono Slashed:pixelsize=13:foundry=unknown:weight=normal:slant=normal:width=normal:spacing=100:scalable=true size: 13 height: 17 baseline-offset: 0 relative-compose: 0
Simple emacs mode for .gitignore files.
Through the power of generic-mode, adding the following lines to your
.emacs file will add syntax-coloring support for
.svnignore, etc. files. And by "syntax-coloring" I mean that lines that start with a
# will be marked as comments.
(require 'generic-x) (add-to-list 'auto-mode-alist '("\\..*ignore$" . hosts-generic-mode))
Actually, any text after an un-escaped
# will be marked as a comment, which isn't the way Git and SVN interpret those files. (TODO: it would be pretty simple to add a dot-ignore-generic-mode that handles this correctly.)
Using js-mode's indent logic in js2-mode
Here's a somewhat hack-y workaround: switch to
indent-region and then switch back.
;; use js-mode's indent logic, by pressing C-M-| (C-M-S-\) (defun rlw/js-indent-region () (interactive) (js-mode) (indent-region (region-beginning) (region-end)) (js2-mode) ) (define-key js2-mode-map (kbd "C-M-|") 'rlw/js-indent-region)
- mooz's fork of js2-mode
- thomblake's js3-mode
- I think the defunct espresso-mode is now the built-in
- I'm not sure where that leaves
- Steve Yegge's js2-mode
The first two are supposed to address js2-mode's indentation problems (among other enhancements).