Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
1118 lines (926 sloc) 35.7 KB

ddavis dotfiles

emacs init file

Emacs init written with org-mode to have at least a little bit of organization. Lot’s of use-package use going on here.

setup MELPA

(require 'package)

(unless (string= system-name "")
  (let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
                      (not (gnutls-available-p))))
         (proto (if no-ssl "http" "https")))
    (when no-ssl
      (warn "no ssl bad :("))
    ;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
    (add-to-list 'package-archives (cons "melpa" (concat proto "://")) t)
    (add-to-list 'package-archives (cons "org" (concat proto "://")) t)
    (when (< emacs-major-version 24)
      ;; For important compatibility libraries like cl-lib
      (add-to-list 'package-archives (cons "gnu" (concat proto "://"))))))

(when (string= system-name "")
  (add-to-list 'package-archives (cons "melpa" "") t)
  (add-to-list 'package-archives (cons "org" "") t))

(when (version< emacs-version "27.0.50")

ensure use-package

(unless (package-installed-p 'use-package)
  (package-install 'use-package))

(eval-when-compile (require 'use-package))

(setq use-package-always-ensure t)


(use-package auto-package-update
  :ensure t
  (setq auto-package-update-delete-old-versions t
        auto-package-update-interval 5)


(use-package exec-path-from-shell
  :if (eq system-type 'darwin)
  :ensure t
  (setq exec-path-from-shell-variables '("PATH"  "MANPATH" "SHELL"))
(use-package shell-pop)


(setq custom-file (concat user-emacs-directory "/custom.el"))
(setq inhibit-startup-screen t)

(when (eq system-type ‘darwin) (setq mac-right-command-modifier ‘super) ;; (setq mac-left-option-modifier ‘meta) (setq mac-option-modifier ‘meta) (setq mac-command-modifier ‘super))

(when (and (eq system-type 'darwin) (display-graphic-p))
  (setq-default ns-alternate-modifier 'meta)
  (setq-default mac-option-modifier 'meta)
  (setq-default ns-right-alternate-modifier nil))

s- means super key. On OS X I want this to be ⌘:

(when (and (eq system-type 'darwin) (display-graphic-p))
  (setq-default ns-command-modifier 'super)
  (setq-default mac-command-modifier 'super))

H- means hyper key. On OS X I want this to be fn:

(when (and (eq system-type 'darwin) (display-graphic-p))
  (setq-default ns-function-modifier 'hyper)
  (setq-default mac-function-modifier 'hyper))

machine dependent vars

Set some machine dependent variables that we’ll use later. Defaults are set to macOS setup. Doing this all in one place to isolate all of the when/if calls that would be spread out otherwise.

(defvar ddavis-font '(font . "SF Mono-12")
  "default font to use")
(defvar ddavis-clang-exe "/usr/local/opt/llvm/bin/clang"
  "clang executable path")
(defvar ddavis-clangd-exe "/usr/local/opt/llvm/bin/clangd"
  "clangd executable path")
(defvar ddavis-rg-exe "/usr/local/bin/rg"
  "ripgrep executable")
(defvar ddavis-default-python "~/Software/Python/anaconda3/bin/python3"
  "default python exe")
(defvar ddavis-default-ipython "~/Software/Python/anaconda3/bin/ipython3"
  "default ipython exe")
(defvar ddavis-default-pyls "~/Software/Python/anaconda3/bin/pyls"
  "default pyls")

;;(when (eq system-type 'darwin)
;;  (mac-auto-operator-composition-mode))

(when (string= (system-name) "")
  (setq ddavis-font '(font . "-*-source code pro-semibold-*-normal-*-*-100-100-100-m-0-*-*")
        ddavis-clang-exe "~/Software/LLVM/releases/master/bin/clang"
        ddavis-clangd-exe "~/Software/LLVM/releases/master/bin/clangd"
        ddavis-rg-exe "~/.cargo/bin/rg")
  (setq browse-url-browser-function 'browse-url-generic
        browse-url-generic-program "google-chrome"))

(when (string= (system-name) "cc7")
  (setq ddavis-font '(font . "-*-source code pro-semibold-*-normal-*-*-120-120-100-m-0-*-*")
        ddavis-clang-exe "~/Software/LLVM/releases/10.0.0-20190725/bin/clang"
        ddavis-clangd-exe "~/Software/LLVM/releases/10.0.0-20190725/bin/clangd"
        ddavis-rg-exe "~/.cargo/bin/rg")
  (setq browse-url-browser-function 'browse-url-generic
        browse-url-generic-program "google-chrome"))

(when (string= (system-name) "pion")
  ;; (setq ddavis-font '(font . "-*-fira code retina-medium-*-normal-*-*-120-120-100-m-0-*-*")
  (setq ddavis-font '(font . "-*-source code pro-semibold-*-normal-*-*-120-120-100-m-0-*-*")
        ddavis-clang-exe "/usr/bin/clang"
        ddavis-clangd-exe "/usr/bin/clangd")
  (setq browse-url-browser-function 'browse-url-generic
        browse-url-generic-program "google-chrome"))


initial setup

(defun ddavis/mu4e-machines ()
  (bool-vector (eq system-type 'darwin)
               (string= (system-name) "pion")
               (string= (system-name) "")
               (string= (system-name) "cc7")))

(setq ddavis-use-mu4e
      (> (bool-vector-count-population
          (ddavis/mu4e-machines)) 0))

(when ddavis-use-mu4e

  ;;(setq mu4e-view-use-gnus t)

  (setq mu4e-change-filenames-when-moving t)
  (setq mu4e-get-mail-command "mbsync standard")

  (setq mu4e-update-interval 90
        mu4e-maildir "~/.mail"
        message-send-mail-function 'message-send-mail-with-sendmail)

  (when (eq system-type 'darwin)
    (add-to-list 'load-path "~/Software/localbase/share/emacs/site-lisp/mu4e")
    (setq sendmail-program "~/Software/localbase/bin/msmtp"
          mu4e-get-mail-command "~/Software/localbase/bin/mbsync standard"
          mu4e-mu-binary "~/Software/localbase/bin/mu"))

  (when (string= (system-name) "")
    (add-to-list 'load-path "~/Software/localbase/share/emacs/site-lisp/mu4e")
    (setq sendmail-program "/usr/bin/msmtp"
          mu4e-mu-binary "~/Software/localbase/bin/mu"))

  (when (string= (system-name) "pion")
    (add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e")
    (setq sendmail-program "/usr/bin/msmtp"
          mu4e-mu-binary "/usr/bin/mu"))

  (when (string= (system-name) "cc7")
    (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
    (setq sendmail-program "~/Software/localbase/bin/msmtp"
          mu4e-mu-binary "/usr/local/bin/mu"))

  (setq message-sendmail-f-is-evil t
        message-sendmail-extra-arguments '("--read-envelope-from"))

  (require 'mu4e)

  (setq message-kill-buffer-on-exit t)

  (define-key global-map (kbd "C-c 4") 'mu4e)
  (define-key mu4e-headers-mode-map (kbd "C-c k") 'mu4e-kill-update-mail)
  (define-key mu4e-view-mode-map (kbd "C-c k") 'mu4e-kill-update-mail)
  (define-key mu4e-main-mode-map (kbd "C-c k") 'mu4e-kill-update-mail))


(when ddavis-use-mu4e
  (setq mu4e-contexts
        `( ,(make-mu4e-context
             :name "cern"
             :enter-func (lambda () (mu4e-message "Entering CERN context"))
             :leave-func (lambda () (mu4e-message "Leaving CERN context"))
             :match-func (lambda (msg)
                           (when msg
                             (string-match-p "^/cern" (mu4e-message-field msg :maildir))))
             :vars '( ( user-mail-address      . "" )
                      ( user-email-address     . "" )
                      ( user-full-name         . "Douglas Davis" )
                      ( mu4e-trash-folder      . "/cern/Trash" )
                      ( mu4e-sent-folder       . "/cern/Sent" )
                      ( mu4e-drafts-folder     . "/cern/Drafts" )
                      ( mu4e-reply-to-address  . "" )))

             :name "duke"
             :enter-func (lambda () (mu4e-message "Entering Duke context"))
             :leave-func (lambda () (mu4e-message "Leaving Duke Context"))
             :match-func (lambda (msg)
                           (when msg
                             (string-match-p "^/duke" (mu4e-message-field msg :maildir))))
             :vars '( ( user-mail-address       . "" )
                      ( user-email-address      . "" )
                      ( user-full-name          . "Douglas Davis" )
                      ( mu4e-trash-folder       . "/duke/Trash" )
                      ( mu4e-sent-folder        . "/duke/Sent" )
                      ( mu4e-drafts-folder      . "/duke/Drafts" )
                      ( mu4e-reply-to-address   . "" ))))))

(when (and (or (eq system-type 'darwin) (string= (system-name) "cc7"))  ddavis-use-mu4e)
  (add-to-list 'mu4e-contexts
                :name "fastmail"
                :enter-func (lambda () (mu4e-message "Entering FastMail context"))
                :leave-func (lambda () (mu4e-message "Leaving FastMail context"))
                :match-func (lambda (msg)
                              (when msg
                                (string-match-p "^/fastmail" (mu4e-message-field msg :maildir))))
                :vars '( ( user-mail-address      . "" )
                         ( user-email-address     . "" )
                         ( user-full-name         . "Doug Davis" )
                         ( mu4e-trash-folder      . "/fastmail/Trash" )
                         ( mu4e-sent-folder       . "/fastmail/Sent" )
                         ( mu4e-drafts-folder     . "/fastmail/Drafts" )
                         ( mu4e-reply-to-address  . "" )))))


(when ddavis-use-mu4e
  (setq mu4e-bookmarks ())
  (add-to-list 'mu4e-bookmarks
                :name "The week"
                :query ""
                :key ?7))
  (add-to-list 'mu4e-bookmarks
                :name "Unread"
                :query "flag:unread AND NOT flag:trashed"
                :key ?u))
  (add-to-list 'mu4e-bookmarks
                :name "Since yesterday INBOXes"
                :query " and (m:/duke/INBOX or m:/cern/INBOX or m:/fastmail/INBOX)"
                :key ?i))
  (add-to-list 'mu4e-bookmarks
                :name "All since yesterday"
                :query ""
                :key ?y))
  (add-to-list 'mu4e-bookmarks
                :name "Last 3 days"
                :query ""
                :key ?3))
  (add-to-list 'mu4e-bookmarks
                :name "Duke today"
                :query " and m:/duke*"
                :key ?d))
  (add-to-list 'mu4e-bookmarks
                :name "Last day's work"
                :query " and not m:/fastmail* and not m:/cern/Mailing\\ Lists/JEDI*"
                :key ?w))
  (add-to-list 'mu4e-bookmarks
                :name "Recent work"
                :query " and not m:/fastmail* and not m:/cern/Mailing\\ Lists/JEDI*"
                :key ?r))
  (add-to-list 'mu4e-bookmarks
                :name "FastMail today"
                :query " and m:/fastmail*"
                :key ?f))
  (add-to-list 'mu4e-bookmarks
                :name "CERN since yesterday"
                :query " and m:/cern*"
                :key ?c)))


This code is taken from this gist.

   (when ddavis-use-mu4e

     ;; Refactored from

     (defun mu4e~headers-msg-unread-p (msg)
	 "Check if MSG is unread."
	 (let ((flags (mu4e-message-field msg :flags)))
	   (and (member 'unread flags) (not (member 'trashed flags)))))

     (defvar mu4e-headers-folding-slug-function
	 (lambda (headers) (format " (%d)" (length headers)))
	 "Function to call to generate the slug that will be appended to folded threads.
   This function receives a single argument HEADERS, which is a list
   of headers about to be folded.")

     (defun mu4e~headers-folded-slug (headers)
	 "Generate a string to append to the message line indicating the fold status.
   HEADERS is a list with the messages being folded (including the root header)."
	 (funcall mu4e-headers-folding-slug-function headers))

     (defun mu4e~headers-fold-make-overlay (beg end headers)
	 "Hides text between BEG and END using an overlay.
   HEADERS is a list with the messages being folded (including the root header)."
	 (let ((o (make-overlay beg end)))
	   (overlay-put o 'mu4e-folded-thread t)
	   (overlay-put o 'display (mu4e~headers-folded-slug headers))
	   (overlay-put o 'evaporate t)
	   (overlay-put o 'invisible t)))

     (defun mu4e~headers-fold-find-overlay (loc)
	 "Find and return the 'mu4e-folded-thread overlay at LOC, or return nil."
	 (cl-dolist (o (overlays-in (1- loc) (1+ loc)))
	   (when (overlay-get o 'mu4e-folded-thread)
	     (cl-return o))))

     (defun mu4e-headers-fold-all ()
	 "Fold all the threads in the current view."
	 (let ((thread-id "") msgs fold-start fold-end)
	    (lambda (msg)
	      (push msg msgs)
	      (let ((this-thread-id (mu4e~headers-get-thread-info msg 'thread-id)))
		(if (string= thread-id this-thread-id)
		    (setq fold-end (point))
		  (when (< 1 (length msgs))
		    (mu4e~headers-fold-make-overlay fold-start fold-end (nreverse msgs)))
		  (setq fold-start (point)
			fold-end (point)
			msgs nil
			thread-id this-thread-id)))))
	   (when (< 1 (length msgs))
	     (mu4e~headers-fold-make-overlay fold-start fold-end (nreverse msgs)))))

     (defun mu4e-headers-toggle-thread-folding (&optional subthread)
	 "Toggle the folding state for the thread at point.
   If SUBTHREAD is non-nil, only fold the current subthread."
	 ;; Folding is accomplished using an overlay that starts at the end
	 ;; of the parent line and ends at the end of the last descendant
	 ;; line. If there's no overlay, it means it isn't folded
	 (interactive "P")
	 (if-let ((o (mu4e~headers-fold-find-overlay (point-at-eol))))
		 (delete-overlay o)
		 (let* ((msg (mu4e-message-at-point))
			(thread-id (mu4e~headers-get-thread-info msg 'thread-id))
			(path-re (concat "^" (mu4e~headers-get-thread-info msg 'path)))
			msgs first-marked-point last-marked-point)
		    (lambda (submsg)
		      (when (and (string= thread-id (mu4e~headers-get-thread-info submsg 'thread-id))
				 (or (not subthread)
				     (string-match-p path-re (mu4e~headers-get-thread-info submsg 'path))))
			(push msg msgs)
			(setq last-marked-point (point-at-eol))
			(unless first-marked-point
			  (setq first-marked-point last-marked-point)))))
		   (when (< 1 (length msgs))
		     (mu4e~headers-fold-make-overlay first-marked-point last-marked-point (nreverse msgs))))))

     (define-key 'mu4e-headers-mode-map (kbd "TAB") 'mu4e-headers-toggle-thread-folding)
     (define-key 'mu4e-headers-mode-map (kbd "C-c TAB") 'mu4e-headers-fold-all))


(when ddavis-use-mu4e
  (setq mu4e-compose-reply-ignore-address
(when ddavis-use-mu4e
  (defun ddavis/mu4e-toggle-gnus ()
    (setq mu4e-view-use-gnus (not mu4e-view-use-gnus)))
  (define-key mu4e-headers-mode-map (kbd "C-c g") 'ddavis/mu4e-toggle-gnus))

(use-package mu4e-maildirs-extension :ensure t :after mu4e :config (mu4e-maildirs-extension))

(when ddavis-use-mu4e
  (setq w3m-default-desplay-inline-images t)
  (defun mu4e-action-view-in-w3m ()
    "View the body of the message in emacs w3m."
    (w3m-browse-url (concat "file://"
                            (mu4e~write-body-to-html (mu4e-message-at-point t)))))
  (define-key mu4e-view-mode-map (kbd "M") 'mu4e-action-view-in-w3m))

(when ddavis-use-mu4e (use-package visual-fill-column :ensure t :after mu4e :hook ((visual-line-mode . visual-fill-column-mode) (mu4e-view-mode . visual-line-mode)) :config (add-hook ‘mu4e-view-mode-hook (lambda () (setq-local fill-column 98)))))


(use-package projectile
  :ensure t
  (after-init . projectile-mode))


(use-package helm
  :ensure t
  (setq helm-autoresize-max-height 50)
  (setq helm-autoresize-min-height 30)
  (require 'helm-config)
  (setq helm-split-window-in-side-p t
        helm-split-window-default-side 'below
        helm-idle-delay 0.0
        helm-input-idle-delay 0.01
        helm-quick-update t
        helm-ff-skip-boring-files t)
  (helm-autoresize-mode 1)
  (helm-mode 1)
  :bind (("C-x C-f" . helm-find-files)
         ("C-x C-t" . find-file)
         ("C-x b" . helm-buffers-list)
         ("C-x r b" . helm-bookmarks)
         ("C-x m" . helm-M-x)
         :map helm-map
         ("<tab>" . helm-execute-persistent-action)))

(use-package helm-projectile
  :ensure t
  (setq projectile-completion-system 'helm)
  (require 'helm-projectile)
  (define-key global-map (kbd "C-c h p") 'helm-projectile)
  (setq helm-split-window-in-side-p t))

(use-package helm-rg
  :ensure t
  (setq helm-rg-ripgrep-executable ddavis-rg-exe)
  (require 'helm-rg)
  (define-key global-map (kbd "C-c s r") 'helm-projectile-rg))


(use-package which-key
  :ensure t
  (after-init . which-key-mode))

tramp fix

(setq tramp-default-method "ssh")


(use-package yasnippet
  :ensure t
  (require 'yasnippet)
  (yas-global-mode 1))

(use-package yasnippet-snippets
  :ensure t
  (require 'yasnippet-snippets))


(use-package iedit
  :ensure t
  :bind ("C-c ;" . 'iedit-mode))


(when window-system (use-package solarized-theme :ensure t :init (setq custom-safe-themes t) :config (setq solarized-scale-org-headlines nil) ;; make the fringe stand out from the background (setq solarized-distinct-fringe-background t) ;; Don’t change the font for some headings and titles (setq solarized-use-variable-pitch nil) ;; Avoid all font-size changes (setq solarized-height-minus-1 1.0) (setq solarized-height-plus-1 1.0) (setq solarized-height-plus-2 1.0) (setq solarized-height-plus-3 1.0) (setq solarized-height-plus-4 1.0) (load-theme ‘solarized-light) (let ((line (face-attribute ‘mode-line :underline))) (set-face-attribute ‘mode-line nil :overline line) (set-face-attribute ‘mode-line-inactive nil :overline line) (set-face-attribute ‘mode-line-inactive nil :underline line) (set-face-attribute ‘mode-line nil :box nil) (set-face-attribute ‘mode-line-inactive nil :box nil) (set-face-attribute ‘mode-line-buffer-id nil :box nil))))

(use-package gruvbox-theme
  :ensure t
  (setq custom-safe-themes t)
  (load-theme 'gruvbox t)
  (let ((line (face-attribute 'mode-line :underline)))
    (set-face-attribute 'mode-line           nil :overline   line)
    (set-face-attribute 'mode-line-inactive  nil :overline   line)
    (set-face-attribute 'mode-line-inactive  nil :underline  line)
    (set-face-attribute 'mode-line           nil :box        nil)
    (set-face-attribute 'mode-line-inactive  nil :box        nil)
    (set-face-attribute 'mode-line-buffer-id nil :box        nil)))

(when window-system (use-package srcery-theme :ensure t :init (setq custom-safe-themes t) :config (setq srcery-org-height nil) (load-theme ‘srcery t) (let ((line (face-attribute ‘mode-line :underline))) (set-face-attribute ‘mode-line nil :overline line) (set-face-attribute ‘mode-line-inactive nil :overline line) (set-face-attribute ‘mode-line-inactive nil :underline line) (set-face-attribute ‘mode-line nil :box nil) (set-face-attribute ‘mode-line-inactive nil :box nil) (set-face-attribute ‘mode-line-buffer-id nil :box nil))))

moody and minions

(use-package moody :ensure t :config (setq x-underline-at-descent-line t) (if (eq system-type ‘darwin) (setq moody-slant-function #’moody-slant-apple-rgb)) (moody-replace-mode-line-buffer-identification) (moody-replace-vc-mode))

(use-package minions :ensure t :config (minions-mode 1))

tabs are spaces

(setq-default indent-tabs-mode nil)


Not liking this right now so dont use

(setq split-width-threshold 0
      split-height-threshold nil)

no ring

(setq ring-bell-function 'ignore)


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


(setq echo-keystrokes 0.001)

{menu,tool,scroll} bar off

(scroll-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(menu-bar-mode -1)

line numbers

(when (version<= "26.0.50" emacs-version)
(setq column-number-mode t)

window size

(add-to-list 'default-frame-alist '(height . 80))
(add-to-list 'default-frame-alist '(width . 248))


(setq show-paren-delay 0)
(show-paren-mode 1)


(setq vc-follow-symlinks t)


(use-package magit
  :ensure t
  :bind ("C-c m s" . 'magit-status))

save and lock files

;; put ~ files in ~/.saves
 backup-by-copying t
 '(("." . "~/.saves"))
 delete-old-versions t
 kept-new-versions 3
 kept-old-versions 2
 version-control t)
(setq create-lockfiles nil)


(add-to-list 'default-frame-alist ddavis-font)
(set-face-italic 'font-lock-comment-face nil)
(when (string= (system-name) "")
  (set-face-attribute 'region nil :background "white" :foreground "dim gray" :inverse-video t))
;; See the following for more details
;; and also see the following on a recent GNU/Linux or similar system:
;;     /usr/share/doc/fontconfig/fontconfig-user.html
;; for the explanation of spacing=100
;; also see the following UNIX StackExchange answer:
(defun ddavis/compare-monospace-font-families ()
  "Display a list of all monospace font faces. Tested on GNU/Linux."
  (pop-to-buffer "*Monospace Fonts*")
  (dolist (font-name (seq-filter (lambda (font)
                                   (when-let ((info (font-info font)))
                                     (string-match-p "spacing=100" (aref info 1))))
      (concat "1 l; 0 O o [ < = > ] " font-name ")\n")
      'font-lock-face `((:family
                         ,(format "%s" (font-get (font-spec :name font-name) :family))))))))



(use-package org
  :bind (("<A-down>" . 'org-move-subtree-down)
         ("<A-up>" . 'org-move-subtree-up)
         ("<A-left>" . 'org-promote-subtree)
         ("<A-right>" . 'org-demote-subtree))
  (setq org-src-fontify-natively t)
  (setq org-structure-template-alist
        (append org-structure-template-alist
                '(("el" . "src emacs-lisp :results silent")
                  ("py" . "src python :results silent")
                  ("cpp" . "src C++")))))

;;(use-package org-bullets
;;  :ensure t
;;  :hook
;;  (org-mode . org-bullets-mode))

extra ox

(require 'ox-md)

(use-package ox-hugo
  :ensure t
  :after ox)

(use-package ox-reveal
  :ensure t
  :after ox)
(defun ddavis/fix-org-beamer ()
  "this was a random function to fix a weird issue with
    recent version of org-mode; im not sure if its really
    necessary anymore."
  (setq org-structure-template-alist
        (delete '("n" "#+BEGIN_NOTES\n?\n#+END_NOTES")
(add-hook 'org-mode-hook 'ddavis/fix-org-beamer)


 '((python . t)))


(define-key global-map "\C-ca" 'org-agenda)
(setq org-agenda-files (list "~/Dropbox/org/agenda/"))

(setq org-agenda-custom-commands
      '(("c" "Simple agenda view"
         ((agenda "")
          (alltodo "")))))

html stuff

(use-package htmlize
  :ensure t)


 (lambda (language-mode-hook)
   (add-hook language-mode-hook 'flyspell-mode))

executable scripts

dont use for now

(defun ddavis/force-scripts-executable () (interactive) (add-hook ‘after-save-hook ‘executable-make-buffer-file-executable-if-script-p)) (ddavis/force-scripts-executable)



(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.icc\\'" . c++-mode))

IDE via eglot

(defun ddavis/projectile-proj-find-function (dir)
  (let ((root (projectile-project-root dir)))
    (and root (cons 'transient root))))

(defun ddavis/cpp-eglot-setup ()
  "enable variables and hooks for eglot cpp IDE"
  (use-package eglot
    :ensure t
    (require 'eglot))
  (delete 'company-capf company-backends)
  (add-to-list 'company-backends' 'company-capf)
  (projectile-mode t)
  (with-eval-after-load 'project
    (add-to-list 'project-find-functions 'ddavis/projectile-proj-find-function))
  (add-to-list 'eglot-server-programs
               `((c++-mode cc-mode) ,ddavis-clangd-exe)))



(use-package pyvenv
  :ensure t)

(use-package elpy
  :ensure t)

format with black

(use-package blacken
  :ensure t)

(defun ddavis/blacken-96 ()
  (setq blacken-line-length 96))

IDE via eglot

(defun ddavis/python-eglot-enable ()
  "set variables and hook for eglot python IDE"
  (use-package eglot
    :ensure t
    (require 'eglot))
  (setq company-backends (cons 'company-capf (remove 'company-capf company-backends)))
  (add-to-list 'eglot-server-programs
               `((python-mode) ,ddavis-default-pyls)))


(use-package lsp-mode
  :ensure t
  :commands lsp
  (setq lsp-clients-clangd-executable ddavis-clangd-exe)
  (setq lsp-enable-on-type-formatting nil)
  (setq lsp-auto-guess-root t))

(use-package lsp-ui
  :ensure t
  :commands lsp-ui-mode
  (setq lsp-ui-sideline-show-hover nil))

(use-package company-lsp
  :ensure t
  :commands company-lsp)

delete trailing white space

 (lambda (language-mode-hook)
   (add-hook language-mode-hook
             (lambda ()
               (add-to-list 'write-file-functions 'delete-trailing-whitespace))))


(use-package company
  (setq company-clang-executable ddavis-clang-exe)
  (add-hook 'emacs-lisp-mode-hook 'company-mode)
  (add-hook 'python-mode-hook 'company-mode)
  (add-hook 'mu4e-compose-mode-hook 'company-mode)
  (add-hook 'sh-mode-hook 'company-mode)
  (add-hook 'LaTeX-mode-hook 'company-mode))


(use-package spaceline :ensure t :hook (after-init . spaceline-helm-mode) :config (require ‘spaceline-config) (spaceline-emacs-theme))

cua selection

(defun ddavis/enable-cua-selection ()
  "turn on cua-selection-mode"
  (cua-selection-mode t))


(use-package elfeed
  :ensure t
  :bind ("C-x w" . 'elfeed)
  (setq elfeed-feeds
  (setq-default elfeed-search-filter "@4-weeks-ago"))


(use-package flymd
  :ensure t
  (require 'flymd)
  (if (eq system-type 'darwin)
      (defun my-flymd-browser-function (url)
        (let ((process-environment (browse-url-process-environment)))
          (apply 'start-process
                 (concat "firefox " url)
                 (list "-a" "firefox" url))))
    (setq flymd-browser-open-function 'my-flymd-browser-function)

    (defun my-flymd-browser-function (url)
      (let ((browse-url-browser-function 'browse-url-firefox))
        (browse-url url)))
    (setq flymd-browser-open-function 'my-flymd-browser-function)))

move lines

(defun ddavis/move-line-up ()
  "Move up the current line."
  (transpose-lines 1)
  (forward-line -2)

(defun ddavis/move-line-down ()
  "Move down the current line."
  (forward-line 1)
  (transpose-lines 1)
  (forward-line -1)

(when (eq system-type 'darwin)
  (global-set-key [(meta shift up)]  'ddavis/move-line-up)
  (global-set-key [(meta shift down)]  'ddavis/move-line-down))


(use-package deadgrep
  :ensure t
  (require 'deadgrep))


(defun eshell-here ()
  "Opens up a new shell in the directory associated with the
        current buffer's file. The eshell is renamed to match that
        directory to make multiple eshell windows easier."
  (let* ((height (/ (window-total-height) 3)))
    (split-window-vertically (- height))
    (other-window 1)
    (eshell "new")
    (insert (concat "ls"))
(bind-key "C-!" 'eshell-here)

(defun eshell/clear ()
  (let ((inhibit-read-only t))

(defun eshell/close ()


(global-set-key (kbd "C-c q") 'auto-fill-mode)


(use-package ace-window
  :ensure t
  (define-key global-map (kbd "M-o") 'ace-window))


You can’t perform that action at this time.