Skip to content

Instantly share code, notes, and snippets.

@humanfactors
Created May 27, 2018 09:52
Show Gist options
  • Save humanfactors/7188f80542f63425168d869fb3bfcd8e to your computer and use it in GitHub Desktop.
Save humanfactors/7188f80542f63425168d869fb3bfcd8e to your computer and use it in GitHub Desktop.
Quick navigation in Spacemacs, with a quick open in system viewer.
(defmacro when-system (type &rest body)
"Evaluate BODY if `system-type' equals TYPE."
(declare (indent defun))
`(when (eq system-type ',type)
,@body))
(defun open-directory-in-system-viewer ()
(interactive)
(when-system gnu/linux
(if default-directory
(browse-url-of-file (expand-file-name default-directory))
(error "No `default-directory' to open")))
(when-system windows-nt
(if default-directory
(w32explore (expand-file-name default-directory))
(error "No `default-directory' to open"))))
(spacemacs/declare-prefix "oo" "openpath-michael")
(spacemacs/set-leader-keys "o TAB" 'open-directory-in-system-viewer)
(defun openpath-dropbox ()
(interactive) (find-file "~/Dropbox/"))
(defun openpath-orgdir ()
(interactive) (find-file "~/Dropbox/org/"))
(defun openpath-blog ()
(interactive) (find-file "~/humanfactors/michael-blog/"))
(defun openpath-code ()
(interactive) (find-file "~/Code/"))
(defun openpath-dotfiles ()
(interactive) (find-file "~/.spacemacs.d/"))
(defun openpath-atc-derde ()
(interactive) (find-file "~/PhD/atc-interruptions-derde"))
(defun openpath-home ()
(interactive) (find-file "~/"))
(global-set-key (kbd "C-x M-1") 'openpath-dropbox)
(global-set-key (kbd "C-x M-2") 'openpath-orgdir)
(global-set-key (kbd "C-x M-3") 'openpath-blog)
(global-set-key (kbd "C-x M-4") 'openpath-code)
(global-set-key (kbd "C-x M-5") 'openpath-dotfiles)
(global-set-key (kbd "C-x M-6") 'openpath-atc-derde)
(spacemacs/set-leader-keys "ood" 'openpath-dropbox)
(spacemacs/set-leader-keys "ooo" 'openpath-orgdir)
(spacemacs/set-leader-keys "oob" 'openpath-blog)
(spacemacs/set-leader-keys "ooc" 'openpath-code)
(spacemacs/set-leader-keys "oos" 'openpath-dotfiles)
(spacemacs/set-leader-keys "oo3" 'openpath-atc-derde)
(spacemacs/set-leader-keys "ooh" 'openpath-home)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment