unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Post-Advice for file-move (rename-file()) but not upon save-buffer
@ 2007-05-06  8:57 Nordlöw
  2007-05-06 11:00 ` Tim X
  2007-05-16  3:40 ` Kevin Rodgers
  0 siblings, 2 replies; 3+ messages in thread
From: Nordlöw @ 2007-05-06  8:57 UTC (permalink / raw)
  To: help-gnu-emacs

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

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

end of thread, other threads:[~2007-05-16  3:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-06  8:57 Post-Advice for file-move (rename-file()) but not upon save-buffer Nordlöw
2007-05-06 11:00 ` Tim X
2007-05-16  3:40 ` Kevin Rodgers

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