[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: replacing a function with another one

From: lee
Subject: Re: replacing a function with another one
Date: Wed, 12 Mar 2014 16:11:34 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Michael Heerdegen <address@hidden> writes:

> lee <address@hidden> writes:
>> > You can specify the pattern save file in the local variables
>> > section at the end of a file, but before a hi-lock mode specification,
>> > like here:
>> >
>> > Local Variables:
>> > hi-lock-patterns-file: "patterns.txt"
>> > mode: hi-lock
>> > End:
>> Apparently this doesn´t work because hi-lock-mode is called before the
>> variable is getting a value assigned.  See `hack-one-local-variable´ in
>> files.el --- IIUC, it calls the mode before it makes the variable.  It´s
>> hilarious ...
> No, that works well here, I've tested in detail what I had posted here,
> and it worked well.  AFAIK, local variable specifications are processed
> in the order as they appear textually in the file - I see that in the
> code.

What I´m referring to is not in which order they are created compared to
where they appear in the text.  When a specification of a variable is
encountered, what is in "mode:" will be called as a function if it ends
in "-mode".  Calling such function always seems to happen before the
variable is created.

> Maybe this is not the case in your Emacs version ... or you
> didn't use it in the intended way.

Yes, I´m using it in a different way.  The mode I´m doing this with is
not hi-lock-mode but lsl-mode.  lsl-mode requires hi-lock-mode because
it´s using it.

With "mode: hi-lock", not much did happen and it somehow wasn´t right.
So I put "mode: lsl-mode" instead and was surprised to get an error
message saying that lsl-mode-mode is a void function.  So I found out
about this sort of function calling.

It´s a cool feature, though.  So I made a function lsl-mode-mode, yet
the variable was only created after I would need it.  Consequently, I
abandoned this approach and went back to just put a line into the file
which is searched for and the file name is taken from.

When it´s found, read the patterns from that file and use
hi-lock-set-file-patterns to set them.  That works fine without any

Now when lsl-mode is enabled, just do that (i. e. search, read, apply).
It could even be done for several files that include patterns by doing
it over and over again until no more files to include are found.

It´s working; the only problem I have atm is how to intentionally return
a particular value from a function ...

Once it´s a bit nicer, I want to make it a mode on its own.  I think
it´s too useful to leave it limited to lsl-mode.  I guess I can make it
a mode derived from hi-lock mode; it simply adds some functionality to

Knowledge is volatile and fluid.  Software is power.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]