~refactor custom functions oreodave/->dx:

e.g. oreodave/debug -> dx:debug

This makes namespacing a lot more noticeable, and less cringy to look at.
This commit is contained in:
dx
2020-04-24 01:57:43 +01:00
parent 05ffefd7a1
commit 5dac639bc0
3 changed files with 40 additions and 40 deletions

View File

@@ -38,14 +38,14 @@ Some quality of life things and others that I couldn't really put in one categor
* Package Config * Package Config
Config for or based heavily around specific packages that I find very important Config for or based heavily around specific packages that I find very important
** DAP ** DAP
*** oreodave/debug *** Function
First to setup is a routine for setting up all the dap-panes for debugging. First to setup is a routine for setting up all the dap-panes for debugging.
Easier to do than just running all those functions manually Easier to do than just running all those functions manually
- Routine sets up the panes that I like to use, instead of M-x'ing it - Routine sets up the panes that I like to use, instead of M-x'ing it
- *<SPC>cD* starts up the routine - *<SPC>cD* starts up the routine
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(after! dap-mode (after! dap-mode
(defun oreodave/debug () (defun dx:debug ()
(interactive) (interactive)
(dap-ui-mode) (dap-ui-mode)
(dap-ui-locals) (dap-ui-locals)
@@ -56,7 +56,7 @@ Easier to do than just running all those functions manually
(map! (map!
:after dap-mode :after dap-mode
:leader :leader
:desc "Start debugging setup" "cD" #'oreodave/debug) :desc "Start debugging setup" "cD" #'dx:debug)
#+END_SRC #+END_SRC
** Elfeed ** Elfeed
Custom functions to work with elfeed, generating new feeds on demand and adding Custom functions to work with elfeed, generating new feeds on demand and adding
@@ -127,7 +127,7 @@ the interactive menu as well.
:action org-agenda) :action org-agenda)
("Check the weather" ("Check the weather"
:icon (all-the-icons-wicon "rain" :face 'font-lock-keyword-face) :icon (all-the-icons-wicon "rain" :face 'font-lock-keyword-face)
:action oreodave/weather) :action dx:weather)
("Jump to bookmark" ("Jump to bookmark"
:icon (all-the-icons-octicon "bookmark" :face 'font-lock-keyword-face) :icon (all-the-icons-octicon "bookmark" :face 'font-lock-keyword-face)
:action bookmark-jump))) :action bookmark-jump)))
@@ -235,7 +235,7 @@ VSCode style web-kit window.
that the pattern can be matched) that the pattern can be matched)
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(after! (csharp-mode counsel-etags) (after! (csharp-mode counsel-etags)
(defun oreodave/csharp/get-unit-test-in-project () (defun dx:csharp/get-unit-test-in-project ()
"Unit test anywhere using CTags or ETags and C#" "Unit test anywhere using CTags or ETags and C#"
(interactive) (interactive)
(let* ((tags-file (counsel-etags-locate-tags-file)) (let* ((tags-file (counsel-etags-locate-tags-file))
@@ -257,7 +257,7 @@ VSCode style web-kit window.
(find-file file) (find-file file)
(counsel-etags-forward-line linenum) (counsel-etags-forward-line linenum)
(omnisharp-unit-test-at-point)))) (omnisharp-unit-test-at-point))))
:caller 'oreodave/csharp/get-unit-tests-in-project)))) :caller 'dx:csharp/get-unit-tests-in-project))))
#+END_SRC #+END_SRC
*** Redo omnisharp-emit-results *** Redo omnisharp-emit-results
- Reimplemented omnisharp-emit-results to emit stdout regardless of whether the - Reimplemented omnisharp-emit-results to emit stdout regardless of whether the
@@ -325,7 +325,7 @@ each of the unit tests ran."
:localleader :localleader
:desc "Format buffer" "=" #'omnisharp-code-format-entire-file :desc "Format buffer" "=" #'omnisharp-code-format-entire-file
(:prefix "t" (:prefix "t"
:desc "Select Test in Project" "t" #'oreodave/csharp/get-unit-test-in-project))) :desc "Select Test in Project" "t" #'dx:csharp/get-unit-test-in-project)))
#+END_SRC #+END_SRC
** Python ** Python
- I do python development for Python3, so I need to set the flycheck python checker, as well as the interpreter, to be Python3 - I do python development for Python3, so I need to set the flycheck python checker, as well as the interpreter, to be Python3
@@ -414,12 +414,12 @@ General keymap
:desc "Open school dir" "s" #'(lambda () (interactive) (dired (expand-file-name "~/School"))) :desc "Open school dir" "s" #'(lambda () (interactive) (dired (expand-file-name "~/School")))
:desc "Open notes" "n" #'(lambda () (interactive) (dired org-directory)) :desc "Open notes" "n" #'(lambda () (interactive) (dired org-directory))
:desc "Open code" "c" #'(lambda () (interactive) (dired (expand-file-name "~/Code"))) :desc "Open code" "c" #'(lambda () (interactive) (dired (expand-file-name "~/Code")))
:desc "Open weather" "w" #'oreodave/weather :desc "Open weather" "w" #'dx:weather
:desc "Change theme" "t" #'oreodave/themes/set-new-theme ; From my own collection :desc "Change theme" "t" #'dx:themes/set-new-theme ; From my own collection
:desc "Generate template" "g" #'+gentemplate/generate-template ; From my own collection :desc "Generate template" "g" #'+gentemplate/generate-template ; From my own collection
(:after pdf-view (:after pdf-view
:desc "Goto page on pdf" "p" #'pdf-view-goto-page) :desc "Goto page on pdf" "p" #'pdf-view-goto-page)
:desc "Reload emacs" "r" #'oreodave/reload) ; Reload is necessary :desc "Reload emacs" "r" #'dx:reload) ; Reload is necessary
#+END_SRC #+END_SRC
** Counsel ** Counsel
- Counsel keybind config - Counsel keybind config
@@ -449,17 +449,17 @@ General keymap
*** Narrow handlers *** Narrow handlers
- Toggles narrow to function by checking a variable - Toggles narrow to function by checking a variable
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(setq oreodave/narrow/narrow-state 0) (setq dx:narrow/narrow-state 0)
(defun oreodave/narrow/toggle-narrow-state () (defun dx:narrow/toggle-narrow-state ()
(if (= oreodave/narrow/narrow-state 1) (if (= dx:narrow/narrow-state 1)
(setq oreodave/narrow/narrow-state 0) (setq dx:narrow/narrow-state 0)
(setq oreodave/narrow/narrow-state 1))) (setq dx:narrow/narrow-state 1)))
(add-hook 'post-command-hook #'oreodave/narrow/toggle-narrow-state) (add-hook 'post-command-hook #'dx:narrow/toggle-narrow-state)
(defun oreodave/narrow/toggle-narrow () (defun dx:narrow/toggle-narrow ()
(interactive) (interactive)
(if (= oreodave/narrow/narrow-state 1) (if (= dx:narrow/narrow-state 1)
(narrow-to-defun) (narrow-to-defun)
(widen))) (widen)))
#+END_SRC #+END_SRC
@@ -473,7 +473,7 @@ General keymap
:desc "Fold all in level" "f" #'hs-hide-level :desc "Fold all in level" "f" #'hs-hide-level
:desc "Compile via make" "C" #'+make/run :desc "Compile via make" "C" #'+make/run
:desc "Undo tree" "u" #'undo-tree-visualize :desc "Undo tree" "u" #'undo-tree-visualize
:desc "Narrow to function" "n" #'oreodave/narrow/toggle-narrow :desc "Narrow to function" "n" #'dx:narrow/toggle-narrow
(:after format-all (:after format-all
:desc "Format code" "=" #'format-all-buffer) :desc "Format code" "=" #'format-all-buffer)
(:after lsp (:after lsp

View File

@@ -10,8 +10,8 @@ Initialise some basic constants for where stuff is.
- literate/preloaded-files: Relative to ~$DOOM~, which files are already - literate/preloaded-files: Relative to ~$DOOM~, which files are already
preloaded/don't need to be compiled preloaded/don't need to be compiled
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(setq oreodave/literate/bin-dir (expand-file-name (concat doom-private-dir "bin/"))) (setq dx:literate/bin-dir (expand-file-name (concat doom-private-dir "bin/")))
(setq oreodave/literate/preloaded-files (list "README.org" "org/packages.org" (setq dx:literate/preloaded-files (list "README.org" "org/packages.org"
"org/config.org" "org/literate.org")) "org/config.org" "org/literate.org"))
#+END_SRC #+END_SRC
* Remove function * Remove function
@@ -21,7 +21,7 @@ specific remove function that will remove entries from a given list and return
the new list, given the fact that the files variable will be a list of fully the new list, given the fact that the files variable will be a list of fully
expanded file names. expanded file names.
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(defun oreodave/literate/remove-mult (remove-files files) (defun dx:literate/remove-mult (remove-files files)
"Remove any occurrences of `remove-files' from `files'" "Remove any occurrences of `remove-files' from `files'"
(let ((parsed-remove-files (map 'list (let ((parsed-remove-files (map 'list
#'(lambda (i) (expand-file-name (concat doom-private-dir i))) #'(lambda (i) (expand-file-name (concat doom-private-dir i)))
@@ -34,17 +34,17 @@ case the bin folder in the private directory
This is not fitted onto the parser because the parser could be fitted to This is not fitted onto the parser because the parser could be fitted to
multiple /differing/ outputs easily if it isn't specified a destination. multiple /differing/ outputs easily if it isn't specified a destination.
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(defun oreodave/literate/destination(SRC) (defun dx:literate/destination(SRC)
"Parse a src.org file to a bin/src.el file" "Parse a src.org file to a bin/src.el file"
(replace-regexp-in-string ".*/\\(\\w+\\).org" (replace-regexp-in-string ".*/\\(\\w+\\).org"
(expand-file-name (concat oreodave/literate/bin-dir "\\1.el")) SRC)) (expand-file-name (concat dx:literate/bin-dir "\\1.el")) SRC))
#+END_SRC #+END_SRC
* Parser * Parser
First we need to get some sort of parser which can, given a source org file and First we need to get some sort of parser which can, given a source org file and
a destination, parse and produce an Emacs lisp file. We'll copy this from the a destination, parse and produce an Emacs lisp file. We'll copy this from the
literate module of doom. literate module of doom.
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(defun oreodave/literate/tangle (SRC DEST) (defun dx:literate/tangle (SRC DEST)
"Tangle a source org file into a destination el file using a new emacs instance" "Tangle a source org file into a destination el file using a new emacs instance"
(let ((default-directory doom-private-dir)) (let ((default-directory doom-private-dir))
(when (file-newer-than-file-p SRC DEST) (when (file-newer-than-file-p SRC DEST)
@@ -69,16 +69,16 @@ this hook function and add it to the after-save-hook once org mode has been
loaded. README.org has been added as an exception because it doesn't contain loaded. README.org has been added as an exception because it doesn't contain
literate contents. literate contents.
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(defun oreodave/literate/compile-hook () (defun dx:literate/compile-hook ()
"Any org file within $DOOM/org will be compiled on save" "Any org file within $DOOM/org will be compiled on save"
(when (and (eq major-mode 'org-mode) (when (and (eq major-mode 'org-mode)
(or (file-in-directory-p buffer-file-name doom-private-dir) (or (file-in-directory-p buffer-file-name doom-private-dir)
(file-in-directory-p buffer-file-name (concat doom-private-dir "org"))) (file-in-directory-p buffer-file-name (concat doom-private-dir "org")))
(not (string= buffer-file-name (expand-file-name (concat doom-private-dir "README.org"))))) (not (string= buffer-file-name (expand-file-name (concat doom-private-dir "README.org")))))
(oreodave/literate/tangle buffer-file-name (oreodave/literate/destination buffer-file-name)))) (dx:literate/tangle buffer-file-name (dx:literate/destination buffer-file-name))))
(after! org (after! org
(add-hook 'after-save-hook #'oreodave/literate/compile-hook)) (add-hook 'after-save-hook #'dx:literate/compile-hook))
#+END_SRC #+END_SRC
* Procedure for all files * Procedure for all files
A procedure that parses all the org files in a given directory into Emacs lisp A procedure that parses all the org files in a given directory into Emacs lisp
@@ -88,7 +88,7 @@ The location is not set because this function could be easily programmed to use
multiple /differing/ sources to produce the config. The tangle function is set multiple /differing/ sources to produce the config. The tangle function is set
because this is the function we'll be using for tangling all org files to ELisp files. because this is the function we'll be using for tangling all org files to ELisp files.
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(defun oreodave/literate/tangle-all (&optional location) (defun dx:literate/tangle-all (&optional location)
"Tangle all org files in `location' to el files in the `destination'" "Tangle all org files in `location' to el files in the `destination'"
(interactive) (interactive)
(or location (setq location doom-private-dir)) (or location (setq location doom-private-dir))
@@ -96,7 +96,7 @@ because this is the function we'll be using for tangling all org files to ELisp
(let ((files (directory-files-recursively location ".org"))) (let ((files (directory-files-recursively location ".org")))
(dolist (file files) (dolist (file files)
(message "Compiling and parsing %s" file) (message "Compiling and parsing %s" file)
(oreodave/literate/tangle file (oreodave/literate/destination file))))) (dx:literate/tangle file (dx:literate/destination file)))))
#+END_SRC #+END_SRC
* Load configuration * Load configuration
Final step of the literate cycle: load the config for the first time. Final step of the literate cycle: load the config for the first time.
@@ -106,6 +106,6 @@ Remove the config.el and literate.el files from the load list because:
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(let ((files (directory-files-recursively "~/.doom.d/org/" ".org"))) ; Load (let ((files (directory-files-recursively "~/.doom.d/org/" ".org"))) ; Load
(dolist (file (oreodave/literate/remove-mult oreodave/literate/preloaded-files files)) (dolist (file (dx:literate/remove-mult dx:literate/preloaded-files files))
(load (oreodave/literate/destination file)))) (load (dx:literate/destination file))))
#+END_SRC #+END_SRC

View File

@@ -12,14 +12,14 @@ Some user variables
Reload the doom session by brute force fully loading the "config.el" file in the Reload the doom session by brute force fully loading the "config.el" file in the
doom private directory. doom private directory.
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(defun oreodave/reload () (defun dx:reload ()
"Reload instance of doom" "Reload instance of doom"
(interactive) (interactive)
(load-file (concat doom-private-dir "config.el"))) (load-file (concat doom-private-dir "config.el")))
#+END_SRC #+END_SRC
* Change theme * Change theme
Allow user to set a theme from a limited set of candidates, based on Allow user to set a theme from a limited set of candidates, based on
"oreodave/theme-list". "dx:theme-list".
- Themes sanctioned by me: - Themes sanctioned by me:
- doom-solarized-dark: just the right everything. best for day. - doom-solarized-dark: just the right everything. best for day.
@@ -36,17 +36,17 @@ Allow user to set a theme from a limited set of candidates, based on
handle those. handle those.
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(setq oreodave/themes/theme-list '(doom-solarized-dark (setq dx:themes/theme-list '(doom-solarized-dark
doom-gruvbox doom-city-lights doom-gruvbox doom-city-lights
doom-outrun-electric doom-vibrant doom-molokai doom-outrun-electric doom-vibrant doom-molokai
doom-solarized-light doom-acario-light doom-solarized-light doom-acario-light
base16-3024 base16-classic-dark base16-material-vivid)) base16-3024 base16-classic-dark base16-material-vivid))
(defun oreodave/themes/set-new-theme () (defun dx:themes/set-new-theme ()
"Set the theme from my own selection, mutate as you see fit" "Set the theme from my own selection, mutate as you see fit"
(interactive) (interactive)
(ivy-read "Select theme: " (ivy-read "Select theme: "
oreodave/themes/theme-list dx:themes/theme-list
:caller 'oreodave/set-new-theme :caller 'oreodave/set-new-theme
:action (lambda (x) ; Shamelessly copied from counsel in case of change :action (lambda (x) ; Shamelessly copied from counsel in case of change
(condition-case nil (condition-case nil
@@ -60,14 +60,14 @@ Allow user to set a theme from a limited set of candidates, based on
* Password store * Password store
Function to get a password given a key. Function to get a password given a key.
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(defun oreodave/password-store/get-password (KEY) (defun dx:password-store/get-password (KEY)
(shell-command-to-string (concat "pass " KEY))) (shell-command-to-string (concat "pass " KEY)))
#+END_SRC #+END_SRC
* Weather * Weather
Function to quickly check weather, which is what I wanted wttrin for. Function to quickly check weather, which is what I wanted wttrin for.
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(defun oreodave/weather () (defun dx:weather ()
"Check the weather at the 'location' stored in password store" "Check the weather at the 'location' stored in password store"
(interactive) (interactive)
(wttrin (oreodave/password-store/get-password "location"))) (wttrin (dx:password-store/get-password "location")))
#+END_SRC #+END_SRC