diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/email.el | 63 | ||||
-rw-r--r-- | lisp/init-dired.el | 23 | ||||
-rw-r--r-- | lisp/init-eshell.el | 68 | ||||
-rw-r--r-- | lisp/init-magit.el | 34 |
4 files changed, 188 insertions, 0 deletions
diff --git a/lisp/email.el b/lisp/email.el new file mode 100644 index 0000000..31cbfca --- /dev/null +++ b/lisp/email.el @@ -0,0 +1,63 @@ +(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e") +(require 'mu4e) +(setq mu4e-get-mail-command "offlineimap" + mu4e-compose-signature-auto-include nil + mu4e-update-interval 120 + mu4e-headers-include-related t) + +(setq mu4e-use-fancy-chars t) +(setq mu4e-html2text-command "w3m -T text/html") +(setq mu4e-view-show-images t) +;; use imagemagick, if available +(when (fboundp 'imagemagick-register-types) + (imagemagick-register-types)) + +(setq mu4e-maildir "~/Mail" ;; top-level Maildir + mu4e-attachment-dir "~/Downloads" + mu4e-sent-folder "/private/Sent" ;; folder for sent messages + mu4e-drafts-folder "/private/Drafts" ;; unfinished messages + mu4e-trash-folder "/private/Trash" ;; trashed messages + mu4e-refile-folder "/private/Archives") ;; saved messages + +(defvar my-mu4e-account-alist + '(("private" + (mu4e-sent-folder "/private/Sent") + (mu4e-drafts-folder "/private/Drafts") + (mu4e-trash-folder "/private/Trash") + (mu4e-refile-folder "/private/Archives")))) + +(defun my-mu4e-set-account () + "Set the account for composing a message." + (let* ((account + (if mu4e-compose-parent-message + (let ((maildir (mu4e-message-field mu4e-compose-parent-message :maildir))) + (string-match "/\\(.*?\\)/" maildir) + (match-string 1 maildir)) + (completing-read (format "Compose with account: (%s) " + (mapconcat #'(lambda (var) (car var)) + my-mu4e-account-alist "/")) + (mapcar #'(lambda (var) (car var)) my-mu4e-account-alist) + nil t nil nil (caar my-mu4e-account-alist)))) + (account-vars (cdr (assoc account my-mu4e-account-alist)))) + (if account-vars + (mapc #'(lambda (var) + (set (car var) (cadr var))) + account-vars) + (error "No email account found")))) + +(add-hook 'mu4e-compose-pre-hook 'my-mu4e-set-account) + +; set up email sending with msmtp +(setq mail-user-agent 'mu4e-user-agent) +(setq mail-specify-envelope-from t) +(setq mail-envelope-from 'header) + +(setq message-kill-buffer-on-exit t) +(setq message-sendmail-envelope-from 'header) +(setq message-send-mail-function 'message-send-mail-with-sendmail) + +;;use msmtp instead of sendmail +(setq sendmail-program "/usr/bin/msmtp") + + +(global-set-key (kbd "<f12>") 'mu4e) diff --git a/lisp/init-dired.el b/lisp/init-dired.el new file mode 100644 index 0000000..b9f54bc --- /dev/null +++ b/lisp/init-dired.el @@ -0,0 +1,23 @@ +;; jump to first or last file in dired, not to the very top or bottom +(require 'dired) +(require 'dired+) +(defun my/dired-back-to-top () + (interactive) + (beginning-of-buffer) + (dired-next-line 4)) + +(define-key dired-mode-map + (vector 'remap 'beginning-of-buffer) 'my/dired-back-to-top) + +(defun my/dired-jump-to-bottom () + (interactive) + (end-of-buffer) + (dired-next-line -1)) + +(define-key dired-mode-map + (vector 'remap 'end-of-buffer) 'my/dired-jump-to-bottom) +(define-key dired-mode-map + (kbd "^") (lambda () (interactive) (find-alternate-file ".."))) ; was dired-up-directory + +;; TODO: what does this do? +(put 'dired-find-alternate-file 'disabled nil) diff --git a/lisp/init-eshell.el b/lisp/init-eshell.el new file mode 100644 index 0000000..d87d0e7 --- /dev/null +++ b/lisp/init-eshell.el @@ -0,0 +1,68 @@ +(require 'eshell) +(require 'shell-switcher) +(setq shell-switcher-mode t) +(add-hook 'eshell-mode-hook 'shell-switcher-manually-register-shell) +(setq eshell-history-size 10000) + +;; author: KaiGrossjohann on EmacsWiki +(defun eshell/ff (&rest args) + "Invoke `find-file' on the file. + \"ff +42 foo\" also goes to line 42 in the buffer." + (while args + (if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args)) + (let* ((line (string-to-number (match-string 1 (pop args)))) + (file (pop args))) + (find-file file) + (goto-line line)) + (find-file (pop args))))) + + +;; convenience functions to input the remote root/home dir when in a +;; directory on a remote host +(defun my/tramp-root () + "Print root directory on the remote host." + (interactive) + (let ((pieces (split-string (eshell/pwd) ":/"))) + (insert-string (if (> (length pieces) 1) + (concat (car pieces) ":/") + "/")))) + +(defun my/tramp-home () + "Print home directory path on the remote host." + (interactive) + (let ((pieces (split-string (eshell/pwd) ":/"))) + (insert-string (if (> (length pieces) 1) + (concat (car pieces) ":~/") + "~/")))) + +(add-hook 'eshell-mode-hook + '(lambda () (define-key eshell-mode-map (kbd "C-c /") 'my/tramp-root))) +(add-hook 'eshell-mode-hook + '(lambda () (define-key eshell-mode-map (kbd "C-c ~") 'my/tramp-home))) + + +;; start a hidden eshell on startup +(add-hook 'emacs-startup-hook #'(lambda () + (let ((default-directory (getenv "HOME"))) + (command-execute 'eshell) + (bury-buffer)))) + +;; use cat as the pager in shell mode, because shell-mode is not an ANSI terminal +(setenv "PAGER" "cat") + +;; C-d on an empty line in the shell terminates the process. +(defun my/comint-delchar-or-eof-or-kill-buffer (arg) + (interactive "p") + (if (null (get-buffer-process (current-buffer))) + (kill-buffer) + (comint-delchar-or-maybe-eof arg))) + +(add-hook 'shell-mode-hook + (lambda () + (define-key shell-mode-map + (kbd "C-d") 'my/comint-delchar-or-eof-or-kill-buffer))) +;; TODO: this isn't working +(add-hook 'term-mode-hook + (lambda () + (define-key term-mode-map + (kbd "C-d") 'my/comint-delchar-or-eof-or-kill-buffer))) diff --git a/lisp/init-magit.el b/lisp/init-magit.el new file mode 100644 index 0000000..a12dd54 --- /dev/null +++ b/lisp/init-magit.el @@ -0,0 +1,34 @@ +;; full screen magit-status +(require 'magit) +(defadvice magit-status (around magit-fullscreen activate) + (window-configuration-to-register :magit-fullscreen) + ad-do-it + (delete-other-windows)) + +(defun my/magit-quit-session () + "Restores the previous window configuration and kills the magit buffer" + (interactive) + (kill-buffer) + (jump-to-register :magit-fullscreen)) + +(defun my/magit-toggle-whitespace () + "Toggles git option -w" + (interactive) + (if (member "-w" magit-diff-options) + (my/magit-dont-ignore-whitespace) + (my/magit-ignore-whitespace))) + +(defun my/magit-ignore-whitespace () + "Adds git option -w" + (interactive) + (add-to-list 'magit-diff-options "-w") + (magit-refresh)) + +(defun my/magit-dont-ignore-whitespace () + "Removes git option -w" + (interactive) + (setq magit-diff-options (remove "-w" magit-diff-options)) + (magit-refresh)) + +(define-key magit-status-mode-map (kbd "q") 'my/magit-quit-session) +(define-key magit-status-mode-map (kbd "W") 'my/magit-toggle-whitespace) |