unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "qingwuking@gmail.com" <qingwuking@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to get current filename and absolute path of the file in emacs?
Date: 16 Apr 2007 02:35:32 -0700	[thread overview]
Message-ID: <1176716132.597633.77330@d57g2000hsg.googlegroups.com> (raw)
In-Reply-To: <mailman.2113.1176698595.7795.help-gnu-emacs@gnu.org>

On 4月16日, 下午12时30分, Eric Hanchrow <off...@blarg.net> wrote:
> >>>>> "QinGW" == QinGW  <dealo...@21cn.com> writes:
>
>     QinGW> I want to put current filename and file path to clipboard
>     QinGW> and I cant get it by short key.how can I implement it?
>     QinGW> Thank a lot.
>
> This is what I use:
>
> (setq x-select-enable-clipboard t)
>
> (defun copy-buffer-file-name (use-backslashes)
>   "Puts the file name of the current buffer (or the current directory,
> if the buffer isn't visiting a file) onto the kill ring, so that it
> can be retrieved with \\[yank], or by another program.  With argument,
> uses backslashes instead of forward slashes."
>   (interactive "P")
>   (let ((fn (subst-char-in-string
>              ?/
>              (if use-backslashes ?\\ ?/)
>              (or
>               (buffer-file-name (current-buffer))
>               ;; Perhaps the buffer isn't visiting a file at all.  In
>               ;; that case, let's return the directory.
>               (expand-file-name default-directory)))))
>     (when (null fn)
>       (error "Buffer doesn't appear to be associated with any file or directory."))
>     (kill-new fn)
>     (message "%s" fn)
>     fn))
>
> (global-set-key (kbd "<f8>") 'copy-buffer-file-name)
> --

Thanks very much.

      parent reply	other threads:[~2007-04-16  9:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-16  3:37 How to get current filename and absolute path of the file in emacs? QinGW
2007-04-16  4:30 ` Eric Hanchrow
2007-04-16 19:36   ` Eli Zaretskii
2007-04-16 20:09     ` Eric Hanchrow
2007-04-16  5:07 ` Pascal Bourguignon
2007-04-16  8:57   ` Matthew Flaschen
2007-04-16  9:32   ` qingwuking
2007-04-16  9:33   ` qingwuking
     [not found]   ` <mailman.2121.1176714130.7795.help-gnu-emacs@gnu.org>
2007-04-16 11:39     ` Pascal Bourguignon
     [not found] ` <mailman.2113.1176698595.7795.help-gnu-emacs@gnu.org>
2007-04-16  9:35   ` qingwuking [this message]

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=1176716132.597633.77330@d57g2000hsg.googlegroups.com \
    --to=qingwuking@gmail.com \
    --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).