Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
xarthurx 2018-02-07 21:49:18 +01:00
commit 824a0b10dc
10 changed files with 97 additions and 77 deletions

View file

@ -33,7 +33,7 @@ shift $((OPTIND-1))
if [[ $daemon ]]; then if [[ $daemon ]]; then
emacsclient -a "" \ emacsclient -a "" \
-c -F '((name . "org-capture") (width . 70) (height . 25))' \ -c -F '((name . "org-capture") (width . 70) (height . 25) (transient . t))' \
-e "(+org-capture/open-frame \"$str\" ${key:-nil})" -e "(+org-capture/open-frame \"$str\" ${key:-nil})"
else else
# Non-daemon servers flicker a lot if frames are created from terminal, so # Non-daemon servers flicker a lot if frames are created from terminal, so

View file

@ -68,16 +68,23 @@ you want to interactive with a project other than the one you're in."
(remhash (format "%s-%s" fn default-directory) projectile-project-root-cache))) (remhash (format "%s-%s" fn default-directory) projectile-project-root-cache)))
(defun doom-project-p (&optional nocache) (defun doom-project-p (&optional nocache)
"Whether or not this buffer is currently in a project or not." "Return t if this buffer is currently in a project.
If NOCACHE, don't fetch a cached answer."
(if nocache (if nocache
(without-project-cache! (doom-project-p nil)) (without-project-cache! (doom-project-p nil))
(let ((projectile-require-project-root t)) (let ((projectile-require-project-root t))
(projectile-project-p)))) (and (projectile-project-p) t))))
(defun doom-project-name (&optional nocache)
"Return the name of the current project.
If NOCACHE, don't fetch a cached answer."
(if nocache
(without-project-cache! (doom-project-name nil))
(projectile-project-name)))
(defun doom-project-root (&optional nocache) (defun doom-project-root (&optional nocache)
"Get the path to the root of your project. "Returns the root of your project, or `default-directory' if none was found.
If STRICT-P, return nil if no project was found, otherwise return If NOCACHE, don't fetch a cached answer."
`default-directory'."
(if nocache (if nocache
(without-project-cache! (doom-project-root nil)) (without-project-cache! (doom-project-root nil))
(let (projectile-require-project-root) (let (projectile-require-project-root)

View file

@ -80,7 +80,7 @@ immediately runs it on the current candidate (ending the ivy session)."
counsel-describe-face counsel-M-x counsel-file-jump counsel-describe-face counsel-M-x counsel-file-jump
counsel-find-file counsel-find-library counsel-info-lookup-symbol counsel-find-file counsel-find-library counsel-info-lookup-symbol
counsel-imenu counsel-recentf counsel-yank-pop counsel-imenu counsel-recentf counsel-yank-pop
counsel-descbinds) counsel-descbinds counsel-org-capture)
:init :init
(map! [remap apropos] #'counsel-apropos (map! [remap apropos] #'counsel-apropos
[remap bookmark-jump] #'counsel-bookmark [remap bookmark-jump] #'counsel-bookmark

View file

@ -525,7 +525,7 @@ Accepts the same arguments as `display-buffer-in-side-window'. You must set
((not (numberp slot)) ((not (numberp slot))
(error "Invalid slot %s specified" slot)) (error "Invalid slot %s specified" slot))
((not (numberp vslot)) ((not (numberp vslot))
(error "Invalid vslot %s specified" slot))) (error "Invalid vslot %s specified" vslot)))
(let* ((major (get-window-with-predicate (let* ((major (get-window-with-predicate
(lambda (window) (lambda (window)

View file

@ -69,9 +69,8 @@
;; Sometimes I forget `git-timemachine' is enabled in a buffer, so instead of ;; Sometimes I forget `git-timemachine' is enabled in a buffer, so instead of
;; showing revision details in the minibuffer, show them in ;; showing revision details in the minibuffer, show them in
;; `header-line-format', which has better visibility. ;; `header-line-format', which has better visibility.
(setq git-timemachine-show-minibuffer-details nil) (setq git-timemachine-show-minibuffer-details t)
(add-hook 'git-timemachine-mode-hook #'+vcs|init-header-line) (advice-add #'git-timemachine--show-minibuffer-details :override #'+vcs*update-header-line)
(advice-add #'git-timemachine-show-revision :after #'+vcs*update-header-line)
;; Force evil to rehash keybindings for the current state ;; Force evil to rehash keybindings for the current state
(add-hook 'git-timemachine-mode-hook #'evil-force-normal-state)) (add-hook 'git-timemachine-mode-hook #'evil-force-normal-state))

View file

@ -32,12 +32,20 @@ repository root."
(user-error "No git root found!"))) (user-error "No git root found!")))
;;;###autoload ;;;###autoload
(defun +vcs|init-header-line () (defun +vcs*update-header-line (revision)
"Toggle the git-timemachine header-line on activate. Use this on "Show revision details in the header-line, instead of the minibuffer.
`git-timemachine-mode-hook'."
(if git-timemachine-mode Sometimes I forget `git-timemachine' is enabled in a buffer. Putting revision
(+vcs*update-header-line) info in the `header-line-format' is a good indication."
(setq-local header-line-format nil))) (let* ((date-relative (nth 3 revision))
(date-full (nth 4 revision))
(author (if git-timemachine-show-author (concat (nth 6 revision) ": ") ""))
(sha-or-subject (if (eq git-timemachine-minibuffer-detail 'commit) (car revision) (nth 5 revision))))
(setq header-line-format
(format "%s%s [%s (%s)]"
(propertize author 'face 'git-timemachine-minibuffer-author-face)
(propertize sha-or-subject 'face 'git-timemachine-minibuffer-detail-face)
date-full date-relative))))
;;;###autoload ;;;###autoload
(defun +vcs|enable-smerge-mode-maybe () (defun +vcs|enable-smerge-mode-maybe ()
@ -49,22 +57,3 @@ repository root."
(when (and (featurep 'hydra) (when (and (featurep 'hydra)
+vcs-auto-hydra-smerge) +vcs-auto-hydra-smerge)
(+hydra-smerge/body))))) (+hydra-smerge/body)))))
;;;###autoload
(defun +vcs*update-header-line (&rest _)
"Show revision details in the header-line, instead of the minibuffer.
Sometimes I forget `git-timemachine' is enabled in a buffer. Putting info into,
putting them in `header-line-format' has better visibility."
(when (and git-timemachine-mode git-timemachine-revision)
(let* ((revision git-timemachine-revision)
(date-relative (nth 3 revision))
(date-full (nth 4 revision))
(author (if git-timemachine-show-author (concat (nth 6 revision) ": ") ""))
(sha-or-subject (if (eq git-timemachine-minibuffer-detail 'commit) (car revision) (nth 5 revision))))
(setq-local
header-line-format
(format "%s%s [%s (%s)]"
(propertize author 'face 'git-timemachine-minibuffer-author-face)
(propertize sha-or-subject 'face 'git-timemachine-minibuffer-detail-face)
date-full date-relative)))))

View file

@ -490,28 +490,33 @@ created."
;;;###autoload ;;;###autoload
(defun +workspaces|switch-to-project (&optional inhibit-prompt) (defun +workspaces|switch-to-project (&optional inhibit-prompt)
"Creates a workspace dedicated to a new project. If one already exists, switch "Creates a workspace dedicated to a new project. If one already exists, switch
to it. Should be hooked to `projectile-after-switch-project-hook'." to it. If in the main workspace and it's empty, recycle that workspace, without
renaming it.
Should be hooked to `projectile-after-switch-project-hook'."
(when (and persp-mode +workspaces--project-dir) (when (and persp-mode +workspaces--project-dir)
(unwind-protect (unwind-protect
(let (persp-p) (if (+workspace-buffer-list)
(let* ((persp (let (persp-p)
(let* ((default-directory +workspaces--project-dir) (let* ((persp
projectile-project-name (let* ((default-directory +workspaces--project-dir)
projectile-require-project-root (project-name (doom-project-name 'nocache)))
projectile-cached-buffer-file-name (or (setq persp-p (+workspace-get project-name t))
projectile-cached-project-root (+workspace-new project-name))))
(project-name (projectile-project-name))) (new-name (persp-name persp)))
(or (setq persp-p (+workspace-get project-name t)) (+workspace-switch new-name)
(+workspace-new project-name)))) (unless persp-p
(new-name (persp-name persp))) (switch-to-buffer (doom-fallback-buffer)))
(+workspace-switch new-name) (unless inhibit-prompt
(unless persp-p (doom-project-find-file +workspaces--project-dir))
(switch-to-buffer (doom-fallback-buffer))) (+workspace-message
(unless inhibit-prompt (format "Switched to '%s' in new workspace" new-name)
(doom-project-find-file +workspaces--project-dir)) 'success)))
(+workspace-message (with-current-buffer (switch-to-buffer (doom-fallback-buffer))
(format "Switched to '%s' in new workspace" new-name) (setq default-directory +workspaces--project-dir)
'success))) (message "Switched to '%s'" (doom-project-name 'nocache)))
(unless inhibit-prompt
(doom-project-find-file +workspaces--project-dir)))
(setq +workspaces--project-dir nil)))) (setq +workspaces--project-dir nil))))

View file

@ -34,6 +34,7 @@ Uses the capture template specified by KEY. Otherwise, prompts you for one."
`((name . "org-capture") `((name . "org-capture")
(width . 70) (width . 70)
(height . 25) (height . 25)
(transient . t)
(window-system . ,(cond (IS-MAC 'ns) (window-system . ,(cond (IS-MAC 'ns)
(IS-LINUX 'x) (IS-LINUX 'x)
(t 'w32))) (t 'w32)))
@ -50,31 +51,46 @@ Uses the capture template specified by KEY. Otherwise, prompts you for one."
(defun +org-capture-frame-p (&rest _) (defun +org-capture-frame-p (&rest _)
"Return t if the current frame is an org-capture frame opened by "Return t if the current frame is an org-capture frame opened by
`+org-capture/open-frame'." `+org-capture/open-frame'."
(equal "org-capture" (frame-parameter nil 'name))) (and (equal "org-capture" (frame-parameter nil 'name))
(frame-parameter nil 'transient)))
;;;###autoload ;;;###autoload
(defun +org-capture/open-frame (&optional string key) (defun +org-capture/open-frame (&optional string key)
"Opens the org-capture window in a floating frame that cleans itself up once "Opens the org-capture window in a floating frame that cleans itself up once
you're done. This can be called from an external shell script." you're done. This can be called from an external shell script."
(interactive) (interactive)
(require 'org) (when (and string (string-empty-p string))
(let (after-make-frame-functions before-make-frame-hook) (setq string nil))
(let ((frame (if (+org-capture-frame-p) (when (and key (string-empty-p key))
(selected-frame) (setq key nil))
(make-frame +org-capture-window-params)))) (require 'org-capture)
(with-selected-frame frame (let ((frame (if (+org-capture-frame-p)
(condition-case ex (selected-frame)
(cl-letf (((symbol-function #'pop-to-buffer) (make-frame +org-capture-window-params))))
(symbol-function #'switch-to-buffer))) (with-selected-frame frame
(if (and (stringp string) (condition-case ex
(not (string-empty-p string))) (cl-letf (((symbol-function #'pop-to-buffer)
(org-capture-string string key) (symbol-function #'switch-to-buffer)))
(org-capture nil key)) (switch-to-buffer (doom-fallback-buffer))
(when (featurep 'solaire-mode) (let ((org-capture-initial string)
(solaire-mode +1))) (org-capture-mode-hook org-capture-mode-hook)
('error org-capture-entry)
(message "org-capture: %s" (error-message-string ex)) (when (and key (not (string-empty-p key)))
(delete-frame frame))))))) (setq org-capture-entry (org-capture-select-template key)))
(if (or org-capture-entry
(not (fboundp 'counsel-org-capture)))
(org-capture)
(unwind-protect
(counsel-org-capture)
(if-let* ((buf (cl-loop for buf in (buffer-list)
if (buffer-local-value 'org-capture-mode buf)
return buf)))
(with-current-buffer buf
(add-hook 'kill-buffer-hook #'+org-capture|cleanup-frame nil t))
(delete-frame frame))))))
('error
(message "org-capture: %s" (error-message-string ex))
(delete-frame frame))))))
;;;###autoload ;;;###autoload
(defun +org-capture-available-keys () (defun +org-capture-available-keys ()

View file

@ -55,7 +55,7 @@
:ne "M-b" #'+eval/build :ne "M-b" #'+eval/build
:ne "M-a" #'mark-whole-buffer :ne "M-a" #'mark-whole-buffer
:ne "M-c" #'evil-yank :ne "M-c" #'evil-yank
:ne "M-q" (if (daemonp) #'delete-frame #'save-buffers-kill-emacs) :ne "M-q" (if (daemonp) #'delete-frame #'evil-quit-all)
:ne "M-f" #'swiper :ne "M-f" #'swiper
:n "M-s" #'save-buffer :n "M-s" #'save-buffer
:m "A-j" #'+default:multi-next-line :m "A-j" #'+default:multi-next-line

View file

@ -27,7 +27,11 @@
:config :config
(setq solaire-mode-real-buffer-fn #'doom-real-buffer-p) (setq solaire-mode-real-buffer-fn #'doom-real-buffer-p)
;; Prevent color glitches when reloading either DOOM or the theme ;; Prevent color glitches when reloading either DOOM or the theme
(add-hook! '(doom-init-theme-hook doom-reload-hook) #'solaire-mode-reset)) (add-hook! '(doom-init-theme-hook doom-reload-hook)
#'solaire-mode-reset)
;; org-capture takes an org buffer and narrows it. The result is erroneously
;; considered an unreal buffer, so solaire-mode must be restored.
(add-hook 'org-capture-mode-hook #'turn-on-solaire-mode))
(after! hideshow (after! hideshow