From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rami A Newsgroups: gmane.emacs.help Subject: Waiting on compilation to finish before executing another function Date: Thu, 15 Aug 2013 10:36:21 -0700 (PDT) Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1376588417 28119 80.91.229.3 (15 Aug 2013 17:40:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 15 Aug 2013 17:40:17 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Aug 15 19:40:21 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VA1Wz-0006mx-Q4 for geh-help-gnu-emacs@m.gmane.org; Thu, 15 Aug 2013 19:40:17 +0200 Original-Received: from localhost ([::1]:54719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VA1Wz-0001LW-FA for geh-help-gnu-emacs@m.gmane.org; Thu, 15 Aug 2013 13:40:17 -0400 X-Received: by 10.224.173.4 with SMTP id n4mr17057714qaz.3.1376588182397; Thu, 15 Aug 2013 10:36:22 -0700 (PDT) X-Received: by 10.50.4.99 with SMTP id j3mr202715igj.6.1376588182265; Thu, 15 Aug 2013 10:36:22 -0700 (PDT) Original-Path: usenet.stanford.edu!fx3no2592172qab.0!news-out.google.com!he10ni1979qab.0!nntp.google.com!fx3no2592165qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=148.87.19.198; posting-account=HZ4YzgoAAABkTSCruZ7Bs4hufjlOUmBF Original-NNTP-Posting-Host: 148.87.19.198 User-Agent: G2/1.0 Injection-Date: Thu, 15 Aug 2013 17:36:22 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:200639 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:92906 Archived-At: Greetings, I am using compile to pulling new files from source tree using mercurial "hg pull". I am performing a save of all buffers before the pull and would like to "refresh all opened buffers" after the compilation "pulling" finishes. I tried experimenting with compilation-finish-functions but found out that the functions added to the list will be executed after "every" compilation. Since I use compile to search IDs "gid" I don't want to refresh opened files on every search. How can I wait on compilation to finish before refreshing opened files "only" while inside a command and not on every compile outside of the command. Here is the code: ; From http://www.emacswiki.org/emacs/CompileCommand (defun compile-pkg (&optional command startdir) "Compile a package, moving up to the parent directory containing configure.ac, if it exists. Start in startdir if defined, else start in the current directory." (interactive) (let ((dirname) (dir-buffer nil)) (setq startdir (expand-file-name (if startdir startdir "."))) (setq command (if command command compile-command)) (setq dirname (upward-find-file "Makefile" startdir)) ; (setq dirname (if dirname dirname (upward-find-file "Makefile" startdir))) ; (setq dirname (if dirname dirname (expand-file-name "."))) ; We've now worked out where to start. Now we need to worry about ; calling compile in the right directory (save-excursion (setq dir-buffer (find-file-noselect dirname)) (set-buffer dir-buffer) (compile command) (kill-buffer dir-buffer) ))) (defun upward-find-file (filename &optional startdir) "Move up directories until we find a certain filename. If we manage to find it, return the containing directory. Else if we get to the toplevel directory and still can't find it, return nil. Start at startdir or . if startdir not given" (let ((dirname (expand-file-name (if startdir startdir "."))) (found nil) ; found is set as a flag to leave loop if we find it (top nil)) ; top is set when we get ; to / so that we only check it once ; While we've neither been at the top last time nor have we found ; the file. (while (not (or found top)) ; If we're at / set top flag. (if (string= (expand-file-name dirname) "/") (setq top t)) ; Check for the file (if (file-exists-p (expand-file-name filename dirname)) (setq found t) ; If not, move up a directory (setq dirname (expand-file-name ".." dirname)))) ; return statement (if found (concat dirname "/") nil))) (defun compile-hgpull () (interactive) (save-all-buffers) (compile-pkg "/import/ftap-rust1/tools/bin/hg pull -u") ; if (compile finished) -> (revert-all-buffers) ) (global-set-key [f1] 'compile-hgpull)