unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Marcin Borkowski <mbork@wmi.amu.edu.pl>
To: help-gnu-emacs@gnu.org
Subject: Re: Get current buffer name from command line?
Date: Wed, 13 Aug 2014 22:49:26 +0200	[thread overview]
Message-ID: <20140813224926.064de008@aga-netbook> (raw)
In-Reply-To: <jwvmwb8r35f.fsf-monnier+gmane.emacs.help@gnu.org>

Dnia 2014-08-13, o godz. 08:23:34
Stefan Monnier <monnier@iro.umontreal.ca> 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	other threads:[~2014-08-13 20:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-13 11:32 Get current buffer name from command line? Marcin Borkowski
2014-08-13 12:23 ` Stefan Monnier
2014-08-13 20:49   ` Marcin Borkowski [this message]
2014-08-13 21:40     ` Stefan Monnier
2014-08-13 22:08       ` Marcin Borkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140813224926.064de008@aga-netbook \
    --to=mbork@wmi.amu.edu.pl \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).