~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.
This commit is contained in:
@@ -463,19 +463,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 dx:narrow/narrow-state 0)
|
(defvar dx:narrow/narrow-state 't "To narrow or not to narrow")
|
||||||
(defun dx:narrow/toggle-narrow-state ()
|
(defun dx:narrow/toggle-narrow-state ()
|
||||||
(if (= dx:narrow/narrow-state 1)
|
"Toggle the state of dx:narrow/narrow-state between 't and 'nil"
|
||||||
(setq dx:narrow/narrow-state 0)
|
(if (= dx:narrow/narrow-state 't)
|
||||||
(setq dx:narrow/narrow-state 1)))
|
(setq dx:narrow/narrow-state nil)
|
||||||
|
(setq dx:narrow/narrow-state 't)))
|
||||||
(add-hook 'post-command-hook #'dx:narrow/toggle-narrow-state)
|
|
||||||
|
|
||||||
(defun dx:narrow/toggle-narrow ()
|
(defun dx:narrow/toggle-narrow ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (= dx:narrow/narrow-state 1)
|
(cond ((dx:narrow/narrow-state) (narrow-to-defun))
|
||||||
(narrow-to-defun)
|
(t (widen))))
|
||||||
(widen)))
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** Keybinds
|
*** Keybinds
|
||||||
- Some keybinds for the code prefix which help me with coding or working with
|
- Some keybinds for the code prefix which help me with coding or working with
|
||||||
|
|||||||
Reference in New Issue
Block a user