;;; present.el --- Present using Emacs buffer states -*- lexical-binding: t; -*- ;; Copyright (C) 2023 Philip Kaludercic ;; Author: Philip Kaludercic ;; Keywords: frames ;; Time-stamp: <2023-06-27 10:32:35 philip> ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; Record and replay a sequence of frame configurations. ;; Example configuration: ;; ;; (global-set-key (kbd "") #'present-previous) ;; (global-set-key (kbd "") #'present-next) ;;; Code: (defvar present-list '() "List of window configurations to iterate in order.") (defun present-prepend-state () "Prepend the current frame state to `present-list'." (interactive) (push (current-frame-configuration) present-list) (message "Extended to %d elements..." (length present-list))) (defun present-append-state () "Prepend the current frame state to `present-list'." (interactive) (setf present-list (nconc present-list (list (current-frame-configuration)))) (message "Extended to %d elements..." (length present-list))) (defun present-next () "Display the window configuration following the previous selection." (interactive) (unless present-list (user-error "Empty list")) (let ((head (pop present-list))) (push head (cdr (last present-list))) (set-frame-configuration head t))) (defun present-previous () "Display the window configuration prior to the previous selection." (interactive) (unless present-list (user-error "Empty list")) ;; Move back two elements, and then move ahead by one. (setf present-list (append (last present-list 2) (nbutlast present-list 2))) (present-next)) (defun present-clear () "Reset the list of window configurations." (interactive) (when (yes-or-no-p "Are you sure you want to reset the list?") (setf present-list nil) (message "Reset `present-list'."))) (defun present-reverse () "Reverse the order of frame configurations in `present-list'." (interactive) (if (null present-list) (message "The list `present-list' was already empty.") (setf present-list (nreverse present-list)) (message "Reset `present-list'."))) (provide 'present) ;;; present.el ends here