[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: proper use of add-function
From: |
Michael Heerdegen |
Subject: |
Re: proper use of add-function |
Date: |
Wed, 23 May 2018 01:31:51 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> And another very basic question:
>
> I can't get `add-function' to do its thing. I want to add a :filter-args
> function to #'canonically-space-region, and because this is a minor
> mode, I want it set locally.
I guess there is a problem with what you want to achieve: we have no
buffer local function bindings of symbols.
> (add-function
> :filter-args
> (local 'canonically-space-region)
> #'my-canonical-space-region)
>
> (defun my-canonical-space-region (bounds)
> ;; etc
> (list (car bounds) (nth 1 bounds)))
Technically ok, but this tries to bind the (value cell of the) symbol
canonically-space-region.
What I typically do in this (quite common) scenario is to install the
advice (globally) and check for the mode in the `current-buffer' in the
advice. I guess there is no alternative unless you find a different way
to reach what you want (like advising `canonical-space-region-function',
which doesn't exist).
Michael.