+; A set of utilities on buffers in general.
+(defun nej-refresh-unmodified-buffer (&optional buf)
+ "refresh a buffer from disk if not modified in ram"
+ (let ((target (if (null buf) (current-buffer) buf)))
+ (when (not (verify-visited-file-modtime target))
+ ; The file has been modified on disk.
+ (let ((filename buffer-file-name))
+ ; The buffer has not been modified since loading:
+ (find-file filename)))))
+(defun nej-for-buffers-inside-directory (directory buf-cmd)
+ "Execute a command on all the buffers visiting files under a directory."
+ (interactive "Ddirectory: \nabuffer command: ")
+ (let ((absdir (expand-file-name directory)))
+ (let ((bufname (buffer-file-name buf)))
+ (when (and (not (null bufname)) (string-prefix-p absdir bufname))
+ (funcall buf-cmd buf))))
+;; Initialize this module: