From abad47f1c40e595779c376a1e936c1609be1cdf4 Mon Sep 17 00:00:00 2001 From: Lars Tveito Date: Sun, 31 Jan 2016 23:14:57 +0100 Subject: [PATCH] Add functions to pin/unpin the focused section --- focus.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/focus.el b/focus.el index e53d2b1..231b52f 100644 --- a/focus.el +++ b/focus.el @@ -196,6 +196,21 @@ default is overwritten. This function simply helps set the (thing (completing-read "Thing: " candidates))) (setq focus-current-thing (intern thing)))) +(defun focus-pin () + "Pin the focused section to its current location or the region, +if active." + (interactive) + (when focus-mode + (when (region-active-p) + (focus-move-overlays (region-beginning) (region-end))) + (remove-hook 'post-command-hook 'focus-move-focus t))) + +(defun focus-unpin () + "Unpin the focused section." + (interactive) + (when focus-mode + (add-hook 'post-command-hook 'focus-move-focus nil t))) + (defun focus-next-thing (&optional n) "Moves the point to the middle of the Nth next thing." (interactive "p")