(server-start)
;; no Tabs
(setq-default indent-tabs-mode nil)
(setq-default tabs-width 2)
;; List more buffers in the buffer menu
(setq-default buffers-menu-max-size 30)
;; Prevent startup message and switch to empty *scratch*
(setq inhibit-startup-message t)
(setq initial-scratch-message nil)
;; Fix C&P
(setq x-select-enable-clipboard t)
;; Make Caps Lock LED blink instead of audio bell
(setq visible-bell 1)
(setq ring-bell-function
(lambda ()
(when (getenv "DISPLAY")
(call-process-shell-command "xset led named \"Scoll Lock\"; xset -led named \"Scroll Lock\"" nil 0 nil))))
(show-paren-mode 1)
(column-number-mode 1)
;; Keep the custom stuff separate
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)
;; I know what downcase-region does. Me no noob anymore ;). So undisable it.
(put 'downcase-region 'disabled nil)
;; This can be a life saver!
(push '("." . "~/.emacs.d/backups") backup-directory-alist)
;; Create better buffer names. foo.c++:src, foo.c++:extra instead of foo.c++ and foo.c++
;; This should really be the default behaviour for Emacs!
(require 'uniquify)
(setq
uniquify-buffer-name-style 'reverse
uniquify-separator ":")
;; c-mode hook to set better default compile-command if no Makefile exists and activate flyspell-prog-mode
;; I have similar hooks for c-mode and fortran-mode
(add-hook 'c++-mode-hook
(lambda ()
(flyspell-prog-mode)
(unless (or (file-exists-p "Makefile")
(local-variable-p 'compile-command)
(not buffer-file-name))
(set (make-local-variable 'compile-command)
(format "%s %s %s"
(or (getenv "CXX") "g++")
(or (getenv "CXXFLAGS")
"-pipe -std=c++0x -pedantic-errors -Wall -Wextra -Weffc++ -g3")
(file-name-nondirectory buffer-file-name))))))
;; Set f9 to compiler and f8 to make clean
(global-set-key '[f9] 'compile)
(global-set-key '[f8] '(lambda ()
(interactive)
(when (file-exists-p "Makefile") (compile "make clean"))))
The rest is just some specific mode setup and minor key bindings stuff.Ask HN Emacs Users: What's in your .emacs file?
31–40 of 67 posts
Re: Ask HN Emacs Users: What's in your .emacs file?
#32Funny, about an hour ago I finally broke down and remapped Ctrl+w to backward-kill-word[1] after re-reading Yegge's Effective Emacs, and you've just reminded me to push the commit to my fork of emacs-starter-kit, which is a great way to get a core set of functionality. Works best if you're tyrannical about keeping it up to date, which I mostly am. http://github.com/daemianmack/emacs-starter-kit/ Favorite two most rec…
(defun backward-kill-word-or-kill-region (&optional arg)
(interactive "p")
(if (region-active-p)
(kill-region (region-beginning) (region-end))
(backward-kill-word arg)))
(global-set-key (kbd "C-w") 'backward-kill-word-or-kill-region)
This gets me kill-region for an active (transient-mark-mode) region but backward-kill-word otherwise.Re: Ask HN Emacs Users: What's in your .emacs file?
#33Funny, about an hour ago I finally broke down and remapped Ctrl+w to backward-kill-word[1] after re-reading Yegge's Effective Emacs, and you've just reminded me to push the commit to my fork of emacs-starter-kit, which is a great way to get a core set of functionality. Works best if you're tyrannical about keeping it up to date, which I mostly am. http://github.com/daemianmack/emacs-starter-kit/ Favorite two most rec…
I too made the switch after reading Yegge's good stuff, but missed kill-region so badly I had to come up with this: (defun backward-kill-word-or-kill-region (&optional arg) (interactive "p") (if (region-active-p) (kill-region (region-beginning) (region-end)) (backward-kill-word arg))) (global-set-key (kbd "C-w") 'backward-kill-word-or-kill-region) This gets me kill-region for an active (transient-mark-mode) region bu…
Re: Ask HN Emacs Users: What's in your .emacs file?
#34Some notable items:
;;; allow seperating out the config stuff to
;;; into different files
(defvar jaw:config-dir (expand-file-name "~/.emacs.d/conf.d")
"My config parts directory location.")
(defun jaw:load-confs ()
"Load Jeremy's config file parts"
(let ((files (sort (directory-files jaw:config-dir) 'string
Automatically installing elpa packages to bootstrap a new emacs system: https://bitbucket.org/zaphar/dotfiles/src/tip/.emacs.d/conf....Re: Ask HN Emacs Users: What's in your .emacs file?
#35 (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!Re: Ask HN Emacs Users: What's in your .emacs file?
#36I've modified it slightly, but overall it set emacs up better than I new was possible (and introduced me to some add ons I didn't know existed).
Re: Ask HN Emacs Users: What's in your .emacs file?
#37It uses org-babel to keep it organized and readable so really there's a short wrapper init.el that then calls babel-init.org
External packages are installed system-wide using my own .SlackBuild generated packages (@ http://github.com/cycojesus/slackbuilds/tree/master/e/ )
Of course I run Slackware.
Re: Ask HN Emacs Users: What's in your .emacs file?
#38My .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:…
If it makes you feel any better, back when I was managing a team in Visual Studio, we called this the "When in Rome" feature. And yes, the versions of this we tried to put together worked as you'd expect... mostly. Determining peoples' whitespace decisions are not trivial. How many lines does the THEN clause of an IF need to have before you surround it with curlies? Do you only put a space before the parens around a function's arguments if there is more than one argument? And my personal favorite, how do you "funge" your indentation style if the nesting level gets high enough that you're at frequent risk of line wrap (soft or hard doesn't matter here)?
People have wacky rules, and as soon as you say you're going to auto-detect them, you're in for a world of pain. Of course, you might have a user base that isn't as persnickety, in which case it's really not that bad.
Re: Ask HN Emacs Users: What's in your .emacs file?
#39Funny, about an hour ago I finally broke down and remapped Ctrl+w to backward-kill-word[1] after re-reading Yegge's Effective Emacs, and you've just reminded me to push the commit to my fork of emacs-starter-kit, which is a great way to get a core set of functionality. Works best if you're tyrannical about keeping it up to date, which I mostly am. http://github.com/daemianmack/emacs-starter-kit/ Favorite two most rec…
I too made the switch after reading Yegge's good stuff, but missed kill-region so badly I had to come up with this: (defun backward-kill-word-or-kill-region (&optional arg) (interactive "p") (if (region-active-p) (kill-region (region-beginning) (region-end)) (backward-kill-word arg))) (global-set-key (kbd "C-w") 'backward-kill-word-or-kill-region) This gets me kill-region for an active (transient-mark-mode) region bu…
Re: Ask HN Emacs Users: What's in your .emacs file?
#40Viper 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!