Add functions to narrow from or to point

This commit is contained in:
Bram Schoenmakers 2023-09-08 13:28:01 +02:00
parent cb4c371e5c
commit b6d0f96a40
2 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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)))