- [dealing with many buffers: ibuffer] (http://emacs-fu.blogspot.com/2010/02/dealing-with-many-buffers-ibuffer.html)
Created
March 29, 2012 09:53
-
-
Save yangg/2235526 to your computer and use it in GitHub Desktop.
Emacs Scripts
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
;; difference between two ways to defalias | |
(defalias 'backward-delete-char 'delete-backward-char) | |
(defalias 'search-forward-regexp (symbol-function 're-search-forward)) | |
;; http://stackoverflow.com/questions/1545993/difference-between-defalias-a-symbol-function-b-and-defalias-a-b |
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
#!/bin/bash | |
# Argument: filename to open in new Emacs frame | |
/usr/bin/emacsclient -e '(let ((default-directory "`pwd`/")) (select-frame (make-frame)) (find-file "'$1'"))' |
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
;;-*-mode: emacs-lisp;-*- | |
(desktop-save-mode t) | |
(setq desktop-load-locked-desktop nil) | |
(add-hook 'desktop-not-loaded-hook 'desktop-save-mode-off) | |
(setq browse-url-generic-program "x-www-browser" | |
browse-url-browser-function 'browse-url-generic) | |
;; (eq system-type "gnu/linux") | |
(defun my-fullscreen () | |
(interactive) | |
(x-send-client-message | |
nil 0 nil "_NET_WM_STATE" 32 | |
'(2 "_NET_WM_STATE_FULLSCREEN" 0))) | |
(global-set-key [f11] 'my-fullscreen) |
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
;;-*-mode: emacs-lisp;-*- | |
;; http://edward.oconnor.cx/config/.emacs | |
(setq auto-mode-case-fold t) | |
(setq read-file-name-completion-ignore-case t) | |
(setq read-buffer-completion-ignore-case t) | |
(add-hook 'before-save-hook 'time-stamp) | |
;; time-stamp-pattern: "4/Last Modified: %3b %:d, %:y\n" | |
(setq mouse-buffer-menu-mode-mult 1) | |
(setq-default abbrev-mode t) | |
(when (file-exists-p abbrev-file-name) | |
(quietly-read-abbrev-file)) | |
(add-to-list 'directory-abbrev-alist '("^/shortname" . "/ssh:username@host:dir")) | |
;; set default browser | |
;; (browse-url) | |
;; (browse-url-of-buffer) | |
;; (browse-url-emacs) | |
(setq browse-url-generic-program "x-www-browser" | |
browse-url-browser-function 'browse-url-generic) | |
;;(substring (shell-command-to-string "gconftool-2 -g /desktop/gnome/applications/browser/exec") 0 -1) | |
(setq tags-file-name "~/Project/TAGS") | |
;; M-. find-tag | |
;; C-u M-. universal-argument, find next tag | |
;; M-* pop-tag-mark, pop back to where M-. was last invoked | |
;; M-TAB complete-symbol | |
(defun my-php-symbol-lookup () | |
(interactive) | |
(let ((symbol (symbol-at-point))) | |
(if (not symbol) | |
(message "No symbol at point.") | |
(browse-url (concat "http://php.net/manual-lookup.php?pattern=" | |
(symbol-name symbol)))))) | |
(defun set-mode () | |
"set multi-mode" | |
(interactive) | |
(save-excursion | |
(if (re-search-backward "</script>\\|\\?>\\|</style>\\|<script[^>]*>\\|<\\?\\|<style[^>]*>\\|<\sw+[^>]*>\\(['\"]?\\)" nil t) | |
(let ((res (match-string 0)) | |
(new-mode nil)) | |
(cond ((equal res "<?") (setq new-mode 'php-mode)) | |
((string-match "^<script" res) (setq new-mode 'js-mode)) | |
((string-match "^<style" res) (setq new-mode 'css-mode)) | |
(t (setq new-mode 'html-mode))) | |
(and (eq new-mode 'html-mode) | |
(> (length (match-string 1)) 0) | |
(setq new-mode 'js-mode)) | |
(or (eq new-mode major-mode) | |
(funcall new-mode)))))) | |
(defun php-newline () | |
(interactive) | |
(if (string-match "views\\(/[a-zA-Z0-9_]+\\)+\\.php$\\|\\.[sp]?html$" buffer-file-truename) | |
(set-mode)) | |
(newline-and-indent)) | |
(global-set-key (kbd "RET") 'php-newline) | |
(add-hook 'php-mode-hook | |
'(lambda () | |
(local-set-key (kbd "<f1>") 'my-php-symbol-lookup) | |
(setq php-warned-bad-indent t))) |
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
(following-char) (preceding-char) | |
(char-after) | |
(skip-chars-forward) | |
(bury-buffer) | |
(browser-url) | |
(expand-file-name) | |
(file-name-as-directory) ; append a slash | |
(directory-file-name) ; remove final slash | |
(file-name-directory) ; directory component | |
(file-name-nondirectory) ; filename | |
(directory-files) ; get files list in a directory | |
emacs -batch -f batch-byte-compile thefile.el | |
(defun quote-range (ch &optional pair) | |
(if (region-active-p) | |
(let ((begin (region-beginning)) | |
(end (+ (region-end) (length ch)))) | |
(goto-char begin) | |
(insert ch) | |
(goto-char end) | |
(insert (or pair ch))) | |
(insert ch))) | |
(global-set-key "'" '(lambda () (interactive) (quote-range "'"))) | |
(global-set-key "\"" '(lambda () (interactive) (quote-range "\""))) | |
(global-set-key "(" '(lambda () (interactive) (quote-range "(" ")"))) | |
;; Compile your .emacs | |
(defun autocompile nil | |
"compile itself if ~/.emacs" | |
(interactive) | |
(require 'bytecomp) | |
(let ((dotemacs (expand-file-name "~/.emacs"))) | |
(if (string= (buffer-file-name) (file-chase-links dotemacs)) | |
(byte-compile-file dotemacs)))) | |
(add-hook 'after-save-hook 'autocompile) | |
;; Compile2 | |
(require 'bytecomp) | |
(setq compiled-init-file (byte-compile-dest-file user-init-file)) | |
(if (or (not (file-exists-p compiled-init-file)) | |
(file-newer-than-file-p user-init-file compiled-init-file) | |
(equal (nth 4 (file-attributes user-init-file)) (list 0 0))) | |
(load user-init-file) | |
(load compiled-init-file)) | |
(add-hook 'kill-emacs-hook | |
'(lambda () | |
(if (file-newer-than-file-p user-init-file compiled-init-file) | |
(byte-compile-file user-init-file)))) | |
;; http://www.emacswiki.org/emacs/OptimizingEmacsStartup | |
;; autoload & eval-after-load |
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
(add-hook 'shell-mode-hook | |
'(lambda() | |
(local-set-key '[up] 'comint-previous-input) | |
(local-set-key '[down] 'comint-next-input))) |
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
user-init-file | |
user-emacs-directory | |
eshell-directory-name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment