From 5dac639bc0949f0b688f1f139a985679233d1a1f Mon Sep 17 00:00:00 2001 From: dx Date: Fri, 24 Apr 2020 01:57:43 +0100 Subject: ~refactor custom functions oreodave/->dx: e.g. oreodave/debug -> dx:debug This makes namespacing a lot more noticeable, and less cringy to look at. --- doom.d/org/config.org | 38 +++++++++++++++++++------------------- doom.d/org/literate.org | 26 +++++++++++++------------- doom.d/org/personal.org | 16 ++++++++-------- 3 files changed, 40 insertions(+), 40 deletions(-) (limited to 'doom.d') diff --git a/doom.d/org/config.org b/doom.d/org/config.org index b3d0f6f..c295c7b 100644 --- a/doom.d/org/config.org +++ b/doom.d/org/config.org @@ -38,14 +38,14 @@ Some quality of life things and others that I couldn't really put in one categor * Package Config Config for or based heavily around specific packages that I find very important ** DAP -*** oreodave/debug +*** Function 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 - Routine sets up the panes that I like to use, instead of M-x'ing it - *cD* starts up the routine #+BEGIN_SRC elisp (after! dap-mode - (defun oreodave/debug () + (defun dx:debug () (interactive) (dap-ui-mode) (dap-ui-locals) @@ -56,7 +56,7 @@ Easier to do than just running all those functions manually (map! :after dap-mode :leader - :desc "Start debugging setup" "cD" #'oreodave/debug) + :desc "Start debugging setup" "cD" #'dx:debug) #+END_SRC ** Elfeed 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) ("Check the weather" :icon (all-the-icons-wicon "rain" :face 'font-lock-keyword-face) - :action oreodave/weather) + :action dx:weather) ("Jump to bookmark" :icon (all-the-icons-octicon "bookmark" :face 'font-lock-keyword-face) :action bookmark-jump))) @@ -235,7 +235,7 @@ VSCode style web-kit window. that the pattern can be matched) #+BEGIN_SRC elisp (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#" (interactive) (let* ((tags-file (counsel-etags-locate-tags-file)) @@ -257,7 +257,7 @@ VSCode style web-kit window. (find-file file) (counsel-etags-forward-line linenum) (omnisharp-unit-test-at-point)))) - :caller 'oreodave/csharp/get-unit-tests-in-project)))) + :caller 'dx:csharp/get-unit-tests-in-project)))) #+END_SRC *** Redo omnisharp-emit-results - Reimplemented omnisharp-emit-results to emit stdout regardless of whether the @@ -325,7 +325,7 @@ each of the unit tests ran." :localleader :desc "Format buffer" "=" #'omnisharp-code-format-entire-file (: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 ** Python - 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 notes" "n" #'(lambda () (interactive) (dired org-directory)) :desc "Open code" "c" #'(lambda () (interactive) (dired (expand-file-name "~/Code"))) - :desc "Open weather" "w" #'oreodave/weather - :desc "Change theme" "t" #'oreodave/themes/set-new-theme ; From my own collection + :desc "Open weather" "w" #'dx:weather + :desc "Change theme" "t" #'dx:themes/set-new-theme ; From my own collection :desc "Generate template" "g" #'+gentemplate/generate-template ; From my own collection (:after pdf-view :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 ** Counsel - Counsel keybind config @@ -449,17 +449,17 @@ General keymap *** Narrow handlers - Toggles narrow to function by checking a variable #+BEGIN_SRC elisp -(setq oreodave/narrow/narrow-state 0) -(defun oreodave/narrow/toggle-narrow-state () - (if (= oreodave/narrow/narrow-state 1) - (setq oreodave/narrow/narrow-state 0) - (setq oreodave/narrow/narrow-state 1))) +(setq dx:narrow/narrow-state 0) +(defun dx:narrow/toggle-narrow-state () + (if (= dx:narrow/narrow-state 1) + (setq dx:narrow/narrow-state 0) + (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) - (if (= oreodave/narrow/narrow-state 1) + (if (= dx:narrow/narrow-state 1) (narrow-to-defun) (widen))) #+END_SRC @@ -473,7 +473,7 @@ General keymap :desc "Fold all in level" "f" #'hs-hide-level :desc "Compile via make" "C" #'+make/run :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 :desc "Format code" "=" #'format-all-buffer) (:after lsp diff --git a/doom.d/org/literate.org b/doom.d/org/literate.org index 19829cf..47a8a64 100644 --- a/doom.d/org/literate.org +++ b/doom.d/org/literate.org @@ -10,8 +10,8 @@ Initialise some basic constants for where stuff is. - literate/preloaded-files: Relative to ~$DOOM~, which files are already preloaded/don't need to be compiled #+BEGIN_SRC elisp -(setq oreodave/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/bin-dir (expand-file-name (concat doom-private-dir "bin/"))) +(setq dx:literate/preloaded-files (list "README.org" "org/packages.org" "org/config.org" "org/literate.org")) #+END_SRC * 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 expanded file names. #+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'" (let ((parsed-remove-files (map 'list #'(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 multiple /differing/ outputs easily if it isn't specified a destination. #+BEGIN_SRC elisp -(defun oreodave/literate/destination(SRC) +(defun dx:literate/destination(SRC) "Parse a src.org file to a bin/src.el file" (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 * Parser 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 literate module of doom. #+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" (let ((default-directory doom-private-dir)) (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 literate contents. #+BEGIN_SRC elisp -(defun oreodave/literate/compile-hook () +(defun dx:literate/compile-hook () "Any org file within $DOOM/org will be compiled on save" (when (and (eq major-mode 'org-mode) (or (file-in-directory-p buffer-file-name doom-private-dir) (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"))))) - (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 - (add-hook 'after-save-hook #'oreodave/literate/compile-hook)) + (add-hook 'after-save-hook #'dx:literate/compile-hook)) #+END_SRC * Procedure for all files 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 because this is the function we'll be using for tangling all org files to ELisp files. #+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'" (interactive) (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"))) (dolist (file files) (message "Compiling and parsing %s" file) - (oreodave/literate/tangle file (oreodave/literate/destination file))))) + (dx:literate/tangle file (dx:literate/destination file))))) #+END_SRC * Load configuration 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 (let ((files (directory-files-recursively "~/.doom.d/org/" ".org"))) ; Load - (dolist (file (oreodave/literate/remove-mult oreodave/literate/preloaded-files files)) - (load (oreodave/literate/destination file)))) + (dolist (file (dx:literate/remove-mult dx:literate/preloaded-files files)) + (load (dx:literate/destination file)))) #+END_SRC diff --git a/doom.d/org/personal.org b/doom.d/org/personal.org index 5d55bef..37a532a 100644 --- a/doom.d/org/personal.org +++ b/doom.d/org/personal.org @@ -12,14 +12,14 @@ Some user variables Reload the doom session by brute force fully loading the "config.el" file in the doom private directory. #+BEGIN_SRC elisp -(defun oreodave/reload () +(defun dx:reload () "Reload instance of doom" (interactive) (load-file (concat doom-private-dir "config.el"))) #+END_SRC * Change theme Allow user to set a theme from a limited set of candidates, based on -"oreodave/theme-list". +"dx:theme-list". - Themes sanctioned by me: - 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. #+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-outrun-electric doom-vibrant doom-molokai doom-solarized-light doom-acario-light 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" (interactive) (ivy-read "Select theme: " - oreodave/themes/theme-list + dx:themes/theme-list :caller 'oreodave/set-new-theme :action (lambda (x) ; Shamelessly copied from counsel in case of change (condition-case nil @@ -60,14 +60,14 @@ Allow user to set a theme from a limited set of candidates, based on * Password store Function to get a password given a key. #+BEGIN_SRC elisp -(defun oreodave/password-store/get-password (KEY) +(defun dx:password-store/get-password (KEY) (shell-command-to-string (concat "pass " KEY))) #+END_SRC * Weather Function to quickly check weather, which is what I wanted wttrin for. #+BEGIN_SRC elisp -(defun oreodave/weather () +(defun dx:weather () "Check the weather at the 'location' stored in password store" (interactive) - (wttrin (oreodave/password-store/get-password "location"))) + (wttrin (dx:password-store/get-password "location"))) #+END_SRC -- cgit v1.2.3-13-gbd6f