When opening 2 files in emacs, how can I have them appear side-by-side?

Here’s a function that will change a pair of vertical windows to a pair of horizontal windows: (defun 2-windows-vertical-to-horizontal () (let ((buffers (mapcar ‘window-buffer (window-list)))) (when (= 2 (length buffers)) (delete-other-windows) (set-window-buffer (split-window-horizontally) (cadr buffers))))) To do this automatically on startup, add this function to emacs-startup-hook: (add-hook ’emacs-startup-hook ‘2-windows-vertical-to-horizontal)

Setting Emacs 24 color theme from .emacs

Emacs 24 has built-in theming, which doesn’t use statements like (require ‘color-theme). As Drew points out in the comments, there are differences between color themes and custom themes, and the new direction is towards the latter. Try M-x customize-themes to take a look. From .emacs, you can do things like (load-theme ‘wombat t). But… It … Read more

How can I emulate Vim’s * search in GNU Emacs?

Based on your feedback to my first answer, how about this: (defun my-isearch-word-at-point () (interactive) (call-interactively ‘isearch-forward-regexp)) (defun my-isearch-yank-word-hook () (when (equal this-command ‘my-isearch-word-at-point) (let ((string (concat “\\<” (buffer-substring-no-properties (progn (skip-syntax-backward “w_”) (point)) (progn (skip-syntax-forward “w_”) (point))) “\\>”))) (if (and isearch-case-fold-search (eq ‘not-yanks search-upper-case)) (setq string (downcase string))) (setq isearch-string string isearch-message (concat isearch-message (mapconcat … Read more

what is custom-set-variables and faces in my .emacs?

These blocks are added by the customize interface, as Noufal pointed out. You can move them to a separate file, though, if you like. Just add this to your ~/.emacs.d/init.el: (setq custom-file “~/.emacs.d/custom.el”) (load custom-file) or, if you’re still using an old-fashioned ~/.emacs file: (setq custom-file “~/.custom.el”) (load custom-file) A slightly more complex snippet that … Read more

Emacs 24 Package System Initialization Problems

It’s worth noting why Emacs defers the package initialization: See C-hig (emacs) Package Installation RET, and in particular: The reason automatic package loading occurs after loading the init file is that user options only receive their customized values after loading the init file, including user options which affect the packaging system. In some circumstances, you … Read more

tech