;;; iterate-files.el --- iterate directory files -*- lexical-binding: t -*- ;; ;; Author: Emanuel Berg ;; Created: 2020-03-16 ;; Keywords: files ;; License: GPL3+ ;; URL: https://dataswamp.org/~incal/emacs-init/iterate-files.el ;; Version: 2.2.3 ;; ;;; Commentary: ;; ;; Iterate the contents of the directory of the current buffer file. ;; ;;; Code: (defun dir-common-files (&optional dir) (or dir (setq dir default-directory)) "List DIR files when used, if not use `default-directory'." (directory-files dir nil "[^.]\\|\\.\\.\\.") ) (defun dir-next-file () "Go to the next file in the working directory. Go to the first one if uninitiated, or at the end." (interactive) (let*((files (dir-common-files)) (this-file-forward (member (buffer-name) files)) ) (if this-file-forward (find-file (if (= 1 (length this-file-forward)) (car files) (cadr this-file-forward) )) (find-file (car files)) ))) (provide 'iterate-files) ;;; iterate-files.el ends here