unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* equivalent of make-local-variable for defun?
@ 2008-11-03 16:18 jrwats
  2008-11-03 17:16 ` Paul R
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jrwats @ 2008-11-03 16:18 UTC (permalink / raw)
  To: help-gnu-emacs

I'm trying to fix a mode using comint for an inferior lisp that
apparently needs to overwrite  comint-send-region.  I'd rather it not
overwrite ALL buffers' (including my shell-mode buffer) comint-send-
region function.

Is there a way to define a function but local to the current buffer as
when you define a local variable in make-local-variable?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: equivalent of make-local-variable for defun?
  2008-11-03 16:18 equivalent of make-local-variable for defun? jrwats
@ 2008-11-03 17:16 ` Paul R
       [not found] ` <barmar-01579F.20470803112008@mara100-84.onlink.net>
  2008-11-05 10:01 ` Kevin Rodgers
  2 siblings, 0 replies; 4+ messages in thread
From: Paul R @ 2008-11-03 17:16 UTC (permalink / raw)
  To: jrwats; +Cc: help-gnu-emacs

jrwats> Is there a way to define a function but local to the current
jrwats> buffer as when you define a local variable in
jrwats> make-local-variable?

I don't know very well how buffer-local variables work, but I don't
think you can locally bind an elisp function. A workaround can be to use
a local variable, then set it to a lambda expression, then call the
function with funcall.


-- 
  Paul




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: equivalent of make-local-variable for defun?
       [not found] ` <barmar-01579F.20470803112008@mara100-84.onlink.net>
@ 2008-11-04  6:03   ` jrwats
  0 siblings, 0 replies; 4+ messages in thread
From: jrwats @ 2008-11-04  6:03 UTC (permalink / raw)
  To: help-gnu-emacs

On Nov 3, 5:47 pm, Barry Margolin <bar...@alum.mit.edu> wrote:
> In article
> <1d3363bf-4c06-4424-832a-5abe06f56...@z6g2000pre.googlegroups.com>,
>
>  jrwats <jrw...@gmail.com> wrote:
> > I'm trying to fix a mode using comint for an inferior lisp that
> > apparently needs to overwrite  comint-send-region.  I'd rather it not
> > overwrite ALL buffers' (including my shell-mode buffer) comint-send-
> > region function.
>
> > Is there a way to define a function but local to the current buffer as
> > when you define a local variable in make-local-variable?
>
> You could define around-advice on the function that checks the mode, or
> looks at the value of a buffer-local variable.  If it's in a buffer that
> needs your fix, it runs the advice, otherwise it falls through to the
> regular function.

Thanks!  This will work.  It seems hackish, but it will work!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: equivalent of make-local-variable for defun?
  2008-11-03 16:18 equivalent of make-local-variable for defun? jrwats
  2008-11-03 17:16 ` Paul R
       [not found] ` <barmar-01579F.20470803112008@mara100-84.onlink.net>
@ 2008-11-05 10:01 ` Kevin Rodgers
  2 siblings, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2008-11-05 10:01 UTC (permalink / raw)
  To: help-gnu-emacs

jrwats wrote:
> I'm trying to fix a mode using comint for an inferior lisp that
> apparently needs to overwrite  comint-send-region.  I'd rather it not
> overwrite ALL buffers' (including my shell-mode buffer) comint-send-
> region function.
> 
> Is there a way to define a function but local to the current buffer as
> when you define a local variable in make-local-variable?

Not really, but you can get the same effect like this:

(defadvice comint-send-region (around inferior-lisp-mode activate)
   "In Inferior Lisp mode, call `inferior-lisp-send-region' instead."
   (if (eq major-mode 'inferior-lisp-mode)
       (apply 'inferior-lisp-send-region (ad-get-args 0))
     ad-do-it))

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-11-05 10:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-03 16:18 equivalent of make-local-variable for defun? jrwats
2008-11-03 17:16 ` Paul R
     [not found] ` <barmar-01579F.20470803112008@mara100-84.onlink.net>
2008-11-04  6:03   ` jrwats
2008-11-05 10:01 ` Kevin Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).