unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* find the file name of the running function programatically
@ 2008-08-28  5:26 Xah
  2008-08-28  7:54 ` Chat
  2008-08-28 11:47 ` John Paul Wallington
  0 siblings, 2 replies; 3+ messages in thread
From: Xah @ 2008-08-28  5:26 UTC (permalink / raw)
  To: help-gnu-emacs

how to find out the file name of the running function
programmatically?

for example, i have:

(defun command-frequency-write-file (file-name)
  (with-temp-file file-name
    (insert (command-frequency)))
  (with-temp-message (format "Wrote %s" file-name)))

i want to change this function so that it doesn't require any arg.
The file name will just be in the same dir but with a “.txt” suffix.

Thanks.

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: find the file name of the running function programatically
  2008-08-28  5:26 find the file name of the running function programatically Xah
@ 2008-08-28  7:54 ` Chat
  2008-08-28 11:47 ` John Paul Wallington
  1 sibling, 0 replies; 3+ messages in thread
From: Chat @ 2008-08-28  7:54 UTC (permalink / raw)
  To: help-gnu-emacs

Xah <xahlee@gmail.com> writes:

> how to find out the file name of the running function
> programmatically?
>
> for example, i have:
>
> (defun command-frequency-write-file (file-name)
>   (with-temp-file file-name
>     (insert (command-frequency)))
>   (with-temp-message (format "Wrote %s" file-name)))
>
> i want to change this function so that it doesn't require any arg.
> The file name will just be in the same dir but with a “.txt” suffix.
>
> Thanks.
>
>   Xah
> ∑ http://xahlee.org/
>
> ☄
Doesn't look like there is a simple function that will work in all versions.
However, given that not all libraries reside on writable file systens, doesn't
it make sense to store it somewhere under HOME?

Chat



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: find the file name of the running function programatically
  2008-08-28  5:26 find the file name of the running function programatically Xah
  2008-08-28  7:54 ` Chat
@ 2008-08-28 11:47 ` John Paul Wallington
  1 sibling, 0 replies; 3+ messages in thread
From: John Paul Wallington @ 2008-08-28 11:47 UTC (permalink / raw)
  To: help-gnu-emacs

Xah <xahlee@gmail.com> writes:

> how to find out the file name of the running function
> programmatically?

You can find out the filename of the file in which a function
was defined, if any, using `symbol-file'.

You might work out the running function by looking at what
`backtrace-frame' returns.  If you are interested instead in the running
command rather than function then you probably want to use the variables
`last-command' or `this-command'.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-08-28 11:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-28  5:26 find the file name of the running function programatically Xah
2008-08-28  7:54 ` Chat
2008-08-28 11:47 ` John Paul Wallington

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).