diff --git a/gists.org b/gists.org index b3ad908..72543b8 100644 --- a/gists.org +++ b/gists.org @@ -713,6 +713,20 @@ Based on an answer at the [[https://emacs.stackexchange.com/a/77480/34645][Emacs (magit-diff-range range () (list (buffer-file-name))))) #+end_src +* Narrow from/to point :emacs: + +#+begin_src elisp :tangle gists/narrow-from-to-point.el + (defun my/narrow-from-point () + "Narrow the buffer from point to end of the (narrowed) buffer." + (interactive) + (narrow-to-region (point) (point-max))) + + (defun my/narrow-to-point () + "Narrow the buffer the start of a (narrowed) buffer up to point." + (interactive) + (narrow-to-region (point-min) (point))) +#+end_src + * Meta ** License diff --git a/gists/narrow-from-to-point.el b/gists/narrow-from-to-point.el new file mode 100644 index 0000000..6a27f2d --- /dev/null +++ b/gists/narrow-from-to-point.el @@ -0,0 +1,9 @@ +(defun my/narrow-from-point () + "Narrow the buffer from point to end of the (narrowed) buffer." + (interactive) + (narrow-to-region (point) (point-max))) + +(defun my/narrow-to-point () + "Narrow the buffer the start of a (narrowed) buffer up to point." + (interactive) + (narrow-to-region (point-min) (point)))