diff options
author | dx <aryadevchavali1@gmail.com> | 2020-05-10 17:25:56 +0100 |
---|---|---|
committer | dx <aryadevchavali1@gmail.com> | 2020-05-10 17:25:56 +0100 |
commit | 5bd00101fcb0288dad3220aa798293bef3763f44 (patch) | |
tree | dcc9dc82483649e145956d305119104efa909fd7 /Doom/.doom.d/org | |
parent | 5bfcedb6b0a3d801d83e38bfd4306e5577ebf2f3 (diff) | |
download | dotfiles-5bd00101fcb0288dad3220aa798293bef3763f44.tar.gz dotfiles-5bd00101fcb0288dad3220aa798293bef3763f44.tar.bz2 dotfiles-5bd00101fcb0288dad3220aa798293bef3763f44.zip |
~clean p the narrow state config
Basically, setq -> defvar and using cond instead of if due to the
ability to do multiple conditions for the body of an 'if'.
I might make this a module actually.
Diffstat (limited to 'Doom/.doom.d/org')
-rw-r--r-- | Doom/.doom.d/org/config.org | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/Doom/.doom.d/org/config.org b/Doom/.doom.d/org/config.org index 9c22bbe..2b535b9 100644 --- a/Doom/.doom.d/org/config.org +++ b/Doom/.doom.d/org/config.org @@ -463,19 +463,17 @@ General keymap *** Narrow handlers - Toggles narrow to function by checking a variable #+BEGIN_SRC elisp -(setq dx:narrow/narrow-state 0) +(defvar dx:narrow/narrow-state 't "To narrow or not to narrow") (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 #'dx:narrow/toggle-narrow-state) + "Toggle the state of dx:narrow/narrow-state between 't and 'nil" + (if (= dx:narrow/narrow-state 't) + (setq dx:narrow/narrow-state nil) + (setq dx:narrow/narrow-state 't))) (defun dx:narrow/toggle-narrow () (interactive) - (if (= dx:narrow/narrow-state 1) - (narrow-to-defun) - (widen))) + (cond ((dx:narrow/narrow-state) (narrow-to-defun)) + (t (widen)))) #+END_SRC *** Keybinds - Some keybinds for the code prefix which help me with coding or working with |