;;; -*- lexical-binding: t -*- ;;; ;;; this file: ;;; http://user.it.uu.se/~embe8573/emacs-init/my-random.el ;;; https://dataswamp.org/~incal/emacs-init/my-random.el (defun do-whatever-return (fun &rest args) (let ((point (point)) (buffer (current-buffer)) ) (apply fun args) (when (bufferp buffer) (switch-to-buffer buffer) (goto-char point) ))) ;; (do-whatever-return #'switch-to-buffer "*Help*") (defun switch-buffer-random () (let*((buffers (buffer-list)) (num-bufs (length buffers)) (rand-buf-num (random (1- num-bufs))) (buf (nth rand-buf-num buffers)) ) (when (bufferp buf) (switch-to-buffer buf)) )) ;; (switch-buffer-random) (defun move-point-random () (let*((min (point-min)) (max (point-max)) (random-char (+ min (random (- max min)))) ) (goto-char random-char) (message "point in %s: %d" (current-buffer) (point)) )) ;; (move-point-random) (defun switch-buffer-move-point-random () (switch-buffer-random) (move-point-random) ) ;; (switch-buffer-move-point-random) ;; (advice-add 'switch-buffer-move-point-random :around #'do-whatever-return) ;; (switch-buffer-move-point-random) ;; ;; (advice-remove 'switch-buffer-move-point-random #'do-whatever-return) ;; (switch-buffer-move-point-random)