From: Michael Heerdegen <michael_heerdegen@web.de>
To: Hongxu Chen <leftcopy.chx@gmail.com>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: resolve rename-buffer conflicts
Date: Sun, 16 Jun 2013 20:29:19 +0200 [thread overview]
Message-ID: <87fvwhykn4.fsf@web.de> (raw)
In-Reply-To: <87hah131ab.fsf@gmail.com> (Hongxu Chen's message of "Fri, 14 Jun 2013 09:54:04 +0800")
Hi Hongxu,
> ,----------[ rename-this-file ]
> | (defun rename-this-file (new-name)
> | "Renames both current buffer and file it's visiting to NEW-NAME."
> | (interactive "sNew name: ")
> | (let ((name (buffer-name))
> | (filename (buffer-file-name)))
> | (unless filename
> | (error "Buffer '%s' is not visiting a file!" name))
> | (if (get-buffer new-name)
> | (message "A buffer named '%s' already exists!" new-name)
> | (progn
> | (rename-file filename new-name t)
> | (rename-buffer new-name t)
> | (set-visited-file-name new-name)
> | (set-buffer-modified-p nil)))))
> `----------
> A buffer named 'test.cpp' already exists!
>
> So Why it fails for the snippet above?
I tested your code in a recent build of trunk, and it works fine here.
Can you reproduce your problem with emacs -Q? Which Emacs version are
you using? Maybe try to follow what's happening with the debugger. You
probably want to (debug-on-entry 'rename-this-file). Load file sources
to avoid debugging compiled code.
Regards,
Michael.
next prev parent reply other threads:[~2013-06-16 18:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-14 1:54 resolve rename-buffer conflicts Hongxu Chen
2013-06-16 18:29 ` Michael Heerdegen [this message]
2013-06-17 0:07 ` Hongxu Chen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fvwhykn4.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=help-gnu-emacs@gnu.org \
--cc=leftcopy.chx@gmail.com \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.