Month: June 2012

  • Sacha Chua interviews John Wiegley

    Sacha Chua has come up with a great idea of interviewing some of the big names in emacs. Check out her first video where she interviews John Wiegley. They cover some interesting ground. It makes me realise what an emacs amateur I am.

  • change the display font size in emacs

    In emacs 24 C-+ and C-- increase and decrease the display font
    size.

  • Editing files using sudo and emacs

    I often edit config files with:
    sudo emacs /etc/whatever

    The problem with that is I would end up with ~ backup files littering my filesystem and also emacs is run as root so it gets root’s config file. I’d rather use emacs with my config.
    The solution, thanks to emacs-fu is twofold:
    First set emacs’s backup directory, which tells it to save backup files in a
    specific directory rather in the same dir as the file you edited. Put something like this in your emacs init file:

     (setq
       backup-by-copying t      ; don't clobber symlinks
       backup-directory-alist
        '(("." . "~/.saves"))    ; don't litter my fs tree
       delete-old-versions t
       kept-new-versions 6
       kept-old-versions 2
       version-control t)       ; use versioned backups
    

    Then you add this to your .bashrc:

    # see http://emacs-fu.blogspot.com.au/2011/12/system-administration-with-emacs.html
    # edit file with root privs
    function E() {
        filename=$1
        without_beg_slash="${1##/}"
        if [[ $without_beg_slash == $1 ]];then
            filename="${PWD%//}/\"
        fi
        emacsclient -c -a emacs "/sudo:root@localhost:$filename"
    }
    

    Now just edit files with: E someconfigfile and it loads it in your emacs, asks your pw to edit and off you go.

  • Fullscreen emacs on OSX

    This works in emacs 24, not sure about previous versions. the keyboard shortcut matches Chrome’s full screen shortcut.

    ; keyboard shortcut to toggle full screen
      (global-set-key [s-return] 'ns-toggle-fullscreen)
    

    will define Cmd-return to toggle emacs between full screen and normal –
    the same shortcut as for chrome.