Commits

nejucomo committed d0b4b3b

Collect buffer-related commands into nej-for-buffers.el.

  • Participants
  • Parent commits 6cd7658

Comments (0)

Files changed (2)

File nej/nej-buffer.el

+;; Usage:
+;
+; 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"
+  (interactive)
+  (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:
+        (kill-buffer target)
+	; Now visit the file:
+        (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)))
+    (mapcar
+     (lambda (buf)
+       (let ((bufname (buffer-file-name buf)))
+         (when (and (not (null bufname)) (string-prefix-p absdir bufname))
+           (funcall buf-cmd buf))))
+     (buffer-list))))
+
+
+;; Initialize this module:
+(provide 'nej-buffer)
+
+

File nej/nej-for-buffers.el

-;; Usage:
-;
-; (require 'nej-for-buffers)
-
-
-(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)))
-    (mapcar
-     (lambda (buf)
-       (let ((bufname (buffer-file-name buf)))
-         (when (and (not (null bufname)) (string-prefix-p absdir bufname))
-           (funcall buf-cmd buf))))
-     (buffer-list))))
-
-
-;; Initialize this module:
-(provide 'nej-for-buffers)