Live data from Hacker News

Ask HN Emacs Users: What's in your .emacs file?

news.ycombinator.com

51–60 of 67 posts

Re: Ask HN Emacs Users: What's in your .emacs file?

#52
post #35

Viper mode gives you the best of both worlds, although I'm probably considered a heretic in both religions. (setq viper-mode t) (require 'viper) (custom-set-variables '(column-number-mode t) '(inhibit-startup-screen t) '(show-paren-mode t) '(tool-bar-mode nil) '(menu-bar-mode nil)) I used to have slime config stuff in there, but now Ubuntu does it all for me. Thanks Ubuntu!

So you're the other viper-mode user! We should have coffee sometime :)

Viper is too mainstream for me:

http://jjfoerch.com/modal-mode/

Re: Ask HN Emacs Users: What's in your .emacs file?

#54
post #23

My .emacs is on GitHub: http://github.com/avar/dotemacs/blob/master/.emacs along with the elisp library I use http://github.com/avar/elisp Some noteworthy things: It's a ~1200 line file (and expanding) this is how I navigate it: (defun show-dot-emacs-structure () "Show the outline-mode structure of ~/.emacs" (interactive) (occur "^;;;;+")) Which shows the outline of the file, e.g.: 74 matches for "^;;;;+" in buffer:…

With iswitchb, once completion is exhausted try using cursor left and right to switch between the remaining alternatives.

This must be a custom setting of yours; C-s and C-r are the default. (And easier to type.)

Re: Ask HN Emacs Users: What's in your .emacs file?

#57
A few things I found useful:

  ;; fonts
  (if (eq window-system 'x)
      (set-default-font "Inconsolata-12"))

  ;; no tabs, spaces instead!
  (setq-default indent-tabs-mode nil)

  ;; Changes all yes/no questions to y/n type
  (fset 'yes-or-no-p 'y-or-n-p)

  ;; default modes
  (iswitchb-mode t)
  (icomplete-mo)
  (column-number-mode)
  (ido-mode)
  (tabbar-mode)
  (winner-mode)

  ;; ido-mode

  ;; do not confirm file creation
  (setq confirm-nonexistent-file-or-buffer nil)

  ;; integrate copy/paste with X
  (setq x-select-enable-clipboard t)
  (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)

  ;; scroll
  (setq scroll-step 1)

  ;; save backup files in this directory
  (setq backup-directory-alist (quote ((".*" . "~/.emacs.d/backups/"))))

  ;; global bindings
  (global-set-key [C-tab] 'other-window)
  (global-set-key "\r" 'newline-and-indent)
  (global-set-key (kbd "C-;") 'comment-region)
  (global-set-key (kbd "") '(lambda ()
                                (interactive)
                                (split-window-vertically 25)
                                (other-window 1)
                                (slime)))

  ; switch buffer with last previous buffer
  (global-set-key (kbd "") '(lambda ()
                                      (interactive)
                                      (switch-to-buffer nil)))
  (global-set-key (kbd "C-p") 'backward-char)
  (global-set-key (kbd "C-S-p") 'previous-line)
  (global-set-key (kbd "C-S-j") 'join-line)
  (global-set-key (kbd "C-") 'tabbar-forward)
  (global-set-key (kbd "C-") 'tabbar-backward)

  ;; fullscreen on F11
  (defun toggle-fullscreen (&optional f)
    (interactive)
    (let ((current-value (frame-parameter nil 'fullscreen)))
      (set-frame-parameter nil 'fullscreen
                         (if (equal 'fullboth current-value)
                             (if (boundp 'old-fullscreen) old-fullscreen nil)
                           (progn (setq old-fullscreen current-value)
                                  'fullboth)))))

  (global-set-key [f11] 'toggle-fullscreen)
http://github.com/kototama/unixconf/blob/master/.emacs

Re: Ask HN Emacs Users: What's in your .emacs file?

#59
Very little, my .emacs just loads a whole load of other .el files. There's quite a lot in them though :) Here's a very very useful few lines if you're on X Windows:

    ; Fix copy-paste between emacs and other x programs
    (setq x-select-enable-clipboard t)
    (if (functionp 'x-cut-buffer-or-selection-value)
        (setq interprogram-paste-function 'x-cut-buffer-or-selection-value))
All your problems with cut and paste between Emacs and other programs? Gone!

The if statement stops it failing when you use it on other platforms.

EDIT: I also really really like this bit which I've not seen in other peoples lists:

    (defun eshell-goto-current-dir (&optional arg)
      (interactive "P")
      (let ((dir default-directory))
        (eshell arg)
        (eshell/cd dir)))

    (global-set-key "\C-cs" 'eshell)
    (global-set-key "\C-cS" 'eshell-goto-current-dir)
That means I can switch to eshell with C-cs or a can switch to eshell and change the current directory to be the same as the file I was viewing with C-cS. It also passes through the argument so I can have multiple shells open and use the numeric argument (M-1, M-2 etc) to select them.
Post reply on HN