Created
October 14, 2012 05:49
-
-
Save roopeshvaddepally/3887530 to your computer and use it in GitHub Desktop.
Emacs init.el custom extras
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; My setup is a emacs 24 with emacs prelude installed | |
(global-set-key (kbd "C-?") 'help) ;; help-command from previous versions is not there anymore | |
(global-set-key (kbd "C-h") 'delete-backward-char) ;; because backspace sucks | |
(defun other-window-backward (&optional n) | |
"Select Nth previous window." | |
(interactive "P") | |
(other-window (- (prefix-numeric-value n)))) | |
(global-set-key (kbd "<f5>") 'other-window) ;; coz f11 are used by emacs gtk | |
(global-set-key (kbd "<f6>") 'other-window-backward) | |
;; need better functions that skip the *buffers* style buffers | |
(global-set-key (kbd "C-<tab>") 'next-buffer) | |
(global-set-key (kbd "C-S-<tab>") 'previous-buffer) | |
(defalias 'scroll-ahead 'scroll-up-command) | |
(defalias 'scroll-behind 'scroll-down-command) | |
(defun scroll-n-lines-ahead (&optional n) | |
"Scroll ahead N lines (1 line by default)." | |
(interactive "P") | |
(scroll-ahead (prefix-numeric-value n))) | |
(defun scroll-n-lines-behind (&optional n) | |
"Scroll behind N lines (1 line by default)" | |
(interactive "P") | |
(scroll-behind (prefix-numeric-value n))) | |
;; i want to use <up> & <down> keys instead, but I'm unable to find a way to bind it right. | |
(global-set-key (kbd "C-q") 'scroll-n-lines-behind) | |
(global-set-key (kbd "C-z") 'scroll-n-lines-ahead) | |
;; rebind the original commands for c-q, c-z to other keymap | |
(global-set-key (kbd "C-c C-q") 'quoted-insert) | |
;; C-z & C-x C-z already bind to suspend-emacs | |
;; my setup has M-r which cycles the point between top middle and bottom | |
;; move-to-window-line-top-bottom | |
(defun point-to-top () | |
"Move point to top line of window." | |
(interactive) | |
(move-to-window-line 0)) | |
(defun point-to-bottom () | |
"Move point to beginning of last visible line." | |
(interactive) | |
(move-to-window-line -1)) | |
;; better one would be to use C-l | |
(defun line-to-top () | |
"Move current line to top of the page" | |
(interactive) | |
(recenter 0)) | |
;; would need a name for the λ if we want to "remove-hook" | |
(add-hook 'find-file-hooks | |
'(lambda () | |
(if (file-symlink-p buffer-file-name) | |
(progn | |
(setq buffer-read-only t) | |
(message "file is symlink"))))) | |
;; wrote a function, i'm sure i'll almost never use | |
(global-set-key (kbd "C-M-L") '(lambda () (interactive) (ucs-insert "3BB"))) | |
;; a much better article on unicode: http://ergoemacs.org/emacs/emacs_n_unicode.html | |
;; convenience function to evaluate and replace the last s-expression | |
;; much like eval-print-last-sexp | |
(defun eval-replace () | |
"evaluate and replace the last sexp" | |
(interactive) | |
(backward-kill-sexp) | |
(prin1 (eval (read (current-kill 0))) (current-buffer))) | |
;; if you are learning elisp and have test somethings in buffer | |
(defun eval-print-in-comments () | |
(interactive) | |
(let (s | |
(end (point))) | |
(backward-sexp) | |
(setq s (eval (read (buffer-substring (point) end)))) | |
(forward-sexp) | |
(insert (format " ;; => %s\n" s)))) | |
(global-set-key (kbd "C-c C-e") 'eval-print-in-comments) | |
;; when running emacs as daemon, client font is not set right. this changes settings for each frame | |
(add-to-list 'default-frame-alist | |
'(font . "Source Code Pro-9")) | |
;; did someone tell you how bad the indentation and paranthesis in perl mode are? | |
(setq cperl-indent-level 4 | |
cperl-close-paren-offset -4 | |
cperl-continued-statement-offset 4 | |
cperl-indent-parens-as-block t) | |
(add-to-list 'exec-path "C:/Program Files (x86)/clisp-2.49/") | |
(add-hook 'lisp-mode-hook | |
'(lambda () | |
(setq inferior-lisp-program | |
"clisp.exe -K full"))) | |
(require 'org-publish) | |
(setq org-publish-project-alist | |
'( | |
("org-notes" | |
:base-directory "c:/Users/rv/My Documents/My Notes/" | |
:base-extension "org" | |
:publishing-directory "c:/Users/rv/Downloads/notes_html/" | |
:recursive t | |
:publishing-function org-publish-org-to-html | |
:headline-levels 4 | |
:auto-preamble t) | |
("org" | |
:components ("org-notes")))) | |
;; disable guru mode that comes with prelude first | |
(guru-global-mode -1) | |
(global-set-key (kbd "<right>") 'enlarge-window-horizontally) | |
(global-set-key (kbd "<left>") 'shrink-window-horizontally) | |
(global-set-key (kbd "<up>") 'enlarge-window) | |
(global-set-key (kbd "<down>") '(lambda () (interactive) (enlarge-window -1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment