/ Published in: Emacs Lisp
An answer to the 'cycle-special-files exercise listed here: http://stackoverflow.com/questions/41522/tips-for-learning-elisp/59589#59589
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(defvar cycle-special-files-file-list '("~/.mailrc" "~/personal/.phones""~/public_html/home.html")) (defun cycle-special-files () "cycle through the set of files specified in cycle-special-files-file-list." (interactive) (let* ((cur-buffer (current-buffer)) (buff-list (mapcar (lambda (f) (find-file-noselect (file-truename f))) cycle-special-files-file-list)) (2x-buff-list (append buff-list buff-list)) (default (car buff-list)) (res (memq cur-buffer 2x-buff-list))) ;; find buffer after the current one (if (and res (cdr res)) (setq default (cadr res))) ;; bury the buffer if it's one of the special list (when (member cur-buffer buff-list) (bury-buffer cur-buffer)) (when default (switch-to-buffer default))))
URL: http://stackoverflow.com/questions/41522/tips-for-learning-elisp/59589#59589