Friday, April 25, 2008

.emacs

I prefer Aquamacs. On Windows, I use Emacs W32. The following is for Aquamacs.

(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'meta)


(setq inhibit-startup-message t)
(defun my-c-initialization-hook ()
 (define-key c-mode-base-map "\C-m" 'c-context-line-break)
 (add-hook 'c-initialization-hook 'my-c-initialization-hook)
)
(global-set-key [C-tab] 'next-buffer)
(global-set-key [C-S-tab] 'previous-buffer)
(global-set-key [S-tab] 'other-window)
(global-set-key [f2] 'save-buffer)
(global-set-key [f5] 'speedbar)
(global-set-key [f7] 'my-save-and-compile)
(global-set-key [f6] 'other-window)
(global-set-key [C-f6] 'comment-or-uncomment-region-or-line)
;(global-set-key [A-tab] 'other-window)
(global-set-key [M-f12] 'calendar)
(global-set-key [M-f9] 'kill-some-buffers)
(global-set-key [C-f4] 'kill-current-buffer)
;(global-set-key [?\A-h] 'mark-paragraph) sfsdfsdf 

(global-set-key [?\A- ] 'just-one-space)
(global-set-key [M-f1] 'man)
(global-set-key [?\A-n] 'new-frame)

(fset 'yes-or-no-p 'y-or-n-p)

;; Make control+pageup/down scroll the other buffer
(global-set-key [C-next] 'scroll-other-window)
(global-set-key [C-prior] 'scroll-other-window-down)
(global-set-key "\C-z" 'shell) ; or eshell
(global-set-key (kbd "M-a") 'execute-extended-command)

; return a backup file path of a give file path
; with full directory mirroring from a root dir
; non-existant dir will be created
(defun my-backup-file-name (fpath)
  "Return a new file path of a given file path.
If the new path's directories does not exist, create them."
  (let (backup-root bpath)
    (setq backup-root "~/.emacs.d/emacs-backup")
    (setq bpath (concat backup-root fpath "~"))
    (make-directory (file-name-directory bpath) bpath)
    bpath
  )
)
(setq make-backup-file-name-function 'my-backup-file-name)


(defun dotemacs ()
 "Open .emacs"
 (interactive)
 (find-file "~/Library/Preferences/Aquamacs Emacs/Preferences.el"))

(add-to-list 'load-path "~/elisp")
(setq-default abbrev-mode t)
(read-abbrev-file "~/.abbrev_defs")
(setq save-abbrevs t)

(setq require-final-newline 't)

;; Save the state of emacs
(desktop-save-mode 1)
(desktop-read)
(add-to-list 'desktop-globals-to-save 'file-name-history)



(defun kill-current-buffer ()
  "Kill the current buffer, without confirmation."
  (interactive)
  (kill-buffer (current-buffer)))


;; smarttab

;;;
;; Smart Tab

(defvar smart-tab-using-hippie-expand t
  "turn this on if you want to use hippie-expand completion.")

(global-set-key [(tab)] 'smart-tab)
(defun smart-tab (prefix)
  "Needs `transient-mark-mode' to be on. This smart tab is
minibuffer compliant: it acts as usual in the minibuffer.

In all other buffers: if PREFIX is \\[universal-argument], calls
`smart-indent'. Else if point is at the end of a symbol,
expands it. Else calls `smart-indent'."
  (interactive "P")
  (if (minibufferp)
      (minibuffer-complete)
    (if (smart-tab-must-expand prefix)
        (if smart-tab-using-hippie-expand
            (hippie-expand nil)
          (dabbrev-expand nil))
      (smart-indent))))

(defun smart-indent ()
  "Indents region if mark is active, or current line otherwise."
  (interactive)
  (if mark-active
      (indent-region (region-beginning)
                     (region-end))
    (indent-for-tab-command)))

(defun smart-tab-must-expand (&optional prefix)
  "If PREFIX is \\[universal-argument], answers no.
Otherwise, analyses point position and answers."
  (unless (or (consp prefix)
              mark-active)
    (looking-at "\\_>")))

;(load-library turkish.el)

(setq-default abbrev-mode t)

(read-abbrev-file "~/.abbrev_defs")

(setq save-abbrevs t)


;(setq initial-frame-alist '((top . 10) (left . 30)

 ;                           (width . 90) (height . 50)))

;(setq default-frame-alist '((width . 80) (height . 45)))

(setq speedbar-mode-hook '(lambda ()
    (interactive)
    (other-frame 0)))

(cd "/Users/ustun/Documents/")

(defun my-save-and-compile ()

(interactive "")

(save-buffer 0)

(compile compile-command)

)

No comments: