.emacs

Defined Key Bindings (Tuned for Programmer Dvorak Layout):

* Control+t → New empty buffer
* Control+l → List buffers
* Control+PageDown → Next Buffer 
* Control+PageUP → Previous Buffer 

* F9 → Save file
* F12 → Find file (Open file)
* Control+F12 → Sudo find file (open file with sudo)

* Alt+& → Split window below
* Alt+[ → Move cursor to other window
* Alt+{ → Split window right
* Alt++ → Delete other windows (does not kill them)
* Control+Up → Shrink Window 
* Control+Down → Enlarge window 
* Control+Left → Shrink Window horizontally 
* Control+Right → Enlarge window horizontally

* Control+h Control+c → Copy whole buffer to clipboard 
* Control+h Control+i → Indent whole buffer 
* Control+h Control+d → Delete whole buffer 

* F11 → Hide menu bar and tool bar 
* Alt+F11 → Hide menu bar and tool bar and full screen 
* Control+F11 → Distraction free 
* Control+F8 → revert distraction free

* Alt-t → Open eshell at bottom

* F7 → Start erc-tls and connect to freenode automatically (irc)

.emacs:

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(cua-mode t nil (cua-base))
 '(inhibit-startup-screen t)
 '(load-home-init-file t t)
 '(send-mail-function (quote mailclient-send-it)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

; open in fullscreen mode on startup -----
(add-to-list 'default-frame-alist '(fullscreen . maximized))
; ------

; Keybindings --------------
(global-set-key (kbd "C-w") 'kill-buffer-and-window)
(global-set-key (kbd "C-<prior>") 'previous-buffer)
(global-set-key (kbd "C-<next>") 'next-buffer)
;(global-set-key (kbd "C-p") 'previous-buffer)
;(global-set-key (kbd "C-n") 'next-buffer)

(defun copy-all ()
  (interactive)
  (clipboard-kill-ring-save (point-min) (point-max))
  (message "Copy Done."))

(global-set-key (kbd "C-h C-c") 'copy-all)

(defun delete-all ()
  (interactive)
  (delete-region (point-min) (point-max))
  (message "Delete Done."))

(global-set-key (kbd "C-h C-d") 'delete-all)

(defun indent-all ()
  (interactive)
  (indent-region (point-min) (point-max))
  (message "Indent Done."))

(global-set-key (kbd "C-h C-i") 'indent-all)

(defun menu-bar-tool-bar ()
  (interactive)
  (menu-bar-mode (if menu-bar-mode -1 1))
  (tool-bar-mode (if tool-bar-mode -1 1)))

(global-set-key (kbd "<f11>") 'menu-bar-tool-bar)

(defun menu-bar-tool-bar-fullscreen ()
  (interactive)
  (menu-bar-tool-bar)
  (toggle-frame-fullscreen))

(global-set-key (kbd "M-<f11>") 'menu-bar-tool-bar-fullscreen)

(defun distraction-free ()
  (interactive)
  (menu-bar-tool-bar-fullscreen)
  (scroll-bar-mode (if scroll-bar-mode -1 1))
  (setq-default left-margin-width 30)
  (setq-default right-margin-width 30)
  (set-window-buffer nil (current-buffer)))

(global-set-key (kbd "C-<f11>") 'distraction-free)

(defun distraction-free-revert ()
  (interactive)
  (menu-bar-tool-bar-fullscreen)
  (scroll-bar-mode t)
  (setq-default left-margin-width 0)
  (setq-default right-margin-width 0)
  (set-window-buffer nil (current-buffer)))

(global-set-key (kbd "C-<f8>") 'distraction-free-revert)


(defun xah-new-empty-buffer ()
  "Open a new empty buffer.
URL `http://ergoemacs.org/emacs/emacs_new_empty_buffer.html'
Version 2015-06-12"
  (interactive)
  (let ((ξbuf (generate-new-buffer "untitled")))
    (switch-to-buffer ξbuf)
    (funcall (and initial-major-mode))
    (setq buffer-offer-save t)))

(global-set-key (kbd "C-t") 'xah-new-empty-buffer)
(global-set-key (kbd "M-&") 'split-window-below)
(global-set-key (kbd "M-[") 'other-window)
(global-set-key (kbd "M-{") 'split-window-right)
(global-set-key (kbd "M-+") 'delete-other-windows)

(defun buffers-list()
  (interactive)
  (ibuffer)
  (isearch-forward))

(global-set-key (kbd "C-l") 'buffers-list)

(global-set-key (kbd "<f12>") 'find-file)

(defun sudo-find-file (file-name)
  "Like find file, but opens the file as root."
  (interactive
  (list (read-file-name "Sudo Find File: " "/")))
  (let ((tramp-file-name (concat "/sudo::/" (expand-file-name file-name))))
    (find-file tramp-file-name)))

(global-set-key (kbd "C-<f12>") 'sudo-find-file)

(global-set-key (kbd "<f9>") 'save-buffer)

(defun eshell-at-bottom ()
  (interactive)
  (split-window-below (floor (* 0.68 (window-height))))
  (windmove-down)
  (eshell))

(global-set-key (kbd "M-t") 'eshell-at-bottom)

(global-set-key (kbd "<C-up>") 'shrink-window)
(global-set-key (kbd "<C-down>") 'enlarge-window)
(global-set-key (kbd "<C-left>") 'shrink-window-horizontally)
(global-set-key (kbd "<C-right>") 'enlarge-window-horizontally)

(defun erc-tls-configured ()
  (interactive)
  (erc-tls :server "irc.freenode.net" :port 6697
       :nick "AAA" :password "AAA" :full-name "AAA")
  (setq erc-autojoin-channels-alist '(("freenode.net" "#shirazlug" "#ubuntu-ir" "#trisquel" "#trisquel-dev"))))

(global-set-key (kbd "<f7>") 'erc-tls-configured)

; server-start
(server-start)
; ------------


;; defining eshell alias (the hard way)
;(defun eshell/e (file)
;          (find-file file))

; autoclose ----------------
; autoclose brackets
(electric-pair-mode 1)
; autoclose more brackets
(setq electric-pair-pairs '(
                            (?\" . ?\")
                            (?\{ . ?\})
                            ) )
;-------------

; solarized theme ----------
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/emacs-color-theme-solarized")
(load-theme 'solarized t)
; -------------------------

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.