From 465abf6de2f36015d8e241ce70cdc1fde294e357 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sat, 22 Nov 2014 04:10:02 -0800 Subject: [PATCH] mu4e and load-dir. --- init.el | 18 +++-- load.d/ensime-imenu.el | 147 +++++++++++++++++++-------------------- load.d/mu4e.el | 59 ++++++++++++++++ load.d/setup-slime-js.el | 124 --------------------------------- 4 files changed, 142 insertions(+), 206 deletions(-) create mode 100644 load.d/mu4e.el delete mode 100644 load.d/setup-slime-js.el diff --git a/init.el b/init.el index 80c57366..577db43d 100644 --- a/init.el +++ b/init.el @@ -86,7 +86,7 @@ (defvar packages-eager '(popup auto-complete yasnippet cl-lib exec-path-from-shell paradox slime xclip dired+ ctags ctags-update aggressive-indent imenu+ neotree diminish - gist load-dir)) + gist)) (use-packages packages-eager) @@ -233,6 +233,7 @@ buffer is not visiting a file." (column-number-mode t) (global-linum-mode t) (setq visible-bell nil) +(show-paren-mode 1) ;; Make buffer names unique. (setq uniquify-buffer-name-style 'forward) @@ -255,6 +256,11 @@ buffer is not visiting a file." ;; Make mouse scrolling less jumpy. (setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) +(use-package load-dir + :ensure t + :config + (progn (add-to-list 'load-dirs "~/.emacs.d/load.d"))) + (use-package tramp :commands tramp :config @@ -272,7 +278,7 @@ buffer is not visiting a file." :ensure t :config (progn - (setq guide-key/guide-key-sequence '("C-c" "C-c p" "C-x C-k" "C-x r")) + (setq guide-key/guide-key-sequence '("C-c" "C-c p" "C-x C-k" "C-x r" "C-x c")) (guide-key-mode 1) (setq guide-key/idle-delay 0.25) (setq guide-key/recursive-key-sequence-flag t) @@ -324,7 +330,8 @@ buffer is not visiting a file." :config (progn (diminish 'magit-auto-revert-mode) - (use-package magit-filenotify ;; Seems like OSX does not properly supoort this. + (use-package magit-filenotify + ;; Seems like OSX does not properly this. :disabled t :ensure t :if (emacs24_4-p) @@ -400,8 +407,7 @@ buffer is not visiting a file." (use-package org :ensure t - :defer t - :commands org + :commands org-mode :mode "\\.org\\'" :init (progn @@ -540,7 +546,7 @@ buffer is not visiting a file." (add-hook 'emacs-lisp-mode-hook 'flatten-current-imenu-index-function) (add-hook 'emacs-lisp-mode-hook (lambda () (setq indent-tabs-mode nil))) (define-key lisp-mode-shared-map (kbd "C-c C-c") 'eval-defun) -(define-key lisp-mode-shared-map (kbd "C-c C-f") 'find-function-at-point) +(define-key lisp-mode-shared-map (kbd "C-c C-f") 'find-function) (define-key lisp-mode-shared-map (kbd "C-c C-r") 'eval-and-replace) ;; ============================================================================= diff --git a/load.d/ensime-imenu.el b/load.d/ensime-imenu.el index d11b13b3..657f79fe 100644 --- a/load.d/ensime-imenu.el +++ b/load.d/ensime-imenu.el @@ -1,92 +1,87 @@ -;;; package -- Summary - -;;; Commentary: - -;;; Code: -(setq imenu-max-item-length 2000) -(setq imenu-space-replacement nil) -(setq scala-imenu:build-imenu-candidate 'ensime-imenu) -(setq scala-imenu:should-flatten-index t) -(defvar ensime-imenu-cache nil) -(add-to-list 'scala-imenu:cleanup-hooks (lambda () (setq ensime-imenu-cache nil))) +;; (setq imenu-max-item-length 2000) +;; (setq imenu-space-replacement nil) +;; (setq scala-imenu:build-imenu-candidate 'ensime-imenu) +;; (setq scala-imenu:should-flatten-index t) +;; (defvar ensime-imenu-cache nil) +;; (add-to-list 'scala-imenu:cleanup-hooks (lambda () (setq ensime-imenu-cache nil))) -(defun ensime-imenu (member-name definition-type marker parents) - `(,(ensime-imenu-string member-name definition-type marker parents) . - ,marker)) +;; (defun ensime-imenu (member-name definition-type marker parents) +;; `(,(ensime-imenu-string member-name definition-type marker parents) . +;; ,marker)) -(defun ensime-imenu-string (member-name definition-type marker parents) - (let ((scala-imenu-string (car (scala-imenu:default-build-imenu-candidate - member-name definition-type marker parents)))) - (if (equal definition-type "def") - (let ((ensime-type-string - (get-ensime-type member-name definition-type marker parents))) - (message ensime-type-string) - (format "%s%s" scala-imenu-string ensime-type-string)) - scala-imenu-string))) +;; (defun ensime-imenu-string (member-name definition-type marker parents) +;; (let ((scala-imenu-string (car (scala-imenu:default-build-imenu-candidate +;; member-name definition-type marker parents)))) +;; (if (equal definition-type "def") +;; (let ((ensime-type-string +;; (get-ensime-type member-name definition-type marker parents))) +;; (message ensime-type-string) +;; (format "%s%s" scala-imenu-string ensime-type-string)) +;; scala-imenu-string))) -(defun get-ensime-type (member-name definition-type marker parents) - (let ((parent-name (caar parents)) - (parent-marker (caddar parents))) - (build-method-type - (plist-get (type-info member-name parent-name parent-marker) :type)))) +;; (defun get-ensime-type (member-name definition-type marker parents) +;; (let ((parent-name (caar parents)) +;; (parent-marker (caddar parents))) +;; (build-method-type +;; (plist-get (type-info member-name parent-name parent-marker) :type)))) -(defun build-method-type (type-info) - (format "%s: %s" - (build-argument-lists (plist-get type-info :param-sections)) - (build-type-string (plist-get type-info :result-type)))) +;; (defun build-method-type (type-info) +;; (format "%s: %s" +;; (build-argument-lists (plist-get type-info :param-sections)) +;; (build-type-string (plist-get type-info :result-type)))) -(defun build-argument-lists (param-list-infos) - (mapconcat 'build-argument-list param-list-infos "")) +;; (defun build-argument-lists (param-list-infos) +;; (mapconcat 'build-argument-list param-list-infos "")) -(defun build-argument-list (param-list-info) - (format "(%s)" (mapconcat 'build-argument-string - (plist-get param-list-info :params) ", "))) +;; (defun build-argument-list (param-list-info) +;; (format "(%s)" (mapconcat 'build-argument-string +;; (plist-get param-list-info :params) ", "))) -(defun build-argument-string (param-info) - (format "%s: %s" (car param-info) - (build-type-string (cadr param-info)))) +;; (defun build-argument-string (param-info) +;; (format "%s: %s" (car param-info) +;; (build-type-string (cadr param-info)))) -(defun build-type-string (type-info) - (let ((name (plist-get type-info :name)) - (type-args (plist-get type-info :type-args))) - (format "%s%s" name - (if type-args - (format "[%s]" (mapconcat - 'build-type-string type-args ", ")) "")))) +;; (defun build-type-string (type-info) +;; (let ((name (plist-get type-info :name)) +;; (type-args (plist-get type-info :type-args))) +;; (format "%s%s" name +;; (if type-args +;; (format "[%s]" (mapconcat +;; 'build-type-string type-args ", ")) "")))) -(defun type-info (member-name type-name marker) - (get-plist-by-keys '(:name) member-name - (get-members type-name - (get-ensime-type-info-from-mark marker)))) +;; (defun type-info (member-name type-name marker) +;; (get-plist-by-keys '(:name) member-name +;; (get-members type-name +;; (get-ensime-type-info-from-mark marker)))) -(defun get-members (type-name type-info-plist) - (plist-get-deep (get-plist-by-keys - '(:type :name) type-name - (plist-get type-info-plist :interfaces)) '(:type :members))) +;; (defun get-members (type-name type-info-plist) +;; (plist-get-deep (get-plist-by-keys +;; '(:type :name) type-name +;; (plist-get type-info-plist :interfaces)) '(:type :members))) -(defun plist-get-deep (plist keys) - (cl-reduce 'plist-get keys :initial-value plist)) +;; (defun plist-get-deep (plist keys) +;; (cl-reduce 'plist-get keys :initial-value plist)) -(defun get-plist-by-keys (keys value plist) - (cl-find value plist :test 'equal - :key (lambda (member) - (plist-get-deep member keys)))) +;; (defun get-plist-by-keys (keys value plist) +;; (cl-find value plist :test 'equal +;; :key (lambda (member) +;; (plist-get-deep member keys)))) -(defun get-ensime-type-info-from-mark (marker) - (let ((cached-value (assoc marker ensime-imenu-cache))) - (when (not cached-value) - (progn (setq cached-value - `(,marker . ,(ensime-rpc-inspect-type-at-range (get-eol-range marker)))) - (setq ensime-imenu-cache (cons cached-value ensime-imenu-cache)))) - (cdr cached-value))) +;; (defun get-ensime-type-info-from-mark (marker) +;; (let ((cached-value (assoc marker ensime-imenu-cache))) +;; (when (not cached-value) +;; (progn (setq cached-value +;; `(,marker . ,(ensime-rpc-inspect-type-at-range (get-eol-range marker)))) +;; (setq ensime-imenu-cache (cons cached-value ensime-imenu-cache)))) +;; (cdr cached-value))) -(defun get-eol-range (marker) - (interactive) - `(,(marker-position marker) - ,(save-excursion (goto-char marker) (end-of-line) (point)))) +;; (defun get-eol-range (marker) +;; (interactive) +;; `(,(marker-position marker) +;; ,(save-excursion (goto-char marker) (end-of-line) (point)))) -(defun msg-type-info () - (interactive) - (message "%s" (build-method-type - (plist-get (type-info "testFunction" "DFA" (point-marker)) :type)))) +;; (defun msg-type-info () +;; (interactive) +;; (message "%s" (build-method-type +;; (plist-get (type-info "testFunction" "DFA" (point-marker)) :type)))) diff --git a/load.d/mu4e.el b/load.d/mu4e.el new file mode 100644 index 00000000..27ba40f9 --- /dev/null +++ b/load.d/mu4e.el @@ -0,0 +1,59 @@ +(use-package s :ensure t) +(add-to-list 'load-path (s-trim (shell-command-to-string "mu4e_directory"))) + +(use-package mu4e + :config + (progn + (setq mu4e-maildir "~/Mail") + + (setq mu4e-drafts-folder "/[Gmail].Drafts") + (setq mu4e-sent-folder "/[Gmail].Sent Mail") + (setq mu4e-trash-folder "/[Gmail].Trash") + + ;; don't save message to Sent Messages, Gmail/IMAP takes care of this + (setq mu4e-sent-messages-behavior 'delete) + + ;; setup some handy shortcuts + ;; you can quickly switch to your Inbox -- press ``ji'' + ;; then, when you want archive some messages, move them to + ;; the 'All Mail' folder by pressing ``ma''. + + (setq mu4e-maildir-shortcuts + '( ("/INBOX" . ?i) + ("/[Gmail].Sent Mail" . ?s) + ("/[Gmail].Trash" . ?t) + ("/[Gmail].All Mail" . ?a))) + + ;; allow for updating mail using 'U' in the main view: + (setq mu4e-get-mail-command "offlineimap") + + ;; ;; something about ourselves + ;; (setq + ;; mu4e-compose-signature + ;; (concat + ;; "Foo X. Bar\n" + ;; "http://www.example.com\n")) + + ;; sending mail -- replace USERNAME with your gmail username + ;; also, make sure the gnutls command line utils are installed + ;; package 'gnutls-bin' in Debian/Ubuntu + + (require 'smtpmail) + ;; (setq message-send-mail-function 'smtpmail-send-it + ;; starttls-use-gnutls t + ;; smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)) + ;; smtpmail-auth-credentials + ;; '(("smtp.gmail.com" 587 "USERNAME@gmail.com" nil)) + ;; smtpmail-default-smtp-server "smtp.gmail.com" + ;; smtpmail-smtp-server "smtp.gmail.com" + ;; smtpmail-smtp-service 587) + + ;; alternatively, for emacs-24 you can use: + (setq message-send-mail-function 'smtpmail-send-it + smtpmail-stream-type 'starttls + smtpmail-default-smtp-server "smtp.gmail.com" + smtpmail-smtp-server "smtp.gmail.com" + smtpmail-smtp-service 587) + + ;; don't keep message buffers around + (setq message-kill-buffer-on-exit t))) diff --git a/load.d/setup-slime-js.el b/load.d/setup-slime-js.el deleted file mode 100644 index 6aa02e97..00000000 --- a/load.d/setup-slime-js.el +++ /dev/null @@ -1,124 +0,0 @@ -;; Taken from https://github.com/magnars/.emacs.d/blob/master/setup-slime-js.el -;; js2-refactor is commented out - -;; Set up slime-js -;; -;; To install, see https://github.com/swank-js/swank-js/wiki/Installation -;; -;; This is what I did: -;; -;; npm install swank-js -g -;; M-x package-install slime-js -;; -;; The slime-js version in marmalade requires swank 2010.04.04, or at least -;; one prior to the breaking change in 2011. -;; -;; It also requires js2-mode, which is a good choice in either case. I highly -;; recommend this fork: -;; -;; https://github.com/mooz/js2-mode -;; -;; My settings found in this file also requires js2-refactor: -;; -;; https://github.com/magnars/js2-refactor.el -;; -;; I have included this file in init.el like so: -;; -;; (add-hook 'after-init-hook -;; #'(lambda () -;; (when (locate-library "slime-js") -;; (require 'setup-slime-js)))) -;; - -(require 'slime) -(require 'slime-js) -;(require 'js2-refactor) - -(set-default 'slime-js-target-url "http://localhost:3000") -(set-default 'slime-js-connect-url "http://localhost:8009") -(set-default 'slime-js-starting-url "/") -(set-default 'slime-js-swank-command "swank-js") -(set-default 'slime-js-swank-args '()) -(set-default 'slime-js-browser-command "open -v \"Google Chrome\"") -(set-default 'slime-js-browser-jacked-in-p nil) - -(add-hook 'js2-mode-hook (lambda () (slime-js-minor-mode 1))) - -(defun slime-js-run-swank () - "Runs the swank side of the equation." - (interactive) - (apply #'make-comint "swank-js" slime-js-swank-command nil slime-js-swank-args)) - -(defun slime-js-jack-in-node () - "Start a swank-js server and connect to it, opening a repl." - (interactive) - (slime-js-run-swank) - (sleep-for 1) - (setq slime-protocol-version 'ignore) - (slime-connect "localhost" 4005)) - -(defun slime-js-jack-in-browser () - "Start a swank-js server, connect to it, open a repl, open a browser, connect to that." - (interactive) - (slime-js-jack-in-node) - (sleep-for 2) - (slime-js-set-target-url slime-js-target-url) - (shell-command (concat slime-js-browser-command " " slime-js-connect-url slime-js-starting-url)) - (sleep-for 3) - (setq slime-remote-history nil) - (slime-js-sticky-select-remote (caadr (slime-eval '(js:list-remotes)))) - (setq slime-js-browser-jacked-in-p t) - (global-set-key [f5] 'slime-js-reload)) - -(defadvice save-buffer (after save-css-buffer activate) - (when (and slime-js-browser-jacked-in-p (eq major-mode 'css-mode)) - (slime-js-refresh-css))) - -(defun js2-eval-friendly-node-p (n) - (or (and (js2-stmt-node-p n) (not (js2-block-node-p n))) - (and (js2-function-node-p n) (js2-function-node-name n)))) - -(defun slime-js--echo-result (result &rest _) - (message result)) - -(defun slime-js--replace-with-result (replacement beg end) - (save-excursion - (goto-char beg) - (delete-char (- end beg)) - (insert replacement))) - -(defun slime-js-eval-region (beg end &optional func) - (lexical-let ((func (or func 'slime-js--echo-result)) - (beg beg) - (end end)) - (slime-flash-region beg end) - (slime-js-eval - (buffer-substring-no-properties beg end) - #'(lambda (s) (funcall func (cadr s) beg end))))) - -(defun slime-js-eval-statement (&optional func) - (let ((node (js2r--closest 'js2-eval-friendly-node-p))) - (slime-js-eval-region (js2-node-abs-pos node) - (js2-node-abs-end node) - func))) - -(defun slime-js-eval-current () - (interactive) - (if (use-region-p) - (slime-js-eval-region (point) (mark)) - (slime-js-eval-statement))) - -(defun slime-js-eval-and-replace-current () - (interactive) - (if (use-region-p) - (slime-js-eval-region (point) (mark) 'slime-js--replace-with-result) - (slime-js-eval-statement 'slime-js--replace-with-result))) - -(define-key slime-js-minor-mode-map (kbd "C-x C-e") 'slime-js-eval-current) -(define-key slime-js-minor-mode-map (kbd "C-c C-e") 'slime-js-eval-and-replace-current) - -;; Remove slime-minor-mode from mode line if diminish.el is installed -(when (boundp 'diminish) - (diminish 'slime-js-minor-mode)) - -(provide 'setup-slime-js)