Elisp: Save narrow-to-region
Emacs has a
narrow-to-region
command.
〔see Emacs: Narrow to Region〕
The
narrow-to-region
is also very useful
in elisp code.
However, when you command is done, you should return to the narrow region state of the user before
the command was called.
Emacs lisp provides
save-restriction
for this purpose.
save-restriction
-
(save-restriction &rest BODY)
Execute BODY, then restoring any
narrow-to-region
in BODY.;; preserve user's narrow-to-region ;; useful when you want to narrow-to-region in your code to work in just that region (save-restriction (narrow-to-region pos1 pos2) ;; lisp code here )
Emacs Lisp, text processing functions
- Elisp: Cursor Position Functions
- Elisp: Move Cursor
- Elisp: Text Editing Functions
- Elisp: Search Text
- Elisp: Find Replace Text in Buffer
- Elisp: Mark, Region, Active Region
- Elisp: Cut Copy Paste, kill-ring
- Elisp: Get Buffer String
- Elisp: Functions on Line
- Elisp: thing-at-point
- Elisp: Get Text Block 🚀
- Elisp: Save narrow-to-region