From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Robert Thorpe" Newsgroups: gmane.emacs.help Subject: Re: Refontifying after revert in hi-lock-mode Date: 23 Nov 2006 09:57:20 -0800 Organization: http://groups.google.com Message-ID: <1164304640.318926.304200@h54g2000cwb.googlegroups.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: sea.gmane.org 1164390623 26345 80.91.229.2 (24 Nov 2006 17:50:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 24 Nov 2006 17:50:23 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 24 18:50:20 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GnfBp-0000UC-KE for geh-help-gnu-emacs@m.gmane.org; Fri, 24 Nov 2006 18:50:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GnfBo-0005eA-Ls for geh-help-gnu-emacs@m.gmane.org; Fri, 24 Nov 2006 12:50:16 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!h54g2000cwb.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 49 Original-NNTP-Posting-Host: 213.94.228.210 Original-X-Trace: posting.google.com 1164304645 20606 127.0.0.1 (23 Nov 2006 17:57:25 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 23 Nov 2006 17:57:25 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.0 EMF3ASPROXY03 Complaints-To: groups-abuse@google.com Injection-Info: h54g2000cwb.googlegroups.com; posting-host=213.94.228.210; posting-account=hWoAPxMAAAAnBKSBz1ZivwUPPjEuve7bvVCHZQ8rhrluPfwcBJd92w Original-Xref: shelby.stanford.edu gnu.emacs.help:143304 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:38921 Archived-At: Denis Bueno wrote: > I would like a synergy between auto-revert-tail-mode and hi-lock-mode. > I frequently tail log files, and would like live updates of > highlighted terms in those log files. In my Emacs (GNU Emacs 22.0.90.2 > (powerpc-apple-darwin8.8.0, Carbon Version 1.6.0) of 2006-11-11 on > ford.local), after a revert performed by auto-revert-tail-mode, I > would like any new terms matching active regexps to be highlighted. > But they aren't. > > I tried the following hook, it my .emacs, and I'm not quite sure why it fails: > > ,---- > | ;; In auto-revert mode, after reverting, if font-lock is turned on, > | ;; fontify the buffer. I intend for this to re-fontify my buffers when they > | ;; revert and I'm using hi-lock-mode. > | (require 'autorevert) > | (add-hook 'after-revert-hook > | (lambda () > | (if font-lock-mode > | (progn > | (message "Re-fontifying buffer...") > | (font-lock-fontify-buffer))) > | (message "dbueno's after-revert-hook finished."))) > `---- > > I looked into autorevert.el to verify that auto-revert-tail-mode > indeed uses `revert-buffer', so, I think that hook should be executed. > I figured that maybe there was a `revert-buffer-function' in use when > `revert-buffer' is called, which (as the doc for `revert-buffer' says: > > "If the value of `revert-buffer-function' is non-nil, it is called to > do all the work for this command. Otherwise, the hooks > `before-revert-hook' and `after-revert-hook' are run at the beginning > and the end, and if `revert-buffer-insert-file-contents-function' is > non-nil, it is called instead of rereading visited file contents." > > Does anyone know why my hook wouldn't run? and if so, how I can fix it? Looks like it should to me. I think you need to check that it isn't. Instead of emitting a message at the end that could be wiped over by a subsequent message try setting a variable, or look in the *Messages* buffer. In the bit starting (if font-lock-mode... note The variable font-lock-mode is strange, even if you have global-font-lock-mode set to t the global variable font-lock-mode will stay nil. So the code will work if you're in the right context when it is executed, but not otherwise.