From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: Get current buffer name from command line? Date: Wed, 13 Aug 2014 22:49:26 +0200 Organization: WMI UAM Message-ID: <20140813224926.064de008@aga-netbook> References: <20140813133234.6805a417@aga-netbook> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1407963000 27276 80.91.229.3 (13 Aug 2014 20:50:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 13 Aug 2014 20:50:00 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 13 22:49:55 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XHfUZ-0006FN-Ej for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Aug 2014 22:49:55 +0200 Original-Received: from localhost ([::1]:50165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHfUZ-0004AX-3Z for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Aug 2014 16:49:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHfUH-00049q-ML for help-gnu-emacs@gnu.org; Wed, 13 Aug 2014 16:49:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHfUC-0000ax-0I for help-gnu-emacs@gnu.org; Wed, 13 Aug 2014 16:49:37 -0400 Original-Received: from msg.wmi.amu.edu.pl ([150.254.78.50]:57538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHfUB-0000ap-R1 for help-gnu-emacs@gnu.org; Wed, 13 Aug 2014 16:49:31 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id 3682845791 for ; Wed, 13 Aug 2014 22:49:28 +0200 (CEST) Original-Received: from msg.wmi.amu.edu.pl ([127.0.0.1]) by localhost (msg.wmi.amu.edu.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IY39N3BuzIp0 for ; Wed, 13 Aug 2014 22:49:28 +0200 (CEST) Original-Received: from aga-netbook (unknown [185.13.171.31]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id 0F1FA45761 for ; Wed, 13 Aug 2014 22:49:27 +0200 (CEST) In-Reply-To: X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.20; i686-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 150.254.78.50 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:99198 Archived-At: Dnia 2014-08-13, o godz. 08:23:34 Stefan Monnier napisa=C5=82(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? >=20 > I think your notion of "current buffer" is not the same as > `current-buffer'. You probably want "the buffer displayed in the > `selected-window'". >=20 > Of course, the selected-window may also be temporarily changed, but > I think >=20 > emacsclient -e "(window-buffer (selected-window))" >=20 > 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, --=20 Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Adam Mickiewicz University