unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Nordlöw <per.nordlow@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Post-Advice for file-move (rename-file()) but not upon save-buffer
Date: 6 May 2007 01:57:59 -0700	[thread overview]
Message-ID: <1178441879.660722.212060@p77g2000hsh.googlegroups.com> (raw)

Hey there again, Emacs Hackers!

I want to make Emacs run a command every time a file is moved/renamed
(from Emacs)

Here is the essential part of my code:

(defadvice rename-file (after update-c-includes activate)
  "Update C include statements upon rename of file."
  (let ((file (file-name-nondirectory (ad-get-arg 0)))
	(newname (file-name-nondirectory (ad-get-arg 1))))
    (if (or (file-is-C-header file)
	    (file-is-C-header newname))
	(if (y-or-n-p "Update C,C++ #includes accordingly ")
	    ;; TODO: We need to strip parts of the path from file and newname
	    (c-rename-includes file newname))
      )))

This works as intended for rename-file but it also gets called when I
save a buffer to file, using save-buffer(), which is *not* what I
want. I guess it's because save-file() is implemented using rename-
file().

How can I make it run *solely* when I rename a file?


Thanks in advance,
Nordlöw

             reply	other threads:[~2007-05-06  8:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-06  8:57 Nordlöw [this message]
2007-05-06 11:00 ` Post-Advice for file-move (rename-file()) but not upon save-buffer Tim X
2007-05-16  3:40 ` Kevin Rodgers

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=1178441879.660722.212060@p77g2000hsh.googlegroups.com \
    --to=per.nordlow@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).