Thank you all for this great wiki!

So I want to contribute. No magic here. But maybe you can make some use of it…

Init file errors

Problem: On an error the init file is not evaluated any further. Also to find the source of an error I need to restart emacs with --debug-init.

The common emacswiki solutions can be found on DebugFileLoading.

This works for me: Use the follwing function instead of (load filename) - if loading fails you will get an error message in Warnings and evaulation does not stop.

; using in Emacs 24.0.

(defun solidload (filename)
  (condition-case err
      (load filename)
    (error (display-warning 'initialization (concat "Load of " filename " failed " (prin1-to-string err) ) :warning) )

So my .emacs file simply contains the definition of (solidload) and a list of calls like:

(solidload "conf-common.el")
(solidload "conf-keys.el")
(solidload "conf-functions.el")
(solidload "conf-theme.el")

(solidload "conf-minor-yasnippet.el")

(solidload "conf-mode-isearch.el")
(solidload "conf-mode-ibuffer.el")
(solidload "conf-mode-dired.el")

(solidload "conf-mode-elisp.el")

The Jumping Cursor

Problem: Sometimes my cursor stops - and jumps a moment later - while I am holding the movement keys. That makes Zarza rrrrrrreally angry. Besides it’s quite irritating, especially because I am smooth scrolling (one line at a time).

The common emacswiki solution: do not use ‘scroll-step’ to activate smooth scrolling but (setq scroll-conservatively 10000) (see SmoothScrolling).

This works for me: Set ‘auto-save-interval’ to a higher value.

The common emacswiki solution did not work for me. My cursor jumped even during non-scrolling-moves. I noticed a short hard-drive activity when the cursor got stuck. My value for ‘auto-save-interval’ was set to 50 chars.

So now I’m using:

; using in Emacs 24.0.

; Autosave every 500 typed characters
(setq auto-save-interval 500)
; Autosave after 5 seconds of idle time
(setq auto-save-timeout 5)
; Scroll just one line when hitting bottom of window
(setq scroll-conservatively 10000)

Cyberpunk Cursor

This one changes the cursor color on each blink. Just eval code and its running.

; Using in Emacs 24.0 

(defvar blink-cursor-colors (list  "#92c48f" "#6785c5" "#be369c" "#d9ca65")
  "On each blink the cursor will cycle to the next color in this list.")

(setq blink-cursor-count 0)
(defun blink-cursor-timer-function ()
  "Cyberpunk variant of timer `blink-cursor-timer'. OVERWRITES original version in `frame.el'.

This one changes the cursor color on each blink. Define colors in `blink-cursor-colors'."
  (when (not (internal-show-cursor-p))
    (when (>= blink-cursor-count (length blink-cursor-colors))
      (setq blink-cursor-count 0))
    (set-cursor-color (nth blink-cursor-count blink-cursor-colors))
    (setq blink-cursor-count (+ 1 blink-cursor-count))
  (internal-show-cursor nil (not (internal-show-cursor-p)))

Color theme based on daytime

This one loads one of two themes depending on current time. Change ‘color-theme-night’ and ‘color-theme-day’ to the color-theme functions of your choice.

; Using in Emacs 24.0

(defvar night-hour 18
  "When to start with dark theme.")

(defvar day-hour 11
  "When to start with light theme.")

(defun color-theme-timer ()
  "Sets color theme according to current time. Customize `night-hour' and `day-hour'."
  (let ((hour (nth 2 (decode-time)))
        (minute (nth 1 (decode-time))))
    (if (or (>= hour night-hour) (< hour day-hour) )

My config runs ‘color-theme-timer’ on emacs start. Thats enough for me. To get an automatic toggle when day-hour/night-hour has come, you could add ‘color-theme-timer’ to some hook that is called quite frequently, maybe ‘auto-save-hook’. Then you have to modify ‘color-theme-timer’, so it only sets the theme if it is not already active - or the screen flashes. Flash! Aaa-aaah!

I think a good way to check which theme is active is by using the background-mode of a theme as in my toggle-function:

; Using in Emacs 23.2. 

(defun toggle-color-theme ()
  "Toggles day/night theme."
  (let ((bgmode (cdr (assoc 'background-mode default-frame-alist))))
    (if (eq bgmode 'dark)

Lookup word under cursor

King Xah suggests a function to lookup the definition of the word under cursor. Here’s a copy:

; by Xah -

(defun lookup-word-definition ()
  "Look up the current word's definition in a browser.
If a region is active (a phrase), lookup that phrase."
 (let (myword myurl)
   (setq myword
         (if (and transient-mark-mode mark-active)
             (buffer-substring-no-properties (region-beginning) (region-end))
           (thing-at-point 'symbol)))

  (setq myword (replace-regexp-in-string " " "%20" myword))
  (setq myurl (concat "" myword))

  (browse-url myurl)
  ;; (w3m-browse-url myurl) ;; if you want to browse using w3m

(global-set-key (kbd "<f6>") 'lookup-word-definition)

With the above, pressing F6 will launch your browser and lookup definition of the word under cursor.

My version (with humble respect):

; Using in Emacs 23.2. 

(defun lookup-word-definition (url)
  "Look up the current word's definition in a browser.
If a region is active (a phrase), lookup that phrase.

Give url of website to look up. Place <SearchWord> into url as in<SearchWord>"
  (let (myword myurl currentmode)
    (setq myword
          (if (and transient-mark-mode mark-active)
              (buffer-substring-no-properties (region-beginning) (region-end))
            (thing-at-point 'symbol)))

    (setq myword (replace-regexp-in-string " " "%20" myword))
    (setq myurl (replace-regexp-in-string "\<SearchWord\>" myword url))
    (browse-url myurl)
    ;; (w3m-browse-url myurl) ;; if you want to browse using w3m

I made these changes because I want one key to bind them all:

; In elisp mode: use f1 to search on emacswiki (C-h helps me with lisp-stuff)
(define-key emacs-lisp-mode-map (kbd "<f1>") '(lambda() (interactive) (lookup-word-definition "<SearchWord>")))

; In Autohotkey mode: use f1 to search ahk-helpsite
(define-key ahk-mode-map (kbd "<f1>") '(lambda() (interactive) (lookup-word-definition "<SearchWord>.htm")))

; Search google by default
(global-set-key (kbd "<f1>") '(lambda() (interactive) (lookup-word-definition "<SearchWord>")))

You can easily add your own modes, eg "<SearchWord>" for ‘php-mode-map’.

Can you help me?

Thanks for visiting! - Zarza

Welcome to the wiki. – DrewAdams

XEmacs had per-buffer faces. I used that to make the active buffer brighter than the inactive ones. It was great! I miss that feature in Emacs. There’s some approximation with buffer-local faces and/or overlays but neither is quite clean. Hm, I just searched EmacsWiki and found FacesPerBuffer. Looks promising! Here's an attempt at changing background color for the active buffer. For ERC, it looks like it uses ‘header-line’ instead of ‘erc-header-line’. Thank you for your auto-save trick for scrolling; I’ve been so annoyed by that. --AmitPatel