From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: lee Newsgroups: gmane.emacs.help Subject: Re: replacing a function with another one Date: Sat, 15 Mar 2014 21:22:24 +0100 Organization: my virtual residence Message-ID: <87mwgrus8v.fsf@yun.yagibdah.de> References: <87vbvofsi6.fsf@yun.yagibdah.de> <87eh27iml1.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1394918108 25373 80.91.229.3 (15 Mar 2014 21:15:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Mar 2014 21:15:08 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Mar 15 22:15:16 2014 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 1WOvvI-0004Fz-GZ for geh-help-gnu-emacs@m.gmane.org; Sat, 15 Mar 2014 22:15:16 +0100 Original-Received: from localhost ([::1]:51203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOvvH-0006Vy-Rl for geh-help-gnu-emacs@m.gmane.org; Sat, 15 Mar 2014 17:15:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOvuo-0006KB-N7 for help-gnu-emacs@gnu.org; Sat, 15 Mar 2014 17:14:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOvue-0002lm-78 for help-gnu-emacs@gnu.org; Sat, 15 Mar 2014 17:14:46 -0400 Original-Received: from client-194-42-186-216.muenet.net ([194.42.186.216]:36520 helo=yun.yagibdah.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOvud-0002jY-Ms for help-gnu-emacs@gnu.org; Sat, 15 Mar 2014 17:14:36 -0400 Original-Received: from lee by yun.yagibdah.de with local (Exim 4.80.1) (envelope-from ) id 1WOvuT-0005kC-Pu for help-gnu-emacs@gnu.org; Sat, 15 Mar 2014 22:14:25 +0100 In-Reply-To: <87eh27iml1.fsf@gmail.com> (Jambunathan K.'s message of "Wed, 12 Mar 2014 18:46:26 +0530") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Mail-Followup-To: help-gnu-emacs@gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 194.42.186.216 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:96521 Archived-At: Jambunathan K writes: > Hello OP, > > It seems you don't mind digging in to elisp code. Well, I have to; It`s a great source to learn from :) > ---------------------------------------------------------------- > > (add-hook 'find-file-hook 'hi-lock-find-file-hook) > (add-hook 'after-save-hook 'hi-lock-file-save-patterns) > > (defun hi-lock-find-file-hook () > (when (and (boundp 'hi-lock-patterns-file) > (file-readable-p hi-lock-patterns-file)) > (let ((patterns (with-current-buffer (find-file-noselect hi-lock-patterns-file) > (goto-char (point-min)) > (prog1 (ignore-errors (read (current-buffer))) > (kill-buffer))))) > (setq hi-lock-interactive-patterns patterns) > (font-lock-add-keywords nil hi-lock-interactive-patterns t)))) > > (defun hi-lock-file-save-patterns () > (interactive) > (when (boundp 'hi-lock-patterns-file) > (let ((patterns (append hi-lock-file-patterns hi-lock-interactive-patterns))) > (with-current-buffer (find-file-noselect hi-lock-patterns-file) > (erase-buffer) > (insert (pp-to-string patterns)) > (save-buffer 0))))) > > ---------------------------------------------------------------- I see what it does, thank you :) I think I can use some of this when I make an addition to hi-lock.el. -- Knowledge is volatile and fluid. Software is power.