[Partial answer: how to get the information and turn it into a string. What it does not do (yet?) is add it to the modeline; but I believe (untested and therefore maybe baseless) that this is fundamentally sound]
The following function can be used e.g. in the find-file-hook
to retrieve the information needed and turn it into a string - it only does it for mtime
, but the others can be added without much difficulty (the only problem is that they are relatively long strings, so you may run out of space in the mode line):
(defun ndk/file-mtime ()
(let* ((fname (buffer-file-name))
(mtime (file-attribute-modification-time
(file-attributes fname))))
(when mtime
(format-time-string "%Y-%m-%dT%H:%M:%S" mtime))))
What remains to be done is to write a function to setq the variable mode-line-format
to something that includes that information (TBD) - setting that variable makes it buffer-local which is what you want - and then adding the resulting function to find-file-hook
. There is a section in the Emacs Lisp manual (C-h i g(elisp)mode line format
) that explains how to set the variable, but it is somewhat complicated and I have not had the time to implement that. Feel free to do so and either submit an edit to this answer, or provide your own answer to complete this one.
ls
with the applicable switch(es) and converting the output to your human readable format? And, does that need to happen three individual times to get each of the the proposed values, or can all three values be extracted with a sole call usingls
with the appropriate switch(es)? [... thinking about efficiency here ...] And, do you really want Emacs to perform those calls every time you type a key or move the cursor, or when you are scrolling through the text / screen (up/down)...?file-attributes
and related functions can be used to get that information. IIUC, the modeline changes only when first opening the file - no need to change it on every key press or cursor motion. When the buffer is saved, the file will get a new mod/access time and next time it is opened, the new values will be shown. The access time may be indeed useless: it will show pretty much the current time, since emacs just accessed it, unless there is another hook that can be run fromfind-file
before the file is opened. My (partial) answer just deals with modtime.