branch: externals/pulsar
commit a335e525056c1f26f4bef65b0a236ba920de670f
Author: Protesilaos Stavrou <i...@protesilaos.com>
Commit: Protesilaos Stavrou <i...@protesilaos.com>

    Add commands to pulse+recenter
---
 pulsar.el | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/pulsar.el b/pulsar.el
index 04711e1fd4..0f040ef508 100644
--- a/pulsar.el
+++ b/pulsar.el
@@ -237,5 +237,33 @@ sets up the aforementioned hook."
       (advice-add fn :after #'pulsar--add-hook))
     (add-hook 'pulsar-after-function-hook #'pulsar-pulse-line))))
 
+;;;; Recentering commands
+
+(defmacro pulsar-recenter (name doc arg)
+  "Produce command to pulse and recenter.
+The symbol is NAME, DOC for the doc string, and ARG is passed to
+`recenter'."
+  (declare (indent defun))
+  `(defun ,name ()
+     ,doc
+     (interactive)
+     (recenter ,arg)
+     (pulsar-pulse-line)))
+
+(pulsar-recenter
+  pulsar-recenter-top
+  "Reposition point at the top of the window and pulse line."
+  0)
+
+(pulsar-recenter
+  pulsar-recenter-bottom
+  "Reposition point at the bottom of the window and pulse line."
+  -1)
+
+(pulsar-recenter
+  pulsar-recenter-middle
+  "Reposition point at the center of the window and pulse line."
+  nil)
+
 (provide 'pulsar)
 ;;; pulsar.el ends here

Reply via email to