diff --git a/CHANGELOG.develop b/CHANGELOG.develop index 8a7cd19d2..5294eb6f7 100644 --- a/CHANGELOG.develop +++ b/CHANGELOG.develop @@ -521,6 +521,9 @@ Other: terminal mode, but no longer in GUI mode. (emacs18) *** Core changes - Improvements: + - Provide keybindings for using narrow with an indirect buffer, for when you + want narrowing multiple times in the same base buffer (thanks to Keith + Pinson and duianto) - Make =describe-text-properties= available in the help -> describe menu via ~SPC h d t~ (thanks to Keith Pinson) - Bind ~SPC c n~ to ~:cn~ / ~next-error~ and ~SPC c N~ to ~:cN~ / ~previous-error~ diff --git a/layers/+spacemacs/spacemacs-defaults/funcs.el b/layers/+spacemacs/spacemacs-defaults/funcs.el index ca45d66fb..d6382bbc9 100644 --- a/layers/+spacemacs/spacemacs-defaults/funcs.el +++ b/layers/+spacemacs/spacemacs-defaults/funcs.el @@ -1724,3 +1724,24 @@ Decision is based on `dotspacemacs-line-numbers'." (mapcar 'cdr (sort (mapcar (lambda (x) (cons (random) (concat x "\n"))) lines) (lambda (a b) (< (car a) (car b)))))))) + + +;; narrow region + +(defun spacemacs/narrow-to-defun-indirect-buffer () + (interactive) + (call-interactively 'clone-indirect-buffer) + (call-interactively 'narrow-to-defun) + (message "Function narrowed to an indirect buffer")) + +(defun spacemacs/narrow-to-page-indirect-buffer () + (interactive) + (call-interactively 'clone-indirect-buffer) + (call-interactively 'narrow-to-page) + (message "Page narrowed to an indirect buffer")) + +(defun spacemacs/narrow-to-region-indirect-buffer () + (interactive) + (call-interactively 'clone-indirect-buffer) + (call-interactively 'narrow-to-region) + (message "Region narrowed to an indirect buffer")) diff --git a/layers/+spacemacs/spacemacs-defaults/keybindings.el b/layers/+spacemacs/spacemacs-defaults/keybindings.el index 2a71e920b..2fdc98f11 100644 --- a/layers/+spacemacs/spacemacs-defaults/keybindings.el +++ b/layers/+spacemacs/spacemacs-defaults/keybindings.el @@ -454,6 +454,9 @@ "nr" 'narrow-to-region "np" 'narrow-to-page "nf" 'narrow-to-defun + "nR" 'spacemacs/narrow-to-region-indirect-buffer + "nP" 'spacemacs/narrow-to-page-indirect-buffer + "nF" 'spacemacs/narrow-to-defun-indirect-buffer "nw" 'widen) ;; toggle --------------------------------------------------------------------- (spacemacs|add-toggle highlight-current-line-globally