unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#45577: 27.1; please document default-directory for filters and sentinels
@ 2020-12-31 20:39 Hendrik Tews
  2021-01-01  1:55 ` Unknown
  0 siblings, 1 reply; 7+ messages in thread
From: Hendrik Tews @ 2020-12-31 20:39 UTC (permalink / raw)
  To: 45577

Hi,

the value of default-directory has a number of implicit effects.
Therefore, it would be good, if the elisp manual would
explicitly state the value that default-directory has in process
filters and process sentinels. From the behavior I see, it seems
it gets the value from the working directory of the process. Is
this right?

Thanks,

Hendrik





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

* bug#45577: 27.1; please document default-directory for filters and sentinels
  2020-12-31 20:39 bug#45577: 27.1; please document default-directory for filters and sentinels Hendrik Tews
@ 2021-01-01  1:55 ` Unknown
  2021-01-01 11:03   ` Lars Ingebrigtsen
  2021-01-04 22:39   ` Hendrik Tews
  0 siblings, 2 replies; 7+ messages in thread
From: Unknown @ 2021-01-01  1:55 UTC (permalink / raw)
  To: Hendrik Tews; +Cc: 45577

Hendrik Tews <hendrik@askra.de> writes:

> Hi,
>
> the value of default-directory has a number of implicit effects.
> Therefore, it would be good, if the elisp manual would
> explicitly state the value that default-directory has in process
> filters and process sentinels. From the behavior I see, it seems
> it gets the value from the working directory of the process. Is
> this right?

Process filters and sentinels are functions, so default-directory, as
any other buffer-local variable, will have the value that is bound in
the current buffer.

As you said, it's usually the same as the working directory of the
process, because the working directory of an inferior process in Emacs
is usually initialized from default-directory when the process is
started.  This is described at (info "(elisp) Subprocess Creation").
Note that default-directory *may change* as the user switches buffers or
sets it explicitly with "M-x cd", for example.

For more information about when and how Emacs changes default-directory
for file-visiting and non-file-visiting buffers, see (info "(emacs) File
Names").

I don't think the manual needs to be much more explicit here, IMHO,
because process filters and sentinels are not very different from other
functions.  But let's wait for more opinions from the Emacs developers.





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

* bug#45577: 27.1; please document default-directory for filters and sentinels
  2021-01-01  1:55 ` Unknown
@ 2021-01-01 11:03   ` Lars Ingebrigtsen
  2021-01-04 22:42     ` Hendrik Tews
  2021-01-04 22:39   ` Hendrik Tews
  1 sibling, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-01 11:03 UTC (permalink / raw)
  To: Daniel Martín; +Cc: Hendrik Tews, 45577

Daniel Martín <mardani29@yahoo.es> writes:

> I don't think the manual needs to be much more explicit here, IMHO,
> because process filters and sentinels are not very different from other
> functions.  But let's wait for more opinions from the Emacs developers.

Yeah, I don't think there's anything further to document here?  There's
nothing special about default-directory for sentinels/process filters --
they're called in a buffer, and the default-directory is whatever is in
that buffer, as usual.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#45577: 27.1; please document default-directory for filters and sentinels
  2021-01-01  1:55 ` Unknown
  2021-01-01 11:03   ` Lars Ingebrigtsen
@ 2021-01-04 22:39   ` Hendrik Tews
  1 sibling, 0 replies; 7+ messages in thread
From: Hendrik Tews @ 2021-01-04 22:39 UTC (permalink / raw)
  To: Daniel Martín; +Cc: 45577

Hi,

> Process filters and sentinels are functions, so default-directory, as
> any other buffer-local variable, will have the value that is bound in
> the current buffer.

This means that my guess was wrong. The current buffer may change
independently of the working directory of the process.

> because process filters and sentinels are not very different from other
> functions.

They are called asynchronously and the current buffer may change
arbitrarily and unrelated to the process. For functions called
from the command loop, the user has control over the current
buffer and therefore also default-directory. For filters and
sentinels the user cannot reliably control the current buffer and
neither can the programmer. IMO this is enough difference to
include a warning in the manual that filters and sentinels need
to set the current buffer in case they are not agnostic to the
current buffer of the value of default-directory.

Hendrik





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

* bug#45577: 27.1; please document default-directory for filters and sentinels
  2021-01-01 11:03   ` Lars Ingebrigtsen
@ 2021-01-04 22:42     ` Hendrik Tews
  2021-01-05  8:54       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Hendrik Tews @ 2021-01-04 22:42 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Daniel Martín, 45577

Lars Ingebrigtsen <larsi@gnus.org> writes:

> nothing special about default-directory for sentinels/process filters --
> they're called in a buffer

OK, but where does the manual say in which buffer sentinels and
filters are called? A valid choice could also be the associated
buffer of the process, if it is present.

Hendrik





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

* bug#45577: 27.1; please document default-directory for filters and sentinels
  2021-01-04 22:42     ` Hendrik Tews
@ 2021-01-05  8:54       ` Lars Ingebrigtsen
  2021-01-11 15:49         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-05  8:54 UTC (permalink / raw)
  To: Hendrik Tews; +Cc: 45577, Daniel Martín

Hendrik Tews <hendrik@askra.de> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> nothing special about default-directory for sentinels/process filters --
>> they're called in a buffer
>
> OK, but where does the manual say in which buffer sentinels and
> filters are called? A valid choice could also be the associated
> buffer of the process, if it is present.

As with most (all?) async functions, it's undefined what buffer they're
called from.  As the "Filter Functions" node says, this is the canonical
way of running a filter function:

(defun ordinary-insertion-filter (proc string)
  (when (buffer-live-p (process-buffer proc))
    (with-current-buffer (process-buffer proc)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#45577: 27.1; please document default-directory for filters and sentinels
  2021-01-05  8:54       ` Lars Ingebrigtsen
@ 2021-01-11 15:49         ` Lars Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-11 15:49 UTC (permalink / raw)
  To: Hendrik Tews; +Cc: Daniel Martín, 45577

Lars Ingebrigtsen <larsi@gnus.org> writes:

> As with most (all?) async functions, it's undefined what buffer they're
> called from. 

So I don't think there's anything here that should be documented any
further, and I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2021-01-11 15:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-31 20:39 bug#45577: 27.1; please document default-directory for filters and sentinels Hendrik Tews
2021-01-01  1:55 ` Unknown
2021-01-01 11:03   ` Lars Ingebrigtsen
2021-01-04 22:42     ` Hendrik Tews
2021-01-05  8:54       ` Lars Ingebrigtsen
2021-01-11 15:49         ` Lars Ingebrigtsen
2021-01-04 22:39   ` Hendrik Tews

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).