- moom
- telephone-line
- org-download
- spelling stuff
- eyebrowse
- smart-jump
- deadgrep
- rg
- diff-hl
- YCMD maybe for emacs and header file completions
- god mode
- mbsync
- popup-kill-ring
- discover-my-major
- treemacs (treemacs-magit, projectile)
- amx
- mathewZMD
- ivy-omni-org
- ivy-explorer
- ivy-rich
- cloud-theme
- general.el
- focus mode
- multiple cursors again
- ranger /deer
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(setq inhibit-startup-message t)
(tool-bar-mode -1)
(fset 'yes-or-no-p 'y-or-n-p)
(setenv "BROWSER" "firefox")t
(use-package parchment-theme :ensure t)
(use-package cloud-theme :ensure t)
(use-package moe-theme :ensure t)
(use-package zenburn-theme :ensure t)
(use-package monokai-theme :ensure t)
(use-package gruvbox-theme :ensure t)
(use-package ample-theme :ensure t)
(use-package ample-zen-theme :ensure t)
(use-package alect-themes :ensure t)
(use-package tao-theme :ensure t)
(use-package poet-theme :ensure t)
(use-package modus-operandi-theme :ensure t)
(use-package modus-vivendi-theme :ensure t)
(use-package faff-theme :ensure t)
(use-package color-theme-modern :ensure t)
(load-theme 'modus-operandi t)
(use-package doom-modeline
:ensure t)
(doom-modeline-init)
;; expand the marked region in semantic increments
;;(negative prefix to reduce region)
(use-package expand-region
:ensure t
:config
(global-set-key (kbd "C-=") 'er/expand-region))
(setq save-interprogram-paste-before-kill t)
(use-package hungry-delete
:ensure t
:config
(global-hungry-delete-mode))
(global-auto-revert-mode 1) ;; you might not want this
(setq auto-revert-verbose nil) ;; or this
(global-set-key (kbd "<f5>") 'revert-buffer)
(use-package aggressive-indent
:ensure t
:config
;; (global-aggressive-indent-mode 1)
;;(add-to-list 'aggressive-indent-excluded-modes 'html-mode)
)
(use-package ace-window
:ensure t
:config
(setq aw-scope 'frame) ;; was global
(global-set-key (kbd "C-x O") 'other-frame)
(global-set-key [remap other-window] 'ace-window))
(use-package try :ensure t)
(use-package posframe :ensure t)
(use-package iedit
:ensure t)
(use-package which-key
:ensure t
:config
(which-key-mode))
(use-package pcre2el
:ensure t
:config
(pcre-mode)
)
(add-hook 'org-mode-hook 'turn-on-flyspell)
(add-hook 'org-mode-hook 'turn-on-auto-fill)
(add-hook 'mu4e-compose-mode-hook 'turn-on-flyspell)
(add-hook 'mu4e-compose-mode-hook 'turn-on-auto-fill)
;; (use-package hlinum
;; :ensure t
;; :config
;; (hlinum-activate)
;; (global-linum-mode)
;; )
Swiper gives us a really efficient incremental search with regular expressions and Ivy / Counsel replace a lot of ido or helms completion functionality
(use-package counsel
:ensure t
:bind
(("M-y" . counsel-yank-pop)
:map ivy-minibuffer-map
("M-y" . ivy-next-line)))
(use-package ivy
:ensure t
:diminish (ivy-mode)
:bind (("C-x b" . ivy-switch-buffer))
:config
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "%d/%d ")
(setq ivy-display-style 'fancy))
(use-package swiper
:ensure t
:bind (("C-s" . swiper-isearch)
("C-r" . swiper-isearch)
("C-c C-r" . ivy-resume)
("M-x" . counsel-M-x)
("C-x C-f" . counsel-find-file))
:config
(progn
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq ivy-display-style 'fancy)
(define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
))
(global-set-key (kbd "C-x C-b") 'ibuffer)
(setq ibuffer-saved-filter-groups
(quote (("default"
("dired" (mode . dired-mode))
("org" (name . "^.*org$"))
("magit" (mode . magit-mode))
("IRC" (or (mode . circe-channel-mode) (mode . circe-server-mode)))
("web" (or (mode . web-mode) (mode . js2-mode)))
("shell" (or (mode . eshell-mode) (mode . shell-mode)))
("mu4e" (or
(mode . mu4e-compose-mode)
(name . "\*mu4e\*")
))
("programming" (or
(mode . clojure-mode)
(mode . clojurescript-mode)
(mode . python-mode)
(mode . c++-mode)))
("emacs" (or
(name . "^\\*scratch\\*$")
(name . "^\\*Messages\\*$")))
))))
(add-hook 'ibuffer-mode-hook
(lambda ()
(ibuffer-auto-mode 1)
(ibuffer-switch-to-saved-filter-groups "default")))
;; don't show these
;(add-to-list 'ibuffer-never-show-predicates "zowie")
;; Don't show filter groups if there are no buffers in that group
(setq ibuffer-show-empty-filter-groups nil)
;; Don't ask for confirmation to delete marked buffers
(setq ibuffer-expert t)
(use-package flycheck
:ensure t
:init
(global-flycheck-mode t))
(use-package hydra
:ensure t)
(use-package origami
:ensure t)
(defhydra hydra-origami (:color red)
"
_o_pen node _n_ext fold toggle _f_orward
_c_lose node _p_revious fold toggle _a_ll
"
("o" origami-open-node)
("c" origami-close-node)
("n" origami-next-fold)
("p" origami-previous-fold)
("f" origami-forward-toggle-node)
("a" origami-toggle-all-nodes))
(use-package magit
:ensure t
:init
(progn
(setq magit-section-initial-visibility-alist
'((stashes . hide) (untracked . hide) (unpushed . hide)))
(bind-key "C-x g" 'magit-status)
))
(setq magit-status-margin
'(t "%Y-%m-%d %H:%M " magit-log-margin-width t 18))
(use-package git-timemachine
:ensure t
)
(use-package git-gutter-fringe
:ensure t
:config
(global-git-gutter-mode))
(use-package smerge-mode
:after hydra
:config
(defhydra unpackaged/smerge-hydra
(:color pink :hint nil :post (smerge-auto-leave))
"
^Move^ ^Keep^ ^Diff^ ^Other^
^^-----------^^-------------------^^---------------------^^-------
_n_ext _b_ase _<_: upper/base _C_ombine
_p_rev _u_pper _=_: upper/lower _r_esolve
^^ _l_ower _>_: base/lower _k_ill current
^^ _a_ll _R_efine
^^ _RET_: current _E_diff
"
("n" smerge-next)
("p" smerge-prev)
("b" smerge-keep-base)
("u" smerge-keep-upper)
("l" smerge-keep-lower)
("a" smerge-keep-all)
("RET" smerge-keep-current)
("\C-m" smerge-keep-current)
("<" smerge-diff-base-upper)
("=" smerge-diff-upper-lower)
(">" smerge-diff-base-lower)
("R" smerge-refine)
("E" smerge-ediff)
("C" smerge-combine-with-next)
("r" smerge-resolve)
("k" smerge-kill-current)
("ZZ" (lambda ()
(interactive)
(save-buffer)
(bury-buffer))
"Save and bury buffer" :color blue)
("q" nil "cancel" :color blue))
:hook (magit-diff-visit-file . (lambda ()
(when smerge-mode
(unpackaged/smerge-hydra/body)))))
(use-package forge
:ensure t)
(require 'org-protocol)
(custom-set-variables
'(org-directory "~/Sync/orgfiles")
'(org-default-notes-file (concat org-directory "/notes.org"))
'(org-export-html-postamble nil)
'(org-hide-leading-stars t)
'(org-startup-folded (quote overview))
'(org-startup-indented t)
'(org-confirm-babel-evaluate nil)
'(org-src-fontify-natively t)
'(org-export-with-toc nil)
)
(use-package org-bullets
:ensure t
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
(global-set-key "\C-ca" 'org-agenda)
(setq org-agenda-start-on-weekday nil)
(setq org-agenda-custom-commands
'(("c" "Simple agenda view"
((agenda "")
(alltodo "")))))
(global-set-key (kbd "C-c c") 'org-capture)
(setq org-agenda-files (list "~/opt/gcal.org"
"~/opt/soe-cal.org"
"~/Sync/orgfiles/i.org"))
(setq org-capture-templates
'(("l" "Link" entry (file+headline "~/Sync/orgfiles/links.org" "Links")
"* %a %^g\n %?\n %T\n %i")
("b" "Blog idea" entry (file+headline "~/Sync/orgfiles/i.org" "POSTS:")
"* %?\n%T" :prepend t)
("t" "To Do Item" entry (file+headline "~/Sync/orgfiles/i.org" "To Do and Notes")
"* TODO %?\n%u" :prepend t)
("m" "Mail To Do" entry (file+headline "~/Sync/orgfiles/i.org" "To Do and Notes")
"* TODO %a\n %?" :prepend t)
("n" "Note" entry (file+olp "~/Sync/orgfiles/i.org" "Notes")
"* %u %? " :prepend t)
("r" "RSS" entry (file+headline "~/Sync/shared/elfeed.org" "Feeds misc")
"** %A %^g\n")
))
(use-package htmlize :ensure t)
(setq org-ditaa-jar-path "/usr/share/ditaa/ditaa.jar")
(setq org-file-apps
(append '(
("\\.pdf\\'" . "evince %s")
("\\.x?html?\\'" . "/usr/bin/firefox %s")
) org-file-apps ))
;; babel stuff
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)
(emacs-lisp . t)
(shell . t)
(java . t)
(C . t)
(js . t)
(ditaa . t)
(dot . t)
(org . t)
(latex . t )
))
(setq mail-user-agent 'mu4e-user-agent)
(use-package org-msg
:ensure t
:config
(setq org-msg-options "html-postamble:nil H:5 num:nil ^:{} toc:nil tex:dvipng")
(setq org-msg-startup "hidestars indent inlineimages")
(setq org-msg-greeting-fmt "\n%s,\n\n")
(setq org-msg-greeting-fmt-mailto t)
(setq org-msg-signature "
#+begin_signature
-- *Mike* \\\\
#+end_signature")
(org-msg-mode)
)
(require 'ox-reveal)
(require 'org-tempo) ;; to bring back easy templates using <s or <n
(require 'ox-publish)
(setq org-publish-project-alist
'(
("home_page"
:base-directory "~/Sync/hunter/sites/home_page/"
:base-extension "org"
:publishing-directory "/ssh:[email protected]:/var/www/html/home_page/"
:recursive t
:publishing-function org-html-publish-to-html
:headline-levels 4 ; Just the default for this project.
:auto-preamble t
)
("home_static"
:base-directory "~/Sync/hunter/sites/home_page/"
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
:publishing-directory "/ssh:[email protected]:/var/www/html/home_page/"
:recursive t
:publishing-function org-publish-attachment
)
("teacher_ed"
:base-directory "~/Sync/hunter/sites/teacher_ed/"
:base-extension "org"
:publishing-directory "/ssh:[email protected]:/var/www/html/teacher_ed/"
:recursive t
:publishing-function org-html-publish-to-html
:headline-levels 4 ; Just the default for this project.
:auto-preamble t
)
))
(setq org-refile-targets '((nil :maxlevel . 2)))
(use-package smartparens
:ensure t
:config
(require 'smartparens-config)
(add-hook 'minibuffer-setup-hook 'turn-on-smartparens-strict-mode)
;;;;;;;;;;;;;;;;;;;;;;;;
;; keybinding management
(define-key smartparens-mode-map (kbd "C-M-f") 'sp-forward-sexp)
(define-key smartparens-mode-map (kbd "C-M-b") 'sp-backward-sexp)
(define-key smartparens-mode-map (kbd "C-M-d") 'sp-down-sexp)
(define-key smartparens-mode-map (kbd "C-M-a") 'sp-backward-down-sexp)
(define-key smartparens-mode-map (kbd "C-S-d") 'sp-beginning-of-sexp)
(define-key smartparens-mode-map (kbd "C-S-a") 'sp-end-of-sexp)
(define-key smartparens-mode-map (kbd "C-M-e") 'sp-up-sexp)
(define-key smartparens-mode-map (kbd "C-M-u") 'sp-backward-up-sexp)
(define-key smartparens-mode-map (kbd "C-M-t") 'sp-transpose-sexp)
(define-key smartparens-mode-map (kbd "C-M-n") 'sp-forward-hybrid-sexp)
(define-key smartparens-mode-map (kbd "C-M-p") 'sp-backward-hybrid-sexp)
(define-key smartparens-mode-map (kbd "C-M-k") 'sp-kill-sexp)
(define-key smartparens-mode-map (kbd "C-M-w") 'sp-copy-sexp)
(define-key smartparens-mode-map (kbd "M-<delete>") 'sp-unwrap-sexp)
(define-key smartparens-mode-map (kbd "M-<backspace>") 'sp-backward-unwrap-sexp)
(define-key smartparens-mode-map (kbd "C-<right>") 'sp-forward-slurp-sexp)
(define-key smartparens-mode-map (kbd "C-<left>") 'sp-forward-barf-sexp)
(define-key smartparens-mode-map (kbd "C-M-<left>") 'sp-backward-slurp-sexp)
(define-key smartparens-mode-map (kbd "C-M-<right>") 'sp-backward-barf-sexp)
(define-key smartparens-mode-map (kbd "M-D") 'sp-splice-sexp)
(define-key smartparens-mode-map (kbd "C-M-<delete>") 'sp-splice-sexp-killing-forward)
(define-key smartparens-mode-map (kbd "C-M-<backspace>") 'sp-splice-sexp-killing-backward)
(define-key smartparens-mode-map (kbd "C-S-<backspace>") 'sp-splice-sexp-killing-around)
(define-key smartparens-mode-map (kbd "C-]") 'sp-select-next-thing-exchange)
(define-key smartparens-mode-map (kbd "C-<left_bracket>") 'sp-select-previous-thing)
(define-key smartparens-mode-map (kbd "C-M-]") 'sp-select-next-thing)
(define-key smartparens-mode-map (kbd "M-F") 'sp-forward-symbol)
(define-key smartparens-mode-map (kbd "M-B") 'sp-backward-symbol)
(define-key smartparens-mode-map (kbd "C-\"") 'sp-change-inner)
(define-key smartparens-mode-map (kbd "M-i") 'sp-change-enclosing)
(bind-key "C-c f" (lambda () (interactive) (sp-beginning-of-sexp 2)) smartparens-mode-map)
(bind-key "C-c b" (lambda () (interactive) (sp-beginning-of-sexp -2)) smartparens-mode-map)
(bind-key "C-M-s"
(defhydra smartparens-hydra ()
"Smartparens"
("d" sp-down-sexp "Down")
("e" sp-up-sexp "Up")
("u" sp-backward-up-sexp "Up")
("a" sp-backward-down-sexp "Down")
("f" sp-forward-sexp "Forward")
("b" sp-backward-sexp "Backward")
("k" sp-kill-sexp "Kill" :color blue)
("q" nil "Quit" :color blue))
smartparens-mode-map)
(bind-key "H-t" 'sp-prefix-tag-object smartparens-mode-map)
(bind-key "H-p" 'sp-prefix-pair-object smartparens-mode-map)
(bind-key "H-y" 'sp-prefix-symbol-object smartparens-mode-map)
(bind-key "H-h" 'sp-highlight-current-sexp smartparens-mode-map)
(bind-key "H-e" 'sp-prefix-save-excursion smartparens-mode-map)
(bind-key "H-s c" 'sp-convolute-sexp smartparens-mode-map)
(bind-key "H-s a" 'sp-absorb-sexp smartparens-mode-map)
(bind-key "H-s e" 'sp-emit-sexp smartparens-mode-map)
(bind-key "H-s p" 'sp-add-to-previous-sexp smartparens-mode-map)
(bind-key "H-s n" 'sp-add-to-next-sexp smartparens-mode-map)
(bind-key "H-s j" 'sp-join-sexp smartparens-mode-map)
(bind-key "H-s s" 'sp-split-sexp smartparens-mode-map)
(bind-key "H-s r" 'sp-rewrap-sexp smartparens-mode-map)
(defvar hyp-s-x-map)
(define-prefix-command 'hyp-s-x-map)
(bind-key "H-s x" hyp-s-x-map smartparens-mode-map)
(bind-key "H-s x x" 'sp-extract-before-sexp smartparens-mode-map)
(bind-key "H-s x a" 'sp-extract-after-sexp smartparens-mode-map)
(bind-key "H-s x s" 'sp-swap-enclosing-sexp smartparens-mode-map)
(bind-key "C-x C-t" 'sp-transpose-hybrid-sexp smartparens-mode-map)
(bind-key ";" 'sp-comment emacs-lisp-mode-map)
(bind-key [remap c-electric-backspace] 'sp-backward-delete-char smartparens-strict-mode-map)
;;;;;;;;;;;;;;;;;;
;; pair management
(sp-local-pair 'minibuffer-inactive-mode "'" nil :actions nil)
(bind-key "C-(" 'sp---wrap-with-40 minibuffer-local-map)
(sp-with-modes 'org-mode
(sp-local-pair "=" "=" :wrap "C-="))
(sp-with-modes 'textile-mode
(sp-local-pair "*" "*")
(sp-local-pair "_" "_")
(sp-local-pair "@" "@"))
(sp-with-modes 'web-mode
(sp-local-pair "{{#if" "{{/if")
(sp-local-pair "{{#unless" "{{/unless"))
;;; tex-mode latex-mode
(sp-with-modes '(tex-mode plain-tex-mode latex-mode)
(sp-local-tag "i" "\"<" "\">"))
;;; lisp modes
(sp-with-modes sp--lisp-modes
(sp-local-pair "(" nil
:wrap "C-("
:pre-handlers '(my-add-space-before-sexp-insertion)
:post-handlers '(my-add-space-after-sexp-insertion)))
(defun my-add-space-after-sexp-insertion (id action _context)
(when (eq action 'insert)
(save-excursion
(forward-char (sp-get-pair id :cl-l))
(when (or (eq (char-syntax (following-char)) ?w)
(looking-at (sp--get-opening-regexp)))
(insert " ")))))
(defun my-add-space-before-sexp-insertion (id action _context)
(when (eq action 'insert)
(save-excursion
(backward-char (length id))
(when (or (eq (char-syntax (preceding-char)) ?w)
(and (looking-back (sp--get-closing-regexp))
(not (eq (char-syntax (preceding-char)) ?'))))
(insert " ")))))
;;; C++
(sp-with-modes '(malabar-mode c++-mode)
(sp-local-pair "{" nil :post-handlers '(("||\n[i]" "RET"))))
(sp-local-pair 'c++-mode "/*" "*/" :post-handlers '((" | " "SPC")
("* ||\n[i]" "RET")))
(setq-default sp-escape-quotes-after-insert nil)
(sp-local-pair 'js2-mode "/**" "*/" :post-handlers '(("| " "SPC")
("* ||\n[i]" "RET")))
(smartparens-global-mode)
)
(use-package rainbow-delimiters
:ensure t
:config
(add-hook 'clojure-mode-hook #'rainbow-delimiters-mode)
)
(show-paren-mode t)
(defun load-if-exists (f)
"load the elisp file only if it exists and is readable"
(if (file-readable-p f)
(load-file f)))
(load-if-exists "~/Sync/shared/mu4econfig.el")
(load-if-exists "~/Sync/shared/not-for-github.el")
(use-package yasnippet
:ensure t
:init
(yas-global-mode 1))
(use-package yasnippet-snippets
:ensure t)
(use-package yasnippet-classic-snippets
:ensure t)
(use-package lsp-mode
:ensure t
:commands lsp
:custom
(lsp-auto-guess-root nil)
(lsp-prefer-flymake nil) ; Use flycheck instead of flymake
:bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer))
:hook ((python-mode) . lsp))
(use-package lsp-ui
:after lsp-mode
:diminish
:commands lsp-ui-mode
:custom-face
(lsp-ui-doc-background ((t (:background nil))))
(lsp-ui-doc-header ((t (:inherit (font-lock-string-face italic)))))
:bind (:map lsp-ui-mode-map
([remap xref-find-definitions] . lsp-ui-peek-find-definitions)
([remap xref-find-references] . lsp-ui-peek-find-references)
("C-c u" . lsp-ui-imenu))
:custom
(lsp-ui-doc-enable t)
(lsp-ui-doc-header t)
(lsp-ui-doc-include-signature t)
(lsp-ui-doc-position 'top)
(lsp-ui-doc-border (face-foreground 'default))
(lsp-ui-sideline-enable nil)
(lsp-ui-sideline-ignore-duplicate t)
(lsp-ui-sideline-show-code-actions nil)
:config
;; Use lsp-ui-doc-webkit only in GUI
(setq lsp-ui-doc-use-webkit t)
;; WORKAROUND Hide mode-line of the lsp-ui-imenu buffer
;; https://github.com/emacs-lsp/lsp-ui/issues/243
(defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
(setq mode-line-format nil)))
(use-package projectile
:ensure t
:bind (:map projectile-mode-map
("s-p" . 'projectile-command-map)
("C-c p" . 'projectile-command-map)
)
:config
(setq projectile-completion-system 'ivy)
(projectile-mode +1))
(use-package ibuffer-projectile
:ensure t
:config
(add-hook 'ibuffer-hook
(lambda ()
(ibuffer-projectile-set-filter-groups)
(unless (eq ibuffer-sorting-mode 'alphabetic)
(ibuffer-do-sort-by-alphabetic))))
)
(use-package company
:ensure t
:config
(setq company-idle-delay 0)
(setq company-minimum-prefix-length 3)
(global-company-mode t)
)
(use-package company-lsp
:ensure t
:config
(setq compnay-lsp-enable-snippet t)
(push 'company-lsp company-backends)
)
(use-package virtualenvwrapper
:ensure t
:config
(venv-initialize-interactive-shells)
(venv-initialize-eshell))
(venv-workon "p3")
(setq lsp-python-executable-cmd "python3")
(use-package jedi
:ensure t
:init
(add-hook 'python-mode-hook 'jedi:setup)
(add-hook 'python-mode-hook 'jedi:ac-setup))
(setq python-shell-interpreter "python3"
python-shell-interpreter-args "-i")
(use-package company-irony
:ensure t
:config
(add-to-list 'company-backends 'company-irony)
)
(use-package irony
:ensure t
:config
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
)
(use-package irony-eldoc
:ensure t
:config
(add-hook 'irony-mode-hook #'irony-eldoc))
;;(setq lsp-clangd-executable "clangd-6.0")
;;(setq lsp-clients-clangd-executable "clangd-6.0")
(use-package cider
:ensure t
:config
(add-hook 'cider-repl-mode-hook #'company-mode)
(add-hook 'cider-mode-hook #'company-mode)
(add-hook 'cider-mode-hook #'eldoc-mode)
;; (add-hook 'cider-mode-hook #'cider-hydra-mode)
(setq cider-repl-use-pretty-printing t)
(setq cider-repl-display-help-banner nil)
;; (setq cider-cljs-lein-repl "(do (use 'figwheel-sidecar.repl-api) (start-figwheel!) (cljs-repl))")
:bind (("M-r" . cider-namespace-refresh)
("C-c r" . cider-repl-reset)
("C-c ." . cider-reset-test-run-tests))
)
(use-package dumb-jump
:bind (("M-g o" . dumb-jump-go-other-window)
("M-g j" . dumb-jump-go)
("M-g x" . dumb-jump-go-prefer-external)
("M-g z" . dumb-jump-go-prefer-external-other-window))
:config
;; (setq dumb-jump-selector 'ivy) ;; (setq dumb-jump-selector 'helm)
:init
(dumb-jump-mode)
:ensure
)
(use-package origami
:ensure t)
(use-package grip-mode
:ensure t)
;; font scaling
(use-package default-text-scale
:ensure t
:config
(global-set-key (kbd "C-M-=") 'default-text-scale-increase)
(global-set-key (kbd "C-M--") 'default-text-scale-decrease))
;; narrow/widen dwim
; if you're windened, narrow to the region, if you're narrowed, widen
; bound to C-x n
(defun narrow-or-widen-dwim (p)
"If the buffer is narrowed, it widens. Otherwise, it narrows intelligently.
Intelligently means: region, org-src-block, org-subtree, or defun,
whichever applies first.
Narrowing to org-src-block actually calls `org-edit-src-code'.
With prefix P, don't widen, just narrow even if buffer is already
narrowed."
(interactive "P")
(declare (interactive-only))
(cond ((and (buffer-narrowed-p) (not p)) (widen))
((region-active-p)
(narrow-to-region (region-beginning) (region-end)))
((derived-mode-p 'org-mode)
;; `org-edit-src-code' is not a real narrowing command.
;; Remove this first conditional if you don't want it.
(cond ((ignore-errors (org-edit-src-code))
(delete-other-windows))
((org-at-block-p)
(org-narrow-to-block))
(t (org-narrow-to-subtree))))
(t (narrow-to-defun))))
;; (define-key endless/toggle-map "n" #'narrow-or-widen-dwim)
;; This line actually replaces Emacs' entire narrowing keymap, that's
;; how much I like this command. Only copy it if that's what you want.
(define-key ctl-x-map "n" #'narrow-or-widen-dwim)
(use-package restclient
:ensure t)
(use-package company-restclient
:ensure t
:config
(add-to-list 'company-backends 'company-restclient))
(use-package multiple-cursors
:ensure t
)
(defhydra hydra-multiple-cursors (:hint nil)
"
Up^^ Down^^ Miscellaneous % 2(mc/num-cursors) cursor%s(if (> (mc/num-cursors) 1) \"s\" \"\")
------------------------------------------------------------------
[_p_] Next [_n_] Next [_l_] Edit lines [_0_] Insert numbers
[_P_] Skip [_N_] Skip [_a_] Mark all [_A_] Insert letters
[_M-p_] Unmark [_M-n_] Unmark [_s_] Search
[Click] Cursor at point [_q_] Quit"
("l" mc/edit-lines :exit t)
("a" mc/mark-all-like-this :exit t)
("n" mc/mark-next-like-this)
("N" mc/skip-to-next-like-this)
("M-n" mc/unmark-next-like-this)
("p" mc/mark-previous-like-this)
("P" mc/skip-to-previous-like-this)
("M-p" mc/unmark-previous-like-this)
("s" mc/mark-all-in-region-regexp :exit t)
("0" mc/insert-numbers :exit t)
("A" mc/insert-letters :exit t)
("<mouse-1>" mc/add-cursor-on-click)
;; Help with click recognition in this hydra
("<down-mouse-1>" ignore)
("<drag-mouse-1>" ignore)
("q" nil))
(use-package focus
:ensure t
)
(use-package ivy-rich
:ensure t
:config
(ivy-rich-mode 1)
)
(use-package exec-path-from-shell
:ensure t
:config
(exec-path-from-shell-initialize))
(use-package fish-completion
:ensure t
:config
(global-fish-completion-mode))
;; (use-package eshell-prompt-extras
;; :ensure t
;; :config
;; (setq epe-show-python-info nil)
;; )
(use-package eshell-git-prompt
:ensure t
:config
(eshell-git-prompt-use-theme 'git-radar)
)
(setq scroll-step 1)
(require 'cl-lib)
(defun select-or-create (arg)
"Commentary ARG."
(if (string= arg "New eshell")
(eshell t)
(switch-to-buffer arg)))
(defun eshell-switcher (&optional arg)
"Commentary ARG."
(interactive)
(let* (
(buffers (cl-remove-if-not (lambda (n) (eq (buffer-local-value 'major-mode n) 'eshell-mode)) (buffer-list)) )
(names (mapcar (lambda (n) (buffer-name n)) buffers))
(num-buffers (length buffers) )
(in-eshellp (eq major-mode 'eshell-mode)))
(cond ((eq num-buffers 0) (eshell (or arg t)))
((not in-eshellp) (switch-to-buffer (car buffers)))
(t (select-or-create (completing-read "Select Shell:" (cons "New eshell" names)))))))
(defun eshell/in-term (prog &rest args)
"Run shell command in term buffer."
(switch-to-buffer (apply #'make-term prog prog nil args))
(term-mode)
(term-char-mode))
;; unset C- and M- digit keys
;(dotimes (n 10)
; (global-unset-key (kbd (format C-%d"" n)))
; (global-unset-key (kbd (format "M-%d" n)))
; )
(defun org-agenda-show-agenda-and-todo (&optional arg)
(interactive "P")
(org-agenda arg "c")
(org-agenda-fortnight-view))
(defun z/load-iorg ()
(interactive )
(find-file "~/Sync/orgfiles/i.org"))
;; set up my own map
(define-prefix-command 'z-map)
(global-set-key (kbd "C-z") 'z-map) ;; was C-1
(define-key z-map (kbd "k") 'compile)
(define-key z-map (kbd "c") 'hydra-multiple-cursors/body)
(define-key z-map (kbd "f") 'hydra-origami/body)
(define-key z-map (kbd "m") 'mu4e)
(define-key z-map (kbd "1") 'org-global-cycle)
(define-key z-map (kbd "a") 'org-agenda-show-agenda-and-todo)
(define-key z-map (kbd "g") 'counsel-ag)
(define-key z-map (kbd "2") 'make-frame-command)
(define-key z-map (kbd "0") 'delete-frame)
(define-key z-map (kbd "o") 'other-frame)
(define-key z-map (kbd "s") 'flyspell-correct-word-before-point)
(define-key z-map (kbd "i") 'z/load-iorg)
(define-key z-map (kbd "*") 'calc)
(define-key z-map (kbd "e") 'eshell-switcher)
(setq user-full-name "Mike Zamansky"
user-mail-address "[email protected]")
;;--------------------------------------------------------------------------
(global-set-key (kbd "\e\ei")
(lambda () (interactive) (find-file "~/Sync/orgfiles/i.org")))
(global-set-key (kbd "\e\el")
(lambda () (interactive) (find-file "~/Sync/orgfiles/links.org")))
(global-set-key (kbd "\e\ec")
(lambda () (interactive) (find-file "~/.emacs.d/README.org")))
(global-set-key (kbd "<end>") 'move-end-of-line)
(global-set-key [mouse-3] 'flyspell-correct-word-before-point)
(setq elfeed-db-directory "~/Sync/shared/elfeeddb")
(defun mz/elfeed-browse-url (&optional use-generic-p)
"Visit the current entry in your browser using `browse-url'.
If there is a prefix argument, visit the current entry in the
browser defined by `browse-url-generic-program'."
(interactive "P")
(let ((entries (elfeed-search-selected)))
(cl-loop for entry in entries
do (if use-generic-p
(browse-url-generic (elfeed-entry-link entry))
(browse-url (elfeed-entry-link entry))))
(mapc #'elfeed-search-update-entry entries)
(unless (or elfeed-search-remain-on-entry (use-region-p))
;;(forward-line)
)))
(defun elfeed-mark-all-as-read ()
(interactive)
(mark-whole-buffer)
(elfeed-search-untag-all-unread))
;;functions to support syncing .elfeed between machines
;;makes sure elfeed reads index from disk before launching
(defun bjm/elfeed-load-db-and-open ()
"Wrapper to load the elfeed db from disk before opening"
(interactive)
(elfeed-db-load)
(elfeed)
(elfeed-search-update--force))
;;write to disk when quiting
(defun bjm/elfeed-save-db-and-bury ()
"Wrapper to save the elfeed db to disk before burying buffer"
(interactive)
(elfeed-db-save)
(quit-window))
(use-package elfeed
:ensure t
:bind (:map elfeed-search-mode-map
("q" . bjm/elfeed-save-db-and-bury)
("Q" . bjm/elfeed-save-db-and-bury)
("m" . elfeed-toggle-star)
("M" . elfeed-toggle-star)
("j" . mz/make-and-run-elfeed-hydra)
("J" . mz/make-and-run-elfeed-hydra)
("b" . mz/elfeed-browse-url)
("B" . elfeed-search-browse-url)
)
:config
(defalias 'elfeed-toggle-star
(elfeed-expose #'elfeed-search-toggle-all 'star))
)
(use-package elfeed-goodies
:ensure t
:config
(elfeed-goodies/setup))
(use-package elfeed-org
:ensure t
:config
(elfeed-org)
(setq rmh-elfeed-org-files (list "~/Sync/shared/elfeed.org")))
(defun z/hasCap (s) ""
(let ((case-fold-search nil))
(string-match-p "[[:upper:]]" s)
))
(defun z/get-hydra-option-key (s)
"returns single upper case letter (converted to lower) or first"
(interactive)
(let ( (loc (z/hasCap s)))
(if loc
(downcase (substring s loc (+ loc 1)))
(substring s 0 1)
)))
;; (active blogs cs eDucation emacs local misc sports star tech unread webcomics)
(defun mz/make-elfeed-cats (tags)
"Returns a list of lists. Each one is line for the hydra configuratio in the form
(c function hint)"
(interactive)
(mapcar (lambda (tag)
(let* (
(tagstring (symbol-name tag))
(c (z/get-hydra-option-key tagstring))
)
(list c (append '(elfeed-search-set-filter) (list (format "@6-months-ago +%s" tagstring) ))tagstring )))
tags))
(defmacro mz/make-elfeed-hydra ()
`(defhydra mz/hydra-elfeed ()
"filter"
,@(mz/make-elfeed-cats (elfeed-db-get-all-tags))
("*" (elfeed-search-set-filter "@6-months-ago +star") "Starred")
("M" elfeed-toggle-star "Mark")
("A" (elfeed-search-set-filter "@6-months-ago") "All")
("T" (elfeed-search-set-filter "@1-day-ago") "Today")
("Q" bjm/elfeed-save-db-and-bury "Quit Elfeed" :color blue)
("q" nil "quit" :color blue)
))
(defun mz/make-and-run-elfeed-hydra ()
""
(interactive)
(mz/make-elfeed-hydra)
(mz/hydra-elfeed/body))
(defun my-elfeed-tag-sort (a b)
(let* ((a-tags (format "%s" (elfeed-entry-tags a)))
(b-tags (format "%s" (elfeed-entry-tags b))))
(if (string= a-tags b-tags)
(< (elfeed-entry-date b) (elfeed-entry-date a)))
(string< a-tags b-tags)))
(setf elfeed-search-sort-function #'my-elfeed-tag-sort)
(use-package nameframe
:ensure t)
(use-package nameframe-projectile
:ensure t
:config
(nameframe-projectile-mode t)
)
(use-package diredfl
:ensure t
:config
(diredfl-global-mode 1))
(setq
dired-listing-switches "-lXGh --group-directories-first"
dired-dwim-target t)
(add-hook 'dired-mode-hook 'dired-hide-details-mode)
(use-package dired-recent
:ensure t
:config
(dired-recent-mode 1)
)
(defun my-dired-recent-dirs ()
"Present a list of recently used directories and open the selected one in dired"
(interactive)
(let ((dir (ivy-read "Directory: "
dired-recent-directories
:re-builder #'ivy--regex
:sort nil
:initial-input nil)))
(dired dir)))
(use-package floobits :ensure t)
(use-package rg
:ensure t
:config
(rg-enable-default-bindings))
;;(rg-enable-menu))
(use-package perspective
:ensure t
:config
(persp-mode))
(use-package keypression :ensure t)
(defun xah-open-in-external-app (&optional @fname)
"Open the current file or dired marked files in external app.
The app is chosen from your OS's preference.
When called in emacs lisp, if @fname is given, open that.
URL `http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html'
Version 2019-11-04"
(interactive)
(let* (
($file-list
(if @fname
(progn (list @fname))
(if (string-equal major-mode "dired-mode")
(dired-get-marked-files)
(list (buffer-file-name)))))
($do-it-p (if (<= (length $file-list) 5)
t
(y-or-n-p "Open more than 5 files? "))))
(when $do-it-p
(cond
((string-equal system-type "windows-nt")
(mapc
(lambda ($fpath)
(w32-shell-execute "open" $fpath)) $file-list))
((string-equal system-type "darwin")
(mapc
(lambda ($fpath)
(shell-command
(concat "open " (shell-quote-argument $fpath)))) $file-list))
((string-equal system-type "gnu/linux")
(mapc
(lambda ($fpath) (let ((process-connection-type nil))
(start-process "" nil "xdg-open" $fpath))) $file-list))))))
(define-key dired-mode-map (kbd "C-<return>") 'xah-open-in-external-app)