AI is problematic, but the sheer convenience of it has grabbed my attention. For tweaking my GNU/Linux system, AI summaries of Google searches come in a few seconds, and they sometimes save hours of research. It is helpful that low grade links to sources are often provided. I balk, however, at the damaging infrastructure involved.
A recent adventure has been developing a useful emacs lisp tool to change the metadata time stamps of a file from emacs' Time-stamps, when they exist.
Today I realized I had copied files from another system without specifying to save file metadata. Could I set the file times of files with timestamps using the "Time-stamp: < >" utility in Emacs? I searched, and, I must freely admit, I asked for more info from the AI helper of Google Search. After about 7 or more rounds of providing feedback about a regular expression that did not work, these functions were provided. Wow. The last two of these is probably sufficient for my needs. I will change the names.
[I have deleted all copies of these functions except the one that is installed in my init.el file. Probably this works. I have not used it for a few weeks.
(defun my/dired-set-times-from-stamps ()
"From Google AI summary session. This calls the function my/set-file-time-final. In Dired, sync system modification times for all marked files
based on the 'Created' or 'Time-stamp' lines inside them."
(interactive)
(let ((files (dired-get-marked-files))
(updated 0)
(skipped 0))
(dolist (file files)
;; Open the file in a buffer without switching to it
(with-current-buffer (find-file-noselect file)
(condition-case nil
(progn
;; Call your working 'within-the-file' function
(my/set-file-time-final)
;; Save the buffer to ensure metadata is flushed to disk
(save-buffer)
(setq updated (1+ updated)))
(error
(setq skipped (1+ skipped))))))
;; Refresh the Dired buffer so you see the new dates immediately
(revert-buffer)
(message "Batch complete: %d updated, %d skipped (no stamp found)." updated skipped)))
(with-eval-after-load 'dired
(define-key dired-mode-map (kbd "T") 'my/dired-set-times-from-stamps))
No comments:
Post a Comment