help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get current buffer name from command line?


From: Marcin Borkowski
Subject: Re: Get current buffer name from command line?
Date: Wed, 13 Aug 2014 22:49:26 +0200

Dnia 2014-08-13, o godz. 08:23:34
Stefan Monnier <address@hidden> napisaƂ(a):

> > this is not something I really need, but I was wondering whether I
> > can get the (name of) the current buffer from command line?
> 
> I think your notion of "current buffer" is not the same as
> `current-buffer'.  You probably want "the buffer displayed in the
> `selected-window'".
> 
> Of course, the selected-window may also be temporarily changed, but
> I think
> 
>    emacsclient -e "(window-buffer (selected-window))"
> 
> will more often give you what you're looking for.

Thanks!  A quick test showed that indeed, this is the case.  But I
have two questions now:

1. So what exactly is "current-buffer"?  Or, more precisely, why
(progn (kill-buffer) (current-buffer))
didn't work?

2. Why "more often"?  Is it possible that it won't?  To be more
precise on my requirements: I thought about writing a script (to be
put into cron) which would gather data on what I'm doing at various
times so that I can measure time spent on different activities.  Since
most of my computer time is spent in Emacs, this would be an important
part of it.  From the docstring of selected-window, it seems to be
exactly what I'm looking for.  Still, the words "more often" made me a
bit suspicious;).

>         Stefan

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University



reply via email to

[Prev in Thread] Current Thread [Next in Thread]