XSteve's Emacs Power User TipsI use Emacs as integration environment for most of the tasks I need to do. The other applications I use are:
I am also the author of various emacs lisp addon packages. Finding Files
;;; find file at point (require 'ffap) ;; rebind C-x C-f and others to the ffap bindings (see variable ffap-bindings) (ffap-bindings) ;; C-u C-x C-f finds the file at point (setq ffap-require-prefix t) ;; browse urls at point via w3m (setq ffap-url-fetcher 'w3m-browse-url) ;; provide some dired goodies and dired-jump at C-x C-j (load "dired-x") C-x C-j opens a dired buffer with point at the actual file name. You can navigate in this buffer with the cursor keys and open a file via RET ;;recentf (require 'recentf) (recentf-mode 1) (setq recentf-max-saved-items 500) (setq recentf-max-menu-items 60) (global-set-key [(meta f12)] 'recentf-open-files) M-F12 opens a buffer that contains the recent opened buffers Use C-s to search for a filename and hit RET to open the file. (defun xsteve-ido-choose-from-recentf () "Use ido to select a recently opened file from the `recentf-list'" (interactive) (let ((home (expand-file-name (getenv "HOME")))) (find-file (ido-completing-read "Recentf open: " (mapcar (lambda (path) (replace-regexp-in-string home "~" path)) recentf-list) nil t)))) (global-set-key [(meta f11)] 'xsteve-ido-choose-from-recentf) M-F11 uses the ido completion functionality to select a file from the recentf-list. Note: ido-completing-read needs emacs 22. ;; save a list of open files in ~/.emacs.desktop ;; save the desktop file automatically if it already exists (setq desktop-save 'if-exists) (desktop-save-mode 1) ;; save a bunch of variables to the desktop file ;; for lists specify the len of the maximal saved data also (setq desktop-globals-to-save (append '((extended-command-history . 30) (file-name-history . 100) (grep-history . 30) (compile-history . 30) (minibuffer-history . 50) (query-replace-history . 60) (read-expression-history . 60) (regexp-history . 60) (regexp-search-ring . 20) (search-ring . 20) (shell-command-history . 50) tags-file-name register-alist))) Use M-x desktop-save once to save the desktop. When it exists, Emacs updates it on every exit. Switching Buffers
(ido-mode 'buffer) (setq ido-enable-flex-matching t) (ido-mode 'buffer) enables ido for buffer switching ido-enable-flex-matching means that if the entered string does not match any buffer name, any buffer name containing the entered characters in the given sequence will match. (setq ibuffer-shrink-to-minimum-size t) (setq ibuffer-always-show-last-buffer nil) (setq ibuffer-sorting-mode 'recency) (setq ibuffer-use-header-line t) (global-set-key [(f12)] 'ibuffer) Ibuffer shows a buffer list that allows to perform almost any imaginable operation on the opened buffers. When I press F11 again, the buffer before is selected. Shift-F11 selects the buffer that was selected before by the bubble-buffer package. The interesting property of the package is, that it does not destroy the order of the buffer list, when a buffer is selected. (when (require 'bubble-buffer nil t) (global-set-key [f11] 'bubble-buffer-next) (global-set-key [(shift f11)] 'bubble-buffer-previous)) (setq bubble-buffer-omit-regexp "\\(^ .+$\\|\\*Messages\\*\\|*compilation\\*\\|\\*.+output\\*$\\|\\*TeX Help\\*$\\|\\*vc-diff\\*\\|\\*Occur\\*\\|\\*grep\\*\\|\\*cvs-diff\\*\\)") The nice thing, using that function is, that it does not matter, if I have the buffer already opened, or if the file must be opened now. With that function I have a persistent buffer list available. Shell Integration
(defun xsteve-save-current-directory () "Save the current directory to the file ~/.emacs.d/current-directory" (interactive) (let ((dir default-directory)) (with-current-buffer (find-file-noselect "~/.emacs.d/current-directory") (delete-region (point-min) (point-max)) (insert (concat dir "\n")) (save-buffer) (kill-buffer (current-buffer))))) (global-set-key [(super f10)] 'xsteve-save-current-directory) Hitting s-F10 saves the current directory to a file ;; a part of my ~/.zshrc do-cd-emacs() { LBUFFER="cd $(cat ~/.emacs.d/current-directory)" zle accept-line } zle -N do-cd-emacs bindkey '\e[21~' do-cd-emacs #F10 Hitting F10 in a running zsh switches to the recently saved directory from emacs (server-start) Just start the emacs server in the .emacs ;; a part of my ~/.zshrc function ec { emacsclient --no-wait "$PWD/$1" } function ecw { emacsclient "$PWD/$1" } The functions ec and ecw allow to open a file or a directory in the currently running emacs. The following opens file.txt: ec file.txt Here is the outline of the topics I will cover in the near future: Search and ReplaceVarious Navigation CommandsCopying and yanking textUse Dired for File OperationsDynamic abbreviations and hippie-expandUse Emacs Calc as calculator |