Automating Emacs
I've spent a lot of time doing repetitive tasks in Emacs lately, which prompted med to make the following function. This function asks for a name and a keyboard binding, saves the latest defined macro in my .emacs (my .emacs is located in .emacs.d since I have .emacs.d in a git repository), adds a keybinding to it, saves my .emacs file, reloads it so the keybinding will work immediately and updates the git repository that my .emacs file resides in.
(defun save-macro (name keybinding) "save latest macro defined macro and a keybinding to it to .emacs" (interactive "SName of the macro: \nSKey binding for macro %s: ") (kmacro-name-last-macro name) (find-file "~/.emacs.d/.emacs") (goto-char (point-max)) (newline) (insert-kbd-macro name) (newline) (insert (format "(global-set-key (kbd \"%s\") '%s)" keybinding name)) (newline) (save-buffer) (switch-to-buffer nil) (load-file "~/.emacs.d/.emacs") (shell-command "cd ~/.emacs.d;git pull origin master;git commit -am 'added macro to .emacs';git push;") (kill-buffer "*Shell Command Output*"))
- Previous: 22 September 2010 Single most important Android application
- Next: 16 September 2010 Domain Fetish
About me
-
- Professional
- Master thesis on security, privacy and availability in GSM-positioning systems at Simula Research Laboratory and University of Oslo - Department of Informatics. Currently working as a senior Java consultant and Liferay tech lead.
-
- Languages of choice
- C, python, perl and lisp
-
- Current interests
- GSM-networks and technology, Emacs, Stumpwm, org-mode, philosophy and ethics, microprocessors, Drupal, Latex and writing.