From 3083940611299ce8b5bf941f3c4a8384f6fbcd6e Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 7 Nov 2024 21:59:17 +0100 Subject: emacs: Add mm-rotate-left and mm-rotate-right --- .config/emacs/init.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index d53750e..bc29838 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -93,6 +93,18 @@ buffer suppressed." (message-log-max nil)) ,@body)) +(defun mm-rotate-left (n list) + "Rotate the elements of LIST N places to the left." + (declare (ftype (function (number (list t)) (list t))) + (pure t) (side-effect-free t)) + (append (nthcdr n list) (butlast list (- (length list) n)))) + +(defun mm-rotate-right (n list) + "Rotate the elements of LIST N places to the right." + (declare (ftype (function (number (list t)) (list t))) + (pure t) (side-effect-free t)) + (mm-rotate-left (- (length list) n) list)) + ;;; Silent Native Compilation -- cgit v1.2.3