From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: lee Newsgroups: gmane.emacs.help Subject: replacing a function with another one Date: Sat, 08 Mar 2014 20:43:36 +0100 Organization: my virtual residence Message-ID: <87vbvofsi6.fsf@yun.yagibdah.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1394307841 23340 80.91.229.3 (8 Mar 2014 19:44:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 8 Mar 2014 19:44:01 +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 08 20:44:09 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 1WMNAH-0004p1-9m for geh-help-gnu-emacs@m.gmane.org; Sat, 08 Mar 2014 20:44:09 +0100 Original-Received: from localhost ([::1]:41628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMNAG-0000Fi-P0 for geh-help-gnu-emacs@m.gmane.org; Sat, 08 Mar 2014 14:44:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMNA1-0000Ek-Fu for help-gnu-emacs@gnu.org; Sat, 08 Mar 2014 14:43:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMN9v-0001a9-H3 for help-gnu-emacs@gnu.org; Sat, 08 Mar 2014 14:43:53 -0500 Original-Received: from client-194-42-186-216.muenet.net ([194.42.186.216]:52236 helo=yun.yagibdah.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMN9v-0001Zq-8L for help-gnu-emacs@gnu.org; Sat, 08 Mar 2014 14:43:47 -0500 Original-Received: from lee by yun.yagibdah.de with local (Exim 4.80.1) (envelope-from ) id 1WMN9s-0004Ta-VY for help-gnu-emacs@gnu.org; Sat, 08 Mar 2014 20:43:44 +0100 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:96322 Archived-At: Hi, is there a way to replace a function with another one other than re-defining the original function? Using (defalias) doesn=C2=B4t seem to work for this. The background is that I need a modified version of (hi-lock-set-file-patterns): The hi-lock-mode has different variables for highlighting patterns with which it distinguishes between patterns loaded from the file the buffer is visiting and patterns added through actions of the user. These two variables, `hi-lock-file-patterns=C2=B4 and `hi-lock-interactive-patterns=C2=B4, are independent of each other. When I visit a file with highlighting-patterns, the patterns are read and applied and *not* added to the `hi-lock-interactive-patterns=C2=B4 variable. Consequently, when writing the current patterns to the buffer, only those patterns are written which have been "recently" defined by actions of the user. To add new patterns, I am using wrapper functions, because I want to use particular faces for the highlighting without needing to type them in all the time. When a new pattern is added, the wrapper functions remove all patterns that have already been written to the buffer. Then they use (hi-lock-write-interactive-patterns) to put them back. That way, I don=C2=B4t need to worry whether patterns I added are saved or not. Since (hi-lock-write-interactive-patterns) writes only the patterns from the `hi-lock-interactive-patterns=C2=B4 variable to the buffer, all patterns that were already there are forgotten. To avoid this, I have a modified version of (hi-lock-set-file-patterns). This version assigns the patterns read from the buffer to `hi-lock-interactive-patterns=C2=B4 so that they aren=C2=B4t forgotten anym= ore. The only way I have found to make the hi-lock-mode --- without modifying the mode itself --- use my modified version of (hi-lock-set-file-patterns) is to re-define this function. Is this a way in which we are /supposed/ to customise emacs? Should I rather make a copy of the whole hi-lock-mode and modify it as I like? I=C2=B4d rather not do that (though I might have to because I want a number of other things as well) because the original may receive fixes and updates which would become difficult to keep track of. --=20 Knowledge is volatile and fluid. Software is power.