From b6d0f96a403af27accd55137205924fb125679fc Mon Sep 17 00:00:00 2001 From: Bram Schoenmakers Date: Fri, 8 Sep 2023 13:28:01 +0200 Subject: [PATCH] Add functions to narrow from or to point --- gists.org | 14 ++++++++++++++ gists/narrow-from-to-point.el | 9 +++++++++ 2 files changed, 23 insertions(+) create mode 100644 gists/narrow-from-to-point.el 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)))