Emacs buffer runtime

Is there any way to find out how long the buffer has been active in Emacs?

Mx list-buffers lists them, but there is no way to determine how long a buffer has existed.

+6
source share
3 answers

Yeah. But just because I wrote something in order to do just that. Well, I wrote this for myself, but have been using it for the last 3-4 years and cannot live without it now.

https://github.com/hardaker/elisp-buffer-timer/

+6
source

There is a much more convenient mode for listing buffers called ibuffer . One of the built-in mark commands assigned to the key . (period), is "Mark buffers older than ibuffer-old-time ", which is a custom variable, by default no more than 72 hours. ibuffer mode ibuffer included in the standard emacs-24 distribution.

Here is my .emacs snippet:

 (when (require 'ibuffer nil 'noerror) (define-key global-map "\Cx\Cb" 'ibuffer)) 
+2
source

I don’t think there is anything predefined to keep track of the buffer lifetime. But you can define your own function for this. The starting point is likely to be this hook. Note that get-buffer-create , which is often used to create a buffer, called it.

 ,---- | buffer-list-update-hook is a variable defined in `buffer.c'. | Its value is nil | | This variable can be risky when used as a file-local variable. | | Documentation: | Hook run when the buffer list changes. | Functions running this hook are `get-buffer-create', | `make-indirect-buffer', `rename-buffer', `kill-buffer', | and `bury-buffer-internal'. `---- 

On the other hand, as other messages are hinting, it is possible that you are here, this is the time during which this buffer is displayed, or the time since it was first displayed. This is again something else. If you need a buffer lifetime, then I think get-buffer-create is a good starting point.

+1
source

Source: https://habr.com/ru/post/958309/


All Articles