merge develop

This commit is contained in:
Patrick Elliott 2018-07-18 09:17:50 +02:00
commit 4b435f880b
30 changed files with 210 additions and 133 deletions

1
.gitignore vendored
View file

@ -1,5 +1,4 @@
.local/
.cask/
var/
modules/private/
.yas-compiled-snippets.el

View file

@ -1,4 +1,4 @@
DOOM = bin/doom
DOOM = "bin/doom"
MODULES = $(patsubst modules/%/, %, $(sort $(dir $(wildcard modules/*/ modules/*/*/))))
all:

View file

@ -1,13 +1,24 @@
:: Forward the ./doom script to Emacs
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
PUSHD "%~dp0" >NUL
IF %1=="run" (
SHIFT
emacs -Q %* -l init.el -f "doom|run-all-startup-hooks"
SET args=
SET command=%1
:LOOP
SHIFT /1
IF NOT [%1]==[] (
SET args=%args% %1
GOTO :LOOP
)
IF [%command%]==[run] (
start runemacs -Q %args% -l ..\init.el -f "doom|run-all-startup-hooks"
) ELSE (
emacs --quick --script ./doom -- %*
emacs --quick --script .\doom -- %*
)
POPD >NUL

View file

@ -40,10 +40,12 @@ ready to be pasted in a bug report on github."
,doom-core-dir
,doom-private-dir)
:type 'files :match "\\.elc$"))
(if IS-WINDOWS
"n/a"
(with-temp-buffer
(unless (zerop (call-process "uname" nil t nil "-a"))
(insert (format "%s" system-type)))
(string-trim (buffer-string)))
(string-trim (buffer-string))))
(or (cl-loop with cat = nil
for key being the hash-keys of (doom-modules)
if (or (not cat) (not (eq cat (car key))))
@ -120,6 +122,20 @@ branch and commit."
(or (vc-git-working-revision doom-core-dir)
"n/a")))
;;;###autoload
(defun doom/copy-backtrace ()
"Copy the first 1000 bytes from the *Backtrace* window into your clipboard for
easy pasting into a bug report or discord."
(interactive)
(if-let* ((buf (get-buffer "*Backtrace*")))
(with-current-buffer buf
(kill-new
(string-trim
(buffer-substring-no-properties
(point-min)
(min (point-max) 1000)))))
(user-error "No backtrace buffer detected")))
;;
;; Vanilla sandbox

View file

@ -27,7 +27,7 @@
;;
;;; License: MIT
(unless (boundp 'early-init-file)
(unless (bound-and-true-p early-init-file)
(load (concat (file-name-directory load-file-name) "early-init")
nil t))

View file

@ -248,10 +248,8 @@ order.
(t
(file-relative-name directory project-root))))))
(require 'counsel)
(cl-letf (((symbol-function 'counsel-ag-function)
(symbol-function '+ivy*counsel-ag-function))
((symbol-function 'counsel-git-grep-function)
(symbol-function '+ivy*counsel-git-grep-function)))
(let ((counsel-more-chars-alist
(if query '((t . 1)) counsel-more-chars-alist)))
(pcase engine
('grep
(let ((args (if recursive " -R"))
@ -363,41 +361,3 @@ non-nil)."
non-nil)."
(interactive "P")
(+ivy-file-search 'grep :query query :in default-directory :recursive recursive-p))
;;
;; Advice
;;
;;;###autoload
(defun +ivy*counsel-ag-function (string)
"Advice to get rid of the character limit from `counsel-ag-function'.
NOTE This may need to be updated frequently, to meet changes upstream (in
counsel-rg)."
(if (< (length string) 1) ; <-- modified the character limit
(counsel-more-chars 1) ; <--
(let ((default-directory (ivy-state-directory ivy-last))
(regex (counsel-unquote-regex-parens
(setq ivy--old-re
(ivy--regex string)))))
(counsel--async-command (format counsel-ag-command
(shell-quote-argument regex)))
nil)))
;;;###autoload
(defun +ivy*counsel-git-grep-function (string)
"Advice to get rid of the character limit from `counsel-git-grep-function'.
NOTE This may need to be updated frequently, to meet changes upstream (in
counsel-git-grep)."
(if (and (> counsel--git-grep-count counsel--git-grep-count-threshold)
(< (length string) 1)) ; <-- modified the character limit
(counsel-more-chars 1) ; <--
(let* ((default-directory (ivy-state-directory ivy-last))
(cmd (format counsel-git-grep-cmd
(setq ivy--old-re (ivy--regex string t)))))
(if (<= counsel--git-grep-count counsel--git-grep-count-threshold)
(split-string (shell-command-to-string cmd) "\n" t)
(counsel--gg-candidates (ivy--regex string))
nil))))

View file

@ -197,7 +197,7 @@ immediately runs it on the current candidate (ending the ivy session)."
;; posframe doesn't work well with async sources
(dolist (fn '(swiper counsel-rg counsel-ag counsel-pt counsel-grep counsel-git-grep))
(setf (alist-get fn ivy-display-functions-alist) nil)))
(setf (alist-get fn ivy-display-functions-alist) #'ivy-display-function-fallback)))
(def-package! flx

View file

@ -170,12 +170,14 @@
"a" (evilem-create #'evil-forward-arg)
"A" (evilem-create #'evil-backward-arg)
"s" (evilem-create #'evil-snipe-repeat
:name 'evil-easymotion-snipe-forward
:pre-hook (save-excursion (call-interactively #'evil-snipe-s))
:bind ((evil-snipe-scope 'buffer)
(evil-snipe-enable-highlight)
(evil-snipe-enable-incremental-highlight)))
"S" (evilem-create #'evil-snipe-repeat-reverse
:pre-hook (save-excursion (call-interactively #'evil-snipe-s))
"S" (evilem-create #'evil-snipe-repeat
:name 'evil-easymotion-snipe-backward
:pre-hook (save-excursion (call-interactively #'evil-snipe-S))
:bind ((evil-snipe-scope 'buffer)
(evil-snipe-enable-highlight)
(evil-snipe-enable-incremental-highlight)))
@ -838,5 +840,5 @@
;; Evil-collection fixes
(setq evil-collection-key-blacklist
(list "C-j" "C-k" "gd" "gf" "K" "[" "]"
(list "C-j" "C-k" "gd" "gf" "K" "[" "]" "gz"
doom-leader-key doom-localleader-key))

View file

@ -111,7 +111,8 @@ command from the current directory instead of the project root."
(ex! "grep" #'+helm:grep)
(ex! "grepc[wd]" #'+helm:grep-from-cwd)
(ex! "sw[oop]" #'+helm:swoop)
(ex! "todo" #'+helm:todo)))
;; (ex! "todo" #'+helm:todo) TODO implement `+helm:todo'
))
;; Project tools
(ex! "mak[e]" #'doom:make)
(ex! "debug" #'+debug/run)
@ -135,5 +136,5 @@ command from the current directory instead of the project root."
(ex! "tabs" #'+workspace/display)
(ex! "tabsave" #'+workspace:save)
;; Org-mode
(ex! "cap" #'+org-capture/dwim)
(ex! "cap" #'org-capture)

View file

@ -8,5 +8,4 @@
(after! term
(set-env! "SHELL")
;; Consider term buffers real
(add-hook 'term-mode-hook #'doom|mark-buffer-as-real))

View file

@ -18,7 +18,11 @@
(funcall (if same-window-p #'switch-to-buffer #'pop-to-buffer)
(if (buffer-live-p buffer)
buffer
(setq buffer (save-window-excursion (call-interactively command)))
(setq buffer
(save-window-excursion
(if (commandp command)
(call-interactively command)
(funcall command))))
(unless (bufferp buffer)
(error "REPL command didn't return a buffer"))
(with-current-buffer buffer (+eval-repl-mode +1))

View file

@ -9,10 +9,11 @@
`+eval/open-repl' and filled with the `:repl' setting.")
;;;###autodef
(defun set-repl-handler! (mode command)
"Define a REPL for a mode. MODE is a major mode symbol and COMMAND is a
function that creates and returns the REPL buffer."
(push (cons mode command) +eval-repls))
(defun set-repl-handler! (modes command)
"Define a REPL for MODES. MODES is either a single major mode symbol or a list
of them. COMMAND is a function that creates and returns the REPL buffer."
(dolist (mode (doom-enlist modes))
(setf (alist-get mode +eval-repls) command)))
;; FIXME obsolete :repl
;;;###autoload

View file

@ -50,16 +50,24 @@ cursor at the final match. If BANG, then treat PATTERN as literal."
:move-point nil
:evil-mc t
(interactive "<R><//g><!>")
(unless (and (stringp pattern)
(not (string-empty-p pattern)))
(user-error "A regexp pattern is required"))
(require 'evil-mc)
(setq evil-mc-pattern (cons (evil-mc-make-pattern (if bang (regexp-quote pattern) pattern) nil)
(setq evil-mc-pattern
(cons (evil-ex-make-search-pattern
(if bang (regexp-quote pattern) pattern))
(list beg end type)))
(save-excursion
(evil-with-restriction beg end
(evil-mc-make-cursors-for-all)
(evil-mc-print-cursors-info "Created")))
(evil-mc-make-cursors-for-all)))
(evil-exit-visual-state)
(evil-mc-goto-cursor
(if (= (evil-visual-direction) 1)
(evil-mc-find-last-cursor)
(evil-mc-find-first-cursor))
nil))
nil)
(evil-mc-undo-cursor-at-pos (point))
(if (evil-mc-has-cursors-p)
(evil-mc-print-cursors-info "Created")
(evil-mc-message "No cursors were created")))

View file

@ -18,9 +18,13 @@ these properties:
Provides a secondary predicate. This function takes no arguments and is
executed from within the target buffer. If it returns nil, this rule will be
skipped over.
:trigger
The yasnippet trigger keyword used to trigger the target snippet. If
omitted, `+file-templates-default-trigger' is used.
:trigger STRING|FUNCTION
If a string, this is the yasnippet trigger keyword used to trigger the
target snippet.
If a function, this function will be run in the context of the buffer to
insert a file template into. It is given no arguments and must insert text
into the current buffer manually.
If omitted, `+file-templates-default-trigger' is used.
:mode SYMBOL
What mode to get the yasnippet snippet from. If omitted, either PRED (if
it's a major-mode symbol) or the mode of the buffer is used.
@ -69,6 +73,8 @@ evil is loaded and enabled)."
(user-error "Couldn't determine mode for %s file template" pred))
(unless trigger
(setq trigger +file-templates-default-trigger))
(if (functionp trigger)
(funcall trigger)
(require 'yasnippet)
(unless yas-minor-mode
(yas-minor-mode-on))
@ -81,7 +87,7 @@ evil is loaded and enabled)."
(and yas--active-field-overlay
(overlay-buffer yas--active-field-overlay)
(overlay-get yas--active-field-overlay 'yas--field)))
(evil-initialize-state 'insert)))))
(evil-initialize-state 'insert))))))
;;;###autoload
(defun +file-templates-get-short-path ()

View file

@ -37,7 +37,7 @@ don't have a :trigger property in `+file-templates-alist'.")
("\\.c\\(?:c\\|pp\\)$" :trigger "__cpp" :mode c++-mode)
("\\.h\\(?:h\\|pp\\|xx\\)$" :trigger "__hpp" :mode c++-mode)
("\\.h$" :trigger "__h" :mode c-mode)
(c-mode :trigger "__c" :mode c-mode)
(c-mode :trigger "__c")
;; go
("/main\\.go$" :trigger "__main.go" :mode go-mode :project t)
(go-mode :trigger "__.go")

View file

@ -5,5 +5,4 @@
:hook (haskell-mode . dante-mode)
:config
(when (featurep! :feature syntax-checker)
(add-hook! 'dante-mode-hook
(flycheck-add-next-checker 'haskell-dante '(warning . haskell-hlint)))))
(flycheck-add-next-checker 'haskell-dante '(warning . haskell-hlint))))

View file

@ -13,4 +13,6 @@ This is necessary because `intero-mode' doesn't do its own error checks."
(message "Couldn't find stack. Refusing to enable intero-mode."))))
(add-hook 'haskell-mode-hook #'+haskell|init-intero)
:config
(set-lookup-handlers! 'intero-mode :definition #'intero-goto-definition))
(set-lookup-handlers! 'intero-mode :definition #'intero-goto-definition)
(when (featurep! :feature syntax-checker)
(flycheck-add-next-checker 'intero '(warning . haskell-hlint))))

View file

@ -0,0 +1,15 @@
;;; lang/haskell/autoload.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +haskell-repl-buffer ()
"Returns the appropriate Haskell REPL buffer."
(if (featurep! +intero)
(intero-repl-buffer arg)
(haskell-session-interactive-buffer (haskell-session))))
;;;###autoload
(defun +haskell/repl (&optional arg)
"Opens a Haskell REPL."
(interactive "P")
(display-buffer (+haskell-repl-buffer)))

View file

@ -11,6 +11,9 @@
:hook (haskell-mode . hindent-mode))
(after! haskell-mode
(set-repl-handler! 'haskell-mode #'switch-to-haskell)
(add-hook 'haskell-mode-hook #'interactive-haskell-mode)
(set-lookup-handlers! 'haskell-mode :definition #'haskell-mode-jump-to-def-or-tag)
(set-file-template! 'haskell-mode :trigger #'haskell-auto-insert-module-template :project t)
(set-repl-handler! '(haskell-mode haskell-cabal-mode literate-haskell-mode) #'+haskell-repl-buffer)
(add-to-list 'completion-ignored-extensions ".hi"))

View file

@ -3,9 +3,7 @@
(when (featurep! +dante)
(unless (executable-find "cabal")
(warn! "Couldn't find cabal, haskell-mode may have issues"))
(unless (executable-find "hlint")
(warn! "Couldn't find hlint. Flycheck may have issues in haskell-mode")))
(warn! "Couldn't find cabal, haskell-mode may have issues")))
(when (featurep! +intero)
(unless (executable-find "stack")
@ -14,3 +12,8 @@
(unless (executable-find "hindent")
(warn! "Couldn't find hindent. hindent-mode won't work"))
(when (or (featurep! +dante) (featurep! +intero))
(unless (executable-find "hlint")
(warn! "Couldn't find hlint. Flycheck may have issues in haskell-mode")))

View file

@ -0,0 +1,21 @@
;;; lang/nix/config.el -*- lexical-binding: t; -*-
(after! nix-mode
(set-company-backend! 'nix-mode 'company-nixos-options)
(map! :map nix-mode-map
:localleader
:n "f" #'nix-update-fetch
:n "p" #'nix-format-buffer
:n "r" #'nix-repl-show
:n "s" #'nix-shell
:n "b" #'nix-build
:n "u" #'nix-unpack
(:when (featurep! :completion helm)
:n "o" #'helm-nixos-options)))
(def-package! nix-update
:commands (nix-update-fetch))
(def-package! nix-repl
:commands (nix-repl-show))

View file

@ -0,0 +1,9 @@
;; -*- lexical-binding: t; no-byte-compile: t; -*-
;;; lang/nix/doctor.el
(unless (executable-find "nix")
(warn! "Couldn't find the nix package manager. nix-mode won't work."))
(unless (executable-find "nixfmt")
(warn! "Couldn't find nixfmt. nix-format-buffer won't work."))

View file

@ -2,3 +2,11 @@
;;; lang/nix/packages.el
(package! nix-mode)
(package! nix-update)
(when (featurep! :completion company)
(package! company-nixos-options))
(when (featurep! :completion helm)
(package! helm-nixos-options))

View file

@ -18,7 +18,8 @@ path too.")
(add-to-list 'org-export-backends 'pandoc nil #'eq)
(setq org-pandoc-options
'((standalone . t)
(mathjax . t))))
(mathjax . t)
(variable . "revealjs-url=https://cdn.jsdelivr.net/npm/reveal.js@3/"))))
;;
(defun +org|init-export ()

View file

@ -13,7 +13,7 @@
(def-package! ox-reveal
:defer t
:config
(setq org-reveal-root "http://cdn.jsdelivr.net/reveal.js/3.0.0/"
(setq org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js@3/"
org-reveal-mathjax t))

View file

@ -1,21 +1,33 @@
;;; lang/python/+conda.el -*- lexical-binding: t; -*-
;;;###if (featurep! +conda)
;; This file add conda support to doom-emacs. To get started, try `M-x'
;; `+python/set-conda-home' and then `M-x' `conda-env-activate'.
;; Adds conda support to Doom Emacs. `conda-anaconda-home' should be the path to
;; your anaconda installation, and will be guessed from the following:
;;
;; + ~/.anaconda3
;; + ~/.anaconda
;; + ~/usr/bin/anaconda3
;;
;; If none of these work, you'll need to set `conda-anaconda-home' yourself.
;;
;; Once set, run M-x `conda-env-activate' to switch between environments OR turn
;; on `conda-env-autoactivate-mode' if you want it done automatically.
(def-package! conda
:when (featurep! +conda)
:after (python)
:init
(defvar +python-conda-home '("~/.anaconda3" "/usr/bin/anaconda3" "~/.anaconda")
"A list of host pattern and corresponding anaconda home.")
:after python
:config
(advice-add 'anaconda-mode-bootstrap :override #'+python*anaconda-mode-bootstrap)
(conda-env-autoactivate-mode -1)
;; (add-hook 'python-mode-hook #'conda-env-activate-for-buffer)
(unless (cl-loop for dir in (list conda-anaconda-home "/usr/bin/anaconda3" "~/.anaconda")
if (file-directory-p dir)
return (setq conda-anaconda-home dir
conda-env-home-directory dir))
(message "Cannot find Anaconda installation"))
;; integration with term/eshell
(conda-env-initialize-interactive-shells)
(conda-env-initialize-eshell)
;; Version management with conda
(add-hook 'conda-postactivate-hook #'+python|add-conda-env-to-modeline)
(add-hook 'conda-postdeactivate-hook #'+python|add-conda-env-to-modeline))
(after! eshell (conda-env-initialize-eshell))
(add-hook! '(conda-postactivate-hook conda-postdeactivate-hook)
#'+python|add-conda-env-to-modeline)
(advice-add 'anaconda-mode-bootstrap :override #'+python*anaconda-mode-bootstrap-in-remote-environments))

View file

@ -3,25 +3,28 @@
;;;###autoload
(defun +python/set-conda-home ()
"Set the CONDA HOME.
Usually it's `~/.anaconda3' on local machine, but you can also set it to a
remote directory using TRAMP syntax such as `/ssh:host:/usr/bin/anaconda3'. In
that way you can use the remote conda environment as well as the corresponding
remote python executable and packages."
"Set `conda-anaconda-home' (ANACONDA_HOME).
Usually it's `~/.anaconda3' on local machine, but it can be set to a remote
directory using TRAMP syntax, e.g. `/ssh:host:/usr/bin/anaconda3'. This way, you
can use a remote conda environment, including the corresponding remote python
executable and packages."
(interactive)
(ivy-read "Set conda home:" +python-conda-home
:history +python/set-conda-home--history
:action (lambda (cand) (setq conda-anaconda-home cand))))
(require 'conda)
(when-let* ((home (read-directory-name "Set conda home: " "~" nil nil conda-anaconda-home)))
(setq conda-anaconda-home home)
(message "Successfully changed conda home to: %s" (abbreviate-file-name home))))
;;;###autoload
(defun +python|add-conda-env-to-modeline ()
"Add conda environment string to the major mode in the modeline."
"Add conda environment string to the major mode modeline segment."
(setq mode-name
(if conda-env-current-name
(format "Py:conda:%s" conda-env-current-name)
"Python")))
;;;###autoload
(defun +python*anaconda-mode-bootstrap (&optional callback)
(defun +python*anaconda-mode-bootstrap-in-remote-environments (&optional callback)
"Advice to set up the anaconda-mode even in remote environment.
Original doc:
Run `anaconda-mode' server.

View file

@ -1,4 +1,4 @@
;;; lang/python/autoload.el -*- lexical-binding: t; -*-
;;; lang/python/autoload/python.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +python/repl ()

View file

@ -1,7 +1,7 @@
;;; lang/swift/config.el -*- lexical-binding: t; -*-
;; `swift-mode'
(set-repl-handler! 'swift-mode #'run-swift)
(after! swift-mode
(set-repl-handler! 'swift-mode #'run-swift))
(def-package! flycheck-swift

View file

@ -42,15 +42,9 @@ load everything.")
(def-package! magit-todos
:after magit
:hook (magit-mode . magit-todos-mode)
:config
(setq magit-todos-require-colon nil)
;; `magit-todos-mode' defines keybinds on activation, so it's better to just
;; do this manually:
(magit-add-section-hook 'magit-status-sections-hook
#'magit-todos--insert-todos
'magit-insert-staged-changes
'append)
(define-key magit-todos-section-map "j" nil))