emacs-devel
[Top][All Lists]
Advanced

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

Re: called by a process filter?


From: Kim F. Storm
Subject: Re: called by a process filter?
Date: Thu, 12 May 2005 14:40:28 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Richard Stallman <address@hidden> writes:

>     Is there a way to tell whether a function was called via process filter?
>
> Not currently.

Doesn't the following work?

(defvar in-my-filter-p nil)

(defun my-filter (proc text)
  (let ((in-my-filter-p t))
    ...))

(defun my-after-change-function ()
  (if in-my-filter-p
    ...


>
> We could envision making the code that calls process filters
> bind this-command to the process that sent the output.
> That is an incompatible change, but your arguments show
> that probably the code that runs in filters would not want
> to test this-command, so it probably won't break anything.

Binding a non-command object (a process) to this-command looks quite
obscure and unclean to me.

Lots of commands look at this-command (and internally we copy it to
last-command etc).  I could envision this change breaking code in
mysterious ways.


If really needed, the filter can do it

(defun my-filter (proc text)
  (let ((this-command proc))
    ...))


>
> We could also create a new variable, perhaps this-process,
> and bind that instead.  I think the former is more elegant.

Again, the filter can do that itself if needed:

(defun my-filter (proc text)
  (let ((this-process proc))
    ...))


I don't think we need to provide a more general approach, at least not
before the release.


-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

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