Skip to content
Permalink
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 "grads-18.internal.phy.duke.edu")
  (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 "://melpa.org/packages/")) t)
    (add-to-list 'package-archives (cons "org" (concat proto "://orgmode.org/elpa/")) t)
    (when (< emacs-major-version 24)
      ;; For important compatibility libraries like cl-lib
      (add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/"))))))

(when (string= system-name "grads-18.internal.phy.duke.edu")
  (add-to-list 'package-archives (cons "melpa" "http://melpa.org/packages/") t)
  (add-to-list 'package-archives (cons "org" "http://orgmode.org/elpa/") t))

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

ensure use-package

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

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

(setq use-package-always-ensure t)

auto-update

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

shell

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

startup

(setq custom-file (concat user-emacs-directory "/custom.el"))
(server-start)
(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) "grads-18.internal.phy.duke.edu")
  (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"))

email

initial setup

(defun ddavis/mu4e-machines ()
  (bool-vector (eq system-type 'darwin)
               (string= (system-name) "pion")
               (string= (system-name) "grads-18.internal.phy.duke.edu")
               (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) "grads-18.internal.phy.duke.edu")
    (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))

contexts

(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      . "ddavis@cern.ch" )
                      ( user-email-address     . "ddavis@cern.ch" )
                      ( user-full-name         . "Douglas Davis" )
                      ( mu4e-trash-folder      . "/cern/Trash" )
                      ( mu4e-sent-folder       . "/cern/Sent" )
                      ( mu4e-drafts-folder     . "/cern/Drafts" )
                      ( mu4e-reply-to-address  . "ddavis@cern.ch" )))

           ,(make-mu4e-context
             :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       . "ddavis@phy.duke.edu" )
                      ( user-email-address      . "ddavis@phy.duke.edu" )
                      ( user-full-name          . "Douglas Davis" )
                      ( mu4e-trash-folder       . "/duke/Trash" )
                      ( mu4e-sent-folder        . "/duke/Sent" )
                      ( mu4e-drafts-folder      . "/duke/Drafts" )
                      ( mu4e-reply-to-address   . "ddavis@phy.duke.edu" ))))))

(when (and (or (eq system-type 'darwin) (string= (system-name) "cc7"))  ddavis-use-mu4e)
  (add-to-list 'mu4e-contexts
               (make-mu4e-context
                :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      . "ddavis@ddavis.io" )
                         ( user-email-address     . "ddavis@ddavis.io" )
                         ( user-full-name         . "Doug Davis" )
                         ( mu4e-trash-folder      . "/fastmail/Trash" )
                         ( mu4e-sent-folder       . "/fastmail/Sent" )
                         ( mu4e-drafts-folder     . "/fastmail/Drafts" )
                         ( mu4e-reply-to-address  . "ddavis@ddavis.io" )))))

bookmarks

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

folding

This code is taken from this gist.

   (when ddavis-use-mu4e

     ;; Refactored from https://github.com/djcb/mu/pull/783


     (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."
	 (interactive)
	 (let ((thread-id "") msgs fold-start fold-end)
	   (mu4e-headers-for-each
	    (lambda (msg)
	      (end-of-line)
	      (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)
		   (mu4e-headers-for-each
		    (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))

extras

(when ddavis-use-mu4e
  (setq mu4e-compose-reply-ignore-address
        '("notifications@github\\.com"
          "ddavis@ddavis\\.io"
          "ddavis@phy\\.duke\\.edu"
          "douglas\\.davis@duke\\.edu"
          "ddavis@cern\\.ch")))
(when ddavis-use-mu4e
  (defun ddavis/mu4e-toggle-gnus ()
    (interactive)
    (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."
    (interactive)
    (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)))))

projectile

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

helm

(use-package helm
  :ensure t
  :init
  (setq helm-autoresize-max-height 50)
  (setq helm-autoresize-min-height 30)
  :config
  (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
  :init
  (setq projectile-completion-system 'helm)
  :config
  (require 'helm-projectile)
  (helm-projectile-on)
  (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
  :init
  (setq helm-rg-ripgrep-executable ddavis-rg-exe)
  :config
  (require 'helm-rg)
  (define-key global-map (kbd "C-c s r") 'helm-projectile-rg))

which-key

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

tramp fix

(setq tramp-default-method "ssh")

yasnippet

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

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

iedit

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

theme

(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
  :init
  (setq custom-safe-themes t)
  :config
  (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)

splitting

Not liking this right now so dont use

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

no ring

(setq ring-bell-function 'ignore)

y-or-n-p

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

keystrokes

(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)
  (global-display-line-numbers-mode))
(setq column-number-mode t)

window size

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

parens

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

symlinks

(setq vc-follow-symlinks t)

magit

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

save and lock files

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

fonts

(add-to-list 'default-frame-alist ddavis-font)
(set-face-italic 'font-lock-comment-face nil)
(when (string= (system-name) "grads-18.internal.phy.duke.edu")
  (set-face-attribute 'region nil :background "white" :foreground "dim gray" :inverse-video t))
;; See the following for more details
;;     https://emacs.stackexchange.com/a/50215/8887
;; 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:
;;    https://unix.stackexchange.com/a/363368/13105
(defun ddavis/compare-monospace-font-families ()
  "Display a list of all monospace font faces. Tested on GNU/Linux."
  (interactive)
  (pop-to-buffer "*Monospace Fonts*")
  (erase-buffer)
  (dolist (font-name (seq-filter (lambda (font)
                                   (when-let ((info (font-info font)))
                                     (string-match-p "spacing=100" (aref info 1))))
                                 (font-family-list)))
    (insert
     (propertize
      (concat "1 l; 0 O o [ < = > ] " font-name ")\n")
      'font-lock-face `((:family
                         ,(format "%s" (font-get (font-spec :name font-name) :family))))))))

org

general

(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))
  :init
  (setq org-src-fontify-natively t)
  :config
  (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."
  (interactive)
  (setq org-structure-template-alist
        (delete '("n" "#+BEGIN_NOTES\n?\n#+END_NOTES")
                org-structure-template-alist)))
(add-hook 'org-mode-hook 'ddavis/fix-org-beamer)

babel

(org-babel-do-load-languages
 'org-babel-load-languages
 '((python . t)))

agenda

(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)

spelling

(mapc
 (lambda (language-mode-hook)
   (add-hook language-mode-hook 'flyspell-mode))
 '(org-mode-hook
   LaTeX-mode-hook
   markdown-mode-hook
   mu4e-compose-mode-hook))

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)

c++

general

(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"
  (interactive)
  (use-package eglot
    :ensure t
    :config
    (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)))

python

elpy

(use-package pyvenv
  :ensure t)

(use-package elpy
  :ensure t)

format with black

(use-package blacken
  :ensure t)

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

IDE via eglot

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

lsp

(use-package lsp-mode
  :ensure t
  :commands lsp
  :init
  (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
  :init
  (setq lsp-ui-sideline-show-hover nil))

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

delete trailing white space

(mapc
 (lambda (language-mode-hook)
   (add-hook language-mode-hook
             (lambda ()
               (add-to-list 'write-file-functions 'delete-trailing-whitespace))))
 '(text-mode-hook
   c-mode-common-hook
   python-mode-hook
   markdown-mode-hook
   bash-mode-hook
   cmake-mode-hook
   fundamental-mode-hook
   LaTeX-mode-hook))

company

(use-package company
  :init
  (setq company-clang-executable ddavis-clang-exe)
  :config
  (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))

spaceline

(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"
  (interactive)
  (cua-selection-mode t))

elfeed

(use-package elfeed
  :ensure t
  :bind ("C-x w" . 'elfeed)
  :config
  (setq elfeed-feeds
        '("https://planet.scipy.org/feed.xml"
          "http://sachachua.com/blog/feed/"
          "http://pragmaticemacs.com/feed/"
          "https://ddavis.io/index.xml"))
  ;;"http://planet.emacsen.org/atom.xml"))
  (setq-default elfeed-search-filter "@4-weeks-ago"))

flyit

(use-package flymd
  :ensure t
  :config
  (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)
                 nil
                 "/usr/bin/open"
                 (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."
  (interactive)
  (transpose-lines 1)
  (forward-line -2)
  (indent-according-to-mode))

(defun ddavis/move-line-down ()
  "Move down the current line."
  (interactive)
  (forward-line 1)
  (transpose-lines 1)
  (forward-line -1)
  (indent-according-to-mode))

(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))

deadgrep

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

eshell

(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."
  (interactive)
  (let* ((height (/ (window-total-height) 3)))
    (split-window-vertically (- height))
    (other-window 1)
    (eshell "new")
    (insert (concat "ls"))
    (eshell-send-input)))
(bind-key "C-!" 'eshell-here)

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

(defun eshell/close ()
  (delete-window))

auto-fill

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

ace-window

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

end

You can’t perform that action at this time.